minor delegation cleanup & fixes
Subsystems (2)
This is cleanup of a little bit of delegation recall code, with a fix for a small race. For 3.10.
--b.
PATCH 1/4 nfsd4: minor cb_recall simplification
From: "J. Bruce Fields" <[email protected]>
--- fs/nfsd/nfs4callback.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/nfsd/nfs4callback.c +3 -5
@@ -817,8 +817,7 @@ static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task)static void nfsd4_cb_prepare (struct rpc_task *task,void *calldata) {struct nfsd4_callback *cb = calldata; - struct nfs4_delegation *dp = container_of(cb, struct nfs4_delegation, dl_recall); -struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfs4_client *clp = cb->cb_clp;u32 minorversion = clp->cl_minorversion; cb->cb_minorversion = minorversion;
@@ -839,8 +838,7 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata)static void nfsd4_cb_done (struct rpc_task *task,void *calldata) {struct nfsd4_callback *cb = calldata; - struct nfs4_delegation *dp = container_of(cb, struct nfs4_delegation, dl_recall); -struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfs4_client *clp = cb->cb_clp;dprintk ("%s: minorversion=%d\n" , __func__, clp->cl_minorversion);
@@ -863,7 +861,7 @@ static void nfsd4_cb_recall_done(struct rpc_task *task, void *calldata) {struct nfsd4_callback *cb = calldata; struct nfs4_delegation *dp = container_of(cb, struct nfs4_delegation, dl_recall); -struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfs4_client *clp = cb->cb_clp;struct rpc_clnt *current_rpc_client = clp->cl_cb_client;nfsd4_cb_done (task, calldata);
Signature · 1 line
1.7.11.7
PATCH 2/4 nfsd4: shut down more of delegation earlier
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
Once we've unhashed the delegation, it's only hanging around for the benefit of an oustanding recall, which only needs the encoded filehandle, stateid, and dl_retries counter. No point keeping the file around any longer, or keeping it hashed.
This also fixes a race: calls to idr_remove should really be serialized by the caller, but the nfs4_put_delegation call from the callback code isn't taking the state lock.
(Better might be to cancel the callback before destroying the delegation, and remove any need for reference counting--but I don't see an easy way to cancel an rpc call.)
--- fs/nfsd/nfs4state.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/nfsd/nfs4state.c +7 -6
@@ -417,21 +417,18 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct svreturn dp; } -static void free_stid (struct nfs4_stid *s,struct kmem_cache *slab) +static void remove_stid (struct nfs4_stid *s) {struct idr *stateids = &s->sc_client->cl_stateids;idr_remove (stateids, s->sc_stateid.si_opaque.so_id); -kmem_cache_free (slab, s); }void nfs4_put_delegation (struct nfs4_delegation *dp) {if (atomic_dec_and_test (&dp->dl_count)) { -dprintk ("NFSD: freeing dp %p\n" ,dp); -put_nfs4_file (dp->dl_file); -free_stid (&dp->dl_stid, deleg_slab); +kmem_cache_free (deleg_slab, dp); num_delegations--; } }
@@ -462,6 +459,9 @@ unhash_delegation(struct nfs4_delegation *dp)list_del_init (&dp->dl_recall_lru);spin_unlock (&recall_lock);nfs4_put_deleg_lease (dp->dl_file); +put_nfs4_file (dp->dl_file); + dp->dl_file =NULL ; +remove_stid (&dp->dl_stid);nfs4_put_delegation (dp); }
@@ -605,7 +605,8 @@ static void close_generic_stateid(struct nfs4_ol_stateid *stp)static void free_generic_stateid (struct nfs4_ol_stateid *stp) { -free_stid (&stp->st_stid, stateid_slab); +remove_stid (&stp->st_stid); +kmem_cache_free (stateid_slab, stp); }static void release_lock_stateid (struct nfs4_ol_stateid *stp)
Signature · 1 line
1.7.11.7
PATCH 3/4 nfsd4: make del_recall_lru per-network-namespace
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
If nothing else this simplifies the nfs4_state_shutdown_net logic a tad.
--- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4state.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-)
fs/nfsd/netns.h +1 -0
@@ -80,6 +80,7 @@ struct nfsd_net {*/ struct list_head client_lru;struct list_head close_lru; +struct list_head del_recall_lru;struct delayed_work laundromat_work;
fs/nfsd/nfs4state.c +7 -8
@@ -225,8 +225,6 @@ opaque_hashval(const void *ptr, int nbytes)return x; } -static struct list_head del_recall_lru; -static void nfsd4_free_file (struct nfs4_file *f) {kmem_cache_free (file_slab, f);
@@ -2583,6 +2581,9 @@ out:static void nfsd_break_one_deleg (struct nfs4_delegation *dp) { +struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); +/* We're assuming the state code never drops its reference * without first removing the lease. Since we're in this lease * callback (and since the lease code is serialized by the kernel
@@ -2590,7 +2591,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)* it's safe to take a reference: */ atomic_inc (&dp->dl_count); -list_add_tail (&dp->dl_recall_lru, &del_recall_lru); +list_add_tail (&dp->dl_recall_lru, &nn->del_recall_lru);/* only place dl_time is set. protected by lock_flocks*/ dp->dl_time =get_seconds ();
@@ -3254,7 +3255,7 @@ nfs4_laundromat(struct nfsd_net *nn)expire_client (clp); }spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);if (net_generic (dp->dl_stid.sc_client->net, nfsd_net_id) != nn)continue ;
@@ -4810,7 +4811,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -INIT_LIST_HEAD (&del_recall_lru); }/*
@@ -4874,6 +4874,7 @@ static int nfs4_state_create_net(struct net *net) nn->unconf_name_tree =RB_ROOT ;INIT_LIST_HEAD (&nn->client_lru);INIT_LIST_HEAD (&nn->close_lru); +INIT_LIST_HEAD (&nn->del_recall_lru);spin_lock_init (&nn->client_lock);INIT_DELAYED_WORK (&nn->laundromat_work, laundromat_main);
@@ -4986,10 +4987,8 @@ nfs4_state_shutdown_net(struct net *net)INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -if (dp->dl_stid.sc_client->net != net) -continue ;list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock);
Signature · 1 line
1.7.11.7
Re: [PATCH 3/4] nfsd4: make del_recall_lru per-network-namespace
Quoted 3 lines · J. Bruce Fields
From: "J. Bruce Fields" <[email protected]>
If nothing else this simplifies the
nfs4_state_shutdown_netlogic a tad.
Stanislav, my one worry is that there was some reason you didn't do this, that I've overlooked....
--b.
Quoted 95 lines
Signed-off-by J. Bruce Fields <[email protected]>--- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4state.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-)fs/nfsd/netns.h +1
-0@@ -80,6 +80,7 @@ struct nfsd_net {*/ struct list_head client_lru;struct list_head close_lru; +struct list_head del_recall_lru;struct delayed_work laundromat_work;fs/nfsd/nfs4state.c +7
-8@@ -225,8 +225,6 @@ opaque_hashval(const void *ptr, int nbytes)return x; } -static struct list_head del_recall_lru; -static void nfsd4_free_file (struct nfs4_file *f) {kmem_cache_free (file_slab, f);@@ -2583,6 +2581,9 @@ out:static void nfsd_break_one_deleg (struct nfs4_delegation *dp) { +struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); +/* We're assuming the state code never drops its reference * without first removing the lease. Since we're in this lease * callback (and since the lease code is serialized by the kernel @@ -2590,7 +2591,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)* it's safe to take a reference: */ atomic_inc (&dp->dl_count); -list_add_tail (&dp->dl_recall_lru, &del_recall_lru); +list_add_tail (&dp->dl_recall_lru, &nn->del_recall_lru);/* only place dl_time is set. protected by lock_flocks*/ dp->dl_time =get_seconds ();@@ -3254,7 +3255,7 @@ nfs4_laundromat(struct nfsd_net *nn)expire_client (clp); }spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);if (net_generic (dp->dl_stid.sc_client->net, nfsd_net_id) != nn)continue ;@@ -4810,7 +4811,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -INIT_LIST_HEAD (&del_recall_lru); }/* @@ -4874,6 +4874,7 @@ static int nfs4_state_create_net(struct net *net) nn->unconf_name_tree =RB_ROOT ;INIT_LIST_HEAD (&nn->client_lru);INIT_LIST_HEAD (&nn->close_lru); +INIT_LIST_HEAD (&nn->del_recall_lru);spin_lock_init (&nn->client_lock);INIT_DELAYED_WORK (&nn->laundromat_work, laundromat_main);@@ -4986,10 +4987,8 @@ nfs4_state_shutdown_net(struct net *net)INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -if (dp->dl_stid.sc_client->net != net) -continue ;list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock);Signature · 6 lines
1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] nfsd4: make del_recall_lru per-network-namespace
05.04.2013 18:09, J. Bruce Fields пишет:
Quoted 8 lines · J. Bruce Fields
Quoted 3 lines
From: "J. Bruce Fields" <[email protected]>
If nothing else this simplifies the
nfs4_state_shutdown_netlogic a tad.Stanislav, my one worry is that there was some reason you didn't do this, that I've overlooked....
Hmm... Currently I can't remember a reason, why I didn't do that... This looks reasonable. Thanks!
BTW, maybe recall_lock should be containerised as well?
Quoted 97 lines
--b.
Quoted 95 lines
Signed-off-by J. Bruce Fields <[email protected]>--- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4state.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-)fs/nfsd/netns.h +1
-0@@ -80,6 +80,7 @@ struct nfsd_net {*/ struct list_head client_lru;struct list_head close_lru; +struct list_head del_recall_lru;struct delayed_work laundromat_work;fs/nfsd/nfs4state.c +7
-9@@ -225,8 +225,6 @@ opaque_hashval(const void *ptr, int nbytes)return x; } -static struct list_head del_recall_lru; -static void nfsd4_free_file (struct nfs4_file *f) {kmem_cache_free (file_slab, f);@@ -2583,6 +2581,9 @@ out:static void nfsd_break_one_deleg (struct nfs4_delegation *dp) { +struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); +/* We're assuming the state code never drops its reference * without first removing the lease. Since we're in this lease * callback (and since the lease code is serialized by the kernel @@ -2590,7 +2591,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)* it's safe to take a reference: */ atomic_inc (&dp->dl_count); -list_add_tail (&dp->dl_recall_lru, &del_recall_lru); +list_add_tail (&dp->dl_recall_lru, &nn->del_recall_lru);/* only place dl_time is set. protected by lock_flocks*/ dp->dl_time =get_seconds ();@@ -3254,7 +3255,7 @@ nfs4_laundromat(struct nfsd_net *nn)expire_client (clp); }spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);if (net_generic (dp->dl_stid.sc_client->net, nfsd_net_id) != nn)continue ;@@ -4810,7 +4811,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -INIT_LIST_HEAD (&del_recall_lru); }/* @@ -4874,6 +4874,7 @@ static int nfs4_state_create_net(struct net *net) nn->unconf_name_tree =RB_ROOT ;INIT_LIST_HEAD (&nn->client_lru);INIT_LIST_HEAD (&nn->close_lru); +INIT_LIST_HEAD (&nn->del_recall_lru);spin_lock_init (&nn->client_lock);INIT_DELAYED_WORK (&nn->laundromat_work, laundromat_main);@@ -4986,10 +4987,8 @@ nfs4_state_shutdown_net(struct net *net)INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -if (dp->dl_stid.sc_client->net != net) -continue ;list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock); --1.7.11.7
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Re: [PATCH 3/4] nfsd4: make del_recall_lru per-network-namespace
Quoted 6 lines · Stanislav Kinsbursky
05.04.2013 18:09, J. Bruce Fields пишет:
Quoted 5 lines · J. Bruce Fields
Quoted 3 lines
From: "J. Bruce Fields" <[email protected]>
If nothing else this simplifies the
nfs4_state_shutdown_netlogic a tad.
Quoted 8 lines
Quoted 3 lines
Stanislav, my one worry is that there was some reason you didn't do this, that I've overlooked....
Hmm... Currently I can't remember a reason, why I didn't do that... This looks reasonable. Thanks!
BTW, maybe
recall_lockshould be containerised as well?
Looks like that also covers manipulations of the global file_hashtbl, so I'm leaving it alone for now.
--b.
Quoted 104 lines
Quoted 99 lines
--b.
Quoted 95 lines
Signed-off-by J. Bruce Fields <[email protected]>--- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4state.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-)fs/nfsd/netns.h +1
-0@@ -80,6 +80,7 @@ struct nfsd_net {*/ struct list_head client_lru;struct list_head close_lru; +struct list_head del_recall_lru;struct delayed_work laundromat_work;fs/nfsd/nfs4state.c +7
-9@@ -225,8 +225,6 @@ opaque_hashval(const void *ptr, int nbytes)return x; } -static struct list_head del_recall_lru; -static void nfsd4_free_file (struct nfs4_file *f) {kmem_cache_free (file_slab, f);@@ -2583,6 +2581,9 @@ out:static void nfsd_break_one_deleg (struct nfs4_delegation *dp) { +struct nfs4_client *clp = dp->dl_stid.sc_client; +struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); +/* We're assuming the state code never drops its reference * without first removing the lease. Since we're in this lease * callback (and since the lease code is serialized by the kernel @@ -2590,7 +2591,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)* it's safe to take a reference: */ atomic_inc (&dp->dl_count); -list_add_tail (&dp->dl_recall_lru, &del_recall_lru); +list_add_tail (&dp->dl_recall_lru, &nn->del_recall_lru);/* only place dl_time is set. protected by lock_flocks*/ dp->dl_time =get_seconds ();@@ -3254,7 +3255,7 @@ nfs4_laundromat(struct nfsd_net *nn)expire_client (clp); }spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);if (net_generic (dp->dl_stid.sc_client->net, nfsd_net_id) != nn)continue ;@@ -4810,7 +4811,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -INIT_LIST_HEAD (&del_recall_lru); }/* @@ -4874,6 +4874,7 @@ static int nfs4_state_create_net(struct net *net) nn->unconf_name_tree =RB_ROOT ;INIT_LIST_HEAD (&nn->client_lru);INIT_LIST_HEAD (&nn->close_lru); +INIT_LIST_HEAD (&nn->del_recall_lru);spin_lock_init (&nn->client_lock);INIT_DELAYED_WORK (&nn->laundromat_work, laundromat_main);@@ -4986,10 +4987,8 @@ nfs4_state_shutdown_net(struct net *net)INIT_LIST_HEAD (&reaplist);spin_lock (&recall_lock); -list_for_each_safe (pos, next, &del_recall_lru) { +list_for_each_safe (pos, next, &nn->del_recall_lru) { dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); -if (dp->dl_stid.sc_client->net != net) -continue ;list_move (&dp->dl_recall_lru, &reaplist); }spin_unlock (&recall_lock); --1.7.11.7
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Best regards, Stanislav Kinsbursky
PATCH 4/4 nfsd4: remove unused nfs4_check_deleg argument
In reply to J. Bruce FieldsFrom: "J. Bruce Fields" <[email protected]>
--- fs/nfsd/nfs4state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +2 -2
@@ -2737,7 +2737,7 @@ static bool nfsd4_is_deleg_cur(struct nfsd4_open *open) }static __be32 -nfs4_check_deleg (struct nfs4_client *cl,struct nfs4_file *fp,struct nfsd4_open *open, +nfs4_check_deleg (struct nfs4_client *cl,struct nfsd4_open *open,struct nfs4_delegation **dp) {int flags;
@@ -3062,7 +3062,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfif (fp) {if ((status =nfs4_check_open (fp, open, &stp))) goto out; - status =nfs4_check_deleg (cl, fp, open, &dp); + status =nfs4_check_deleg (cl, open, &dp);if (status) goto out; }else {
Signature · 1 line
1.7.11.7