Loading fs/nfs/inode.c +0 −14 Original line number Diff line number Diff line Loading @@ -1822,23 +1822,9 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, clnt->cl_softrtry = 1; clnt->cl_chatty = 1; clp->cl_rpcclient = clnt; clp->cl_cred = rpcauth_lookupcred(clnt->cl_auth, 0); if (IS_ERR(clp->cl_cred)) { up_write(&clp->cl_sem); err = PTR_ERR(clp->cl_cred); clp->cl_cred = NULL; goto out_fail; } memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); nfs_idmap_new(clp); } if (list_empty(&clp->cl_superblocks)) { err = nfs4_init_client(clp); if (err != 0) { up_write(&clp->cl_sem); goto out_fail; } } list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); clnt = rpc_clone_client(clp->cl_rpcclient); if (!IS_ERR(clnt)) Loading fs/nfs/nfs4_fs.h +2 −4 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ struct nfs4_client { atomic_t cl_count; struct rpc_clnt * cl_rpcclient; struct rpc_cred * cl_cred; struct list_head cl_superblocks; /* List of nfs_server structs */ Loading Loading @@ -211,8 +210,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); /* nfs4proc.c */ extern int nfs4_map_errors(int err); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short, struct rpc_cred *); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_async_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); Loading @@ -238,7 +237,6 @@ extern void init_nfsv4_state(struct nfs_server *); extern void destroy_nfsv4_state(struct nfs_server *); extern struct nfs4_client *nfs4_get_client(struct in_addr *); extern void nfs4_put_client(struct nfs4_client *clp); extern int nfs4_init_client(struct nfs4_client *clp); extern struct nfs4_client *nfs4_find_client(struct in_addr *); struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp); extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *); Loading fs/nfs/nfs4proc.c +5 −5 Original line number Diff line number Diff line Loading @@ -2846,7 +2846,7 @@ int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct return nfs4_map_errors(ret); } int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port) int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) { nfs4_verifier sc_verifier; struct nfs4_setclientid setclientid = { Loading @@ -2857,7 +2857,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], .rpc_argp = &setclientid, .rpc_resp = clp, .rpc_cred = clp->cl_cred, .rpc_cred = cred, }; u32 *p; int loop = 0; Loading @@ -2871,7 +2871,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p setclientid.sc_name_len = scnprintf(setclientid.sc_name, sizeof(setclientid.sc_name), "%s/%u.%u.%u.%u %s %u", clp->cl_ipaddr, NIPQUAD(clp->cl_addr.s_addr), clp->cl_cred->cr_ops->cr_name, cred->cr_ops->cr_name, clp->cl_id_uniquifier); setclientid.sc_netid_len = scnprintf(setclientid.sc_netid, sizeof(setclientid.sc_netid), "tcp"); Loading @@ -2894,14 +2894,14 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p } int nfs4_proc_setclientid_confirm(struct nfs4_client *clp) nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred) { struct nfs_fsinfo fsinfo; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], .rpc_argp = clp, .rpc_resp = &fsinfo, .rpc_cred = clp->cl_cred, .rpc_cred = cred, }; unsigned long now; int status; Loading fs/nfs/nfs4state.c +45 −26 Original line number Diff line number Diff line Loading @@ -91,11 +91,10 @@ nfs4_alloc_client(struct in_addr *addr) if (nfs_callback_up() < 0) return NULL; if ((clp = kmalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { nfs_callback_down(); return NULL; } memset(clp, 0, sizeof(*clp)); memcpy(&clp->cl_addr, addr, sizeof(clp->cl_addr)); init_rwsem(&clp->cl_sem); INIT_LIST_HEAD(&clp->cl_delegations); Loading @@ -108,7 +107,7 @@ nfs4_alloc_client(struct in_addr *addr) rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS4 client"); clp->cl_rpcclient = ERR_PTR(-EINVAL); clp->cl_boot_time = CURRENT_TIME; clp->cl_state = 0; clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; return clp; } Loading @@ -125,8 +124,6 @@ nfs4_free_client(struct nfs4_client *clp) kfree(sp); } BUG_ON(!list_empty(&clp->cl_state_owners)); if (clp->cl_cred) put_rpccred(clp->cl_cred); nfs_idmap_delete(clp); if (!IS_ERR(clp->cl_rpcclient)) rpc_shutdown_client(clp->cl_rpcclient); Loading Loading @@ -196,21 +193,17 @@ nfs4_put_client(struct nfs4_client *clp) nfs4_free_client(clp); } static int __nfs4_init_client(struct nfs4_client *clp) static int nfs4_init_client(struct nfs4_client *clp, struct rpc_cred *cred) { int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport); int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport, cred); if (status == 0) status = nfs4_proc_setclientid_confirm(clp); status = nfs4_proc_setclientid_confirm(clp, cred); if (status == 0) nfs4_schedule_state_renewal(clp); return status; } int nfs4_init_client(struct nfs4_client *clp) { return nfs4_map_errors(__nfs4_init_client(clp)); } u32 nfs4_alloc_lockowner_id(struct nfs4_client *clp) { Loading Loading @@ -246,6 +239,18 @@ struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp) return cred; } struct rpc_cred *nfs4_get_setclientid_cred(struct nfs4_client *clp) { struct nfs4_state_owner *sp; if (!list_empty(&clp->cl_state_owners)) { sp = list_entry(clp->cl_state_owners.next, struct nfs4_state_owner, so_list); return get_rpccred(sp->so_cred); } return NULL; } static struct nfs4_state_owner * nfs4_find_state_owner(struct nfs4_client *clp, struct rpc_cred *cred) { Loading Loading @@ -902,6 +907,7 @@ static int reclaimer(void *ptr) struct nfs4_client *clp = ptr; struct nfs4_state_owner *sp; struct nfs4_state_recovery_ops *ops; struct rpc_cred *cred; int status = 0; allow_signal(SIGKILL); Loading @@ -913,20 +919,33 @@ static int reclaimer(void *ptr) if (list_empty(&clp->cl_superblocks)) goto out; restart_loop: status = nfs4_proc_renew(clp, clp->cl_cred); ops = &nfs4_network_partition_recovery_ops; /* Are there any open files on this volume? */ cred = nfs4_get_renew_cred(clp); if (cred != NULL) { /* Yes there are: try to renew the old lease */ status = nfs4_proc_renew(clp, cred); switch (status) { case 0: case -NFS4ERR_CB_PATH_DOWN: put_rpccred(cred); goto out; case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_LEASE_MOVED: ops = &nfs4_reboot_recovery_ops; break; default: ops = &nfs4_network_partition_recovery_ops; }; } } else { /* "reboot" to ensure we clear all state on the server */ clp->cl_boot_time = CURRENT_TIME; cred = nfs4_get_setclientid_cred(clp); } /* We're going to have to re-establish a clientid */ nfs4_state_mark_reclaim(clp); status = __nfs4_init_client(clp); status = -ENOENT; if (cred != NULL) { status = nfs4_init_client(clp, cred); put_rpccred(cred); } if (status) goto out_error; /* Mark all delegations for reclaim */ Loading Loading
fs/nfs/inode.c +0 −14 Original line number Diff line number Diff line Loading @@ -1822,23 +1822,9 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, clnt->cl_softrtry = 1; clnt->cl_chatty = 1; clp->cl_rpcclient = clnt; clp->cl_cred = rpcauth_lookupcred(clnt->cl_auth, 0); if (IS_ERR(clp->cl_cred)) { up_write(&clp->cl_sem); err = PTR_ERR(clp->cl_cred); clp->cl_cred = NULL; goto out_fail; } memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); nfs_idmap_new(clp); } if (list_empty(&clp->cl_superblocks)) { err = nfs4_init_client(clp); if (err != 0) { up_write(&clp->cl_sem); goto out_fail; } } list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); clnt = rpc_clone_client(clp->cl_rpcclient); if (!IS_ERR(clnt)) Loading
fs/nfs/nfs4_fs.h +2 −4 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ struct nfs4_client { atomic_t cl_count; struct rpc_clnt * cl_rpcclient; struct rpc_cred * cl_cred; struct list_head cl_superblocks; /* List of nfs_server structs */ Loading Loading @@ -211,8 +210,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); /* nfs4proc.c */ extern int nfs4_map_errors(int err); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short, struct rpc_cred *); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_async_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); Loading @@ -238,7 +237,6 @@ extern void init_nfsv4_state(struct nfs_server *); extern void destroy_nfsv4_state(struct nfs_server *); extern struct nfs4_client *nfs4_get_client(struct in_addr *); extern void nfs4_put_client(struct nfs4_client *clp); extern int nfs4_init_client(struct nfs4_client *clp); extern struct nfs4_client *nfs4_find_client(struct in_addr *); struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp); extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *); Loading
fs/nfs/nfs4proc.c +5 −5 Original line number Diff line number Diff line Loading @@ -2846,7 +2846,7 @@ int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct return nfs4_map_errors(ret); } int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port) int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) { nfs4_verifier sc_verifier; struct nfs4_setclientid setclientid = { Loading @@ -2857,7 +2857,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], .rpc_argp = &setclientid, .rpc_resp = clp, .rpc_cred = clp->cl_cred, .rpc_cred = cred, }; u32 *p; int loop = 0; Loading @@ -2871,7 +2871,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p setclientid.sc_name_len = scnprintf(setclientid.sc_name, sizeof(setclientid.sc_name), "%s/%u.%u.%u.%u %s %u", clp->cl_ipaddr, NIPQUAD(clp->cl_addr.s_addr), clp->cl_cred->cr_ops->cr_name, cred->cr_ops->cr_name, clp->cl_id_uniquifier); setclientid.sc_netid_len = scnprintf(setclientid.sc_netid, sizeof(setclientid.sc_netid), "tcp"); Loading @@ -2894,14 +2894,14 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p } int nfs4_proc_setclientid_confirm(struct nfs4_client *clp) nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred) { struct nfs_fsinfo fsinfo; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], .rpc_argp = clp, .rpc_resp = &fsinfo, .rpc_cred = clp->cl_cred, .rpc_cred = cred, }; unsigned long now; int status; Loading
fs/nfs/nfs4state.c +45 −26 Original line number Diff line number Diff line Loading @@ -91,11 +91,10 @@ nfs4_alloc_client(struct in_addr *addr) if (nfs_callback_up() < 0) return NULL; if ((clp = kmalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { nfs_callback_down(); return NULL; } memset(clp, 0, sizeof(*clp)); memcpy(&clp->cl_addr, addr, sizeof(clp->cl_addr)); init_rwsem(&clp->cl_sem); INIT_LIST_HEAD(&clp->cl_delegations); Loading @@ -108,7 +107,7 @@ nfs4_alloc_client(struct in_addr *addr) rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS4 client"); clp->cl_rpcclient = ERR_PTR(-EINVAL); clp->cl_boot_time = CURRENT_TIME; clp->cl_state = 0; clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; return clp; } Loading @@ -125,8 +124,6 @@ nfs4_free_client(struct nfs4_client *clp) kfree(sp); } BUG_ON(!list_empty(&clp->cl_state_owners)); if (clp->cl_cred) put_rpccred(clp->cl_cred); nfs_idmap_delete(clp); if (!IS_ERR(clp->cl_rpcclient)) rpc_shutdown_client(clp->cl_rpcclient); Loading Loading @@ -196,21 +193,17 @@ nfs4_put_client(struct nfs4_client *clp) nfs4_free_client(clp); } static int __nfs4_init_client(struct nfs4_client *clp) static int nfs4_init_client(struct nfs4_client *clp, struct rpc_cred *cred) { int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport); int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport, cred); if (status == 0) status = nfs4_proc_setclientid_confirm(clp); status = nfs4_proc_setclientid_confirm(clp, cred); if (status == 0) nfs4_schedule_state_renewal(clp); return status; } int nfs4_init_client(struct nfs4_client *clp) { return nfs4_map_errors(__nfs4_init_client(clp)); } u32 nfs4_alloc_lockowner_id(struct nfs4_client *clp) { Loading Loading @@ -246,6 +239,18 @@ struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp) return cred; } struct rpc_cred *nfs4_get_setclientid_cred(struct nfs4_client *clp) { struct nfs4_state_owner *sp; if (!list_empty(&clp->cl_state_owners)) { sp = list_entry(clp->cl_state_owners.next, struct nfs4_state_owner, so_list); return get_rpccred(sp->so_cred); } return NULL; } static struct nfs4_state_owner * nfs4_find_state_owner(struct nfs4_client *clp, struct rpc_cred *cred) { Loading Loading @@ -902,6 +907,7 @@ static int reclaimer(void *ptr) struct nfs4_client *clp = ptr; struct nfs4_state_owner *sp; struct nfs4_state_recovery_ops *ops; struct rpc_cred *cred; int status = 0; allow_signal(SIGKILL); Loading @@ -913,20 +919,33 @@ static int reclaimer(void *ptr) if (list_empty(&clp->cl_superblocks)) goto out; restart_loop: status = nfs4_proc_renew(clp, clp->cl_cred); ops = &nfs4_network_partition_recovery_ops; /* Are there any open files on this volume? */ cred = nfs4_get_renew_cred(clp); if (cred != NULL) { /* Yes there are: try to renew the old lease */ status = nfs4_proc_renew(clp, cred); switch (status) { case 0: case -NFS4ERR_CB_PATH_DOWN: put_rpccred(cred); goto out; case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_LEASE_MOVED: ops = &nfs4_reboot_recovery_ops; break; default: ops = &nfs4_network_partition_recovery_ops; }; } } else { /* "reboot" to ensure we clear all state on the server */ clp->cl_boot_time = CURRENT_TIME; cred = nfs4_get_setclientid_cred(clp); } /* We're going to have to re-establish a clientid */ nfs4_state_mark_reclaim(clp); status = __nfs4_init_client(clp); status = -ENOENT; if (cred != NULL) { status = nfs4_init_client(clp, cred); put_rpccred(cred); } if (status) goto out_error; /* Mark all delegations for reclaim */ Loading