pnfs wave 2 submission
Subsystems (2)
cover pnfs wave 2 submission
These patches implement wave 2 of the pnfs submission, which encompasses CB_LAYOUTRECALL and its serialization with LAYOUTGET, as well as the "forgetful model" in which LAYOUTRETURNs are never sent, but instead merely discarded by the client.
They apply on top of Andy's recent 11 patch series.
They are based on Benny's current pnfs-submit branch (commit f5219ae8 pnfs-submit: Turn off layoutcommits) with commits f2591e12..ccf5e6f8 rearranged into a more coherent series (see tag pnfs-submit-wave2-v0.05-submission from my tree at linux-nfs.org/~iisaman/linux-pnfs.git), then rebased on Andy's most recent patches placed on Trond's nfs-for-next.
Fred
[PATCH 01/14] pnfs: wave 2: fix incorrect comment in destroy_lseg [PATCH 02/14] pnfs: wave 2: remove unnecessary field lgp->status [PATCH 03/14] pnfs: wave 2: rename lo->state to lo->plh_flags [PATCH 04/14] pnfs: wave 2: change layout state seqlock to a spinlock [PATCH 05/14] pnfs: wave 2: change how lsegs are removed from layout list [PATCH 06/14] pnfs: wave 2: layoutget rpc code cleanup
[PATCH 07/14] pnfs: wave 2: serialize LAYOUTGET(openstateid) [PATCH 08/14] pnfs: wave 2: Add layout to client list before sending rpc [PATCH 09/14] pnfs: wave 2: check that partial LAYOUTGET return is ignored [PATCH 10/14] pnfs: wave 2: change lo refcounting to atomic_t [PATCH 11/14] pnfs: wave 2: CB_LAYOUTRECALL xdr code
[PATCH 12/14] pnfs: wave 2: add CB_LAYOUTRECALL handling
[PATCH 13/14] pnfs: wave 2: update nfs4_callback_recallany to handle layouts [PATCH 14/14] pnfs: wave 2: layout roc code
PATCH 1/14 pnfs: wave 2: fix incorrect comment in destroy_lseg
Comment references get_layout_hdr_locked, which never existed in submitted code.
--- fs/nfs/pnfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +1 -1
@@ -225,7 +225,7 @@ destroy_lseg(struct kref *kref)dprintk ("--> %s\n" , __func__);NFS_SERVER (ino)->pnfs_curr_ld->free_lseg (lseg); -/* Matched by get_layout_hdr_locked in pnfs_insert_layout */ +/* Matched by get_layout_hdr in pnfs_insert_layout */ put_layout_hdr (ino); }
Signature · 1 line
1.7.2.1
PATCH 2/14 pnfs: wave 2: remove unnecessary field lgp->status
In reply to Fred Isaman--- fs/nfs/nfs4proc.c | 3 +-- include/linux/nfs_xdr.h | 1 - 2 files changed, 1 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +1 -2
@@ -5330,7 +5330,6 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)return ; } } - lgp->status = task->tk_status;dprintk ("<-- %s\n" , __func__); }
@@ -5386,7 +5385,7 @@ int nfs4_proc_layoutget(struct nfs4_layoutget *lgp) status =nfs4_wait_for_completion_rpc_task (task);if (status !=0 ) goto out; - status = lgp->status; + status = task->tk_status;if (status !=0 ) goto out; status =pnfs_layout_process (lgp);
include/linux/nfs_xdr.h +0 -1
@@ -223,7 +223,6 @@ struct nfs4_layoutget {struct nfs4_layoutget_args args;struct nfs4_layoutget_res res;struct pnfs_layout_segment **lsegpp; -int status; };struct nfs4_getdeviceinfo_args {
Signature · 1 line
1.7.2.1
PATCH 3/14 pnfs: wave 2: rename lo->state to lo->plh_flags
In reply to Fred IsamanPreparing for change in stateid code, and want to avoid name confusion.
--- fs/nfs/pnfs.c | 14 +++++++------- fs/nfs/pnfs.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
fs/nfs/pnfs.c +7 -7
@@ -259,7 +259,7 @@ pnfs_clear_lseg_list(struct pnfs_layout_hdr *lo, struct list_head *tmp_list)list_del_init (&lo->layouts);spin_unlock (&clp->cl_lock);write_seqlock (&lo->seqlock); -clear_bit (NFS_LAYOUT_STATEID_SET , &lo->state); +clear_bit (NFS_LAYOUT_STATEID_SET , &lo->plh_flags);write_sequnlock (&lo->seqlock);dprintk ("%s:Return\n" , __func__);
@@ -331,7 +331,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo,bool overwrite = false;write_seqlock (&lo->seqlock); -if (!test_bit (NFS_LAYOUT_STATEID_SET , &lo->state) || +if (!test_bit (NFS_LAYOUT_STATEID_SET , &lo->plh_flags) ||memcmp (old->stateid.other, new->stateid.other,sizeof (new->stateid.other))) overwrite = true;else {
@@ -360,7 +360,7 @@ pnfs_layout_from_open_stateid(struct pnfs_layout_hdr *lo,memcpy (lo->stateid.data, state->stateid.data,sizeof (state->stateid.data)); }while (read_seqretry (&state->seqlock, seq)); -set_bit (NFS_LAYOUT_STATEID_SET , &lo->state); +set_bit (NFS_LAYOUT_STATEID_SET , &lo->plh_flags);write_sequnlock (&lo->seqlock);dprintk ("<-- %s\n" , __func__); }
@@ -374,7 +374,7 @@ pnfs_get_layout_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo,dprintk ("--> %s\n" , __func__); do { seq = read_seqbegin(&lo->seqlock); - if (!test_bit(NFS_LAYOUT_STATEID_SET, &lo->state)) { + if (!test_bit(NFS_LAYOUT_STATEID_SET, &lo->plh_flags)) { /* This will trigger retry of the read */ pnfs_layout_from_open_stateid(lo, open_state); } else
@@ -424,7 +424,7 @@ send_layoutget(struct pnfs_layout_hdr *lo,nfs4_proc_layoutget (lgp);if (!lseg) {/* remember that LAYOUTGET failed and suspend trying */ -set_bit (lo_fail_bit (iomode), &lo->state); +set_bit (lo_fail_bit (iomode), &lo->plh_flags); }return lseg; }
@@ -597,7 +597,7 @@ pnfs_update_layout(struct inode *ino, }/* if LAYOUTGET already failed once we don't try again */ -if (test_bit (lo_fail_bit (iomode), &nfsi->layout->state)) +if (test_bit (lo_fail_bit (iomode), &nfsi->layout->plh_flags)) goto out_unlock;get_layout_hdr_locked (lo);/* Matched in nfs4_layoutget_release */
@@ -606,7 +606,7 @@ pnfs_update_layout(struct inode *ino, lseg =send_layoutget (lo, ctx, iomode); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, - nfsi->layout->state, lseg); + nfsi->layout->plh_flags, lseg);return lseg; out_unlock:spin_unlock (&ino->i_lock);
fs/nfs/pnfs.h +1 -1
@@ -65,7 +65,7 @@ struct pnfs_layout_hdr {struct list_head segs;/* layout segments list */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -unsigned long state; +unsigned long plh_flags;struct inode *inode; };
Signature · 1 line
1.7.2.1
Re: [PATCH 03/14] pnfs: wave 2: rename lo->state to lo->plh_flags
Quoted 1 line · Fred Isaman
Preparing for change in stateid code, and want to avoid name confusion.
None of the other fields in struct pnfs_layout_hdr has a prefix. Either do it for all of them or none, but this version is rather inconsistant.
Re: [PATCH 03/14] pnfs: wave 2: rename lo->state to lo->plh_flags
Quoted 6 lines · Christoph Hellwig
Quoted 1 line · Fred Isaman
Preparing for change in stateid code, and want to avoid name confusion.
None of the other fields in struct
pnfs_layout_hdrhas a prefix. Either do it for all of them or none, but this version is rather inconsistant.
I was trying to minimize change, but I would be happy to change them all. Any complaints about this from any of the other pnfs developers?
Fred
Quoted 5 lines
--
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
PATCH 4/14 pnfs: wave 2: change layout state seqlock to a spinlock
In reply to Fred IsamanThis prepares for future changes, where the layout state needs to change atomically with several other variables. In particular, it will need to know if lo->segs is empty, as we test that instead of manipulating the NFS_LAYOUT_STATEID_SET bit. Moreover, the layoutstateid is not really a read-mostly structure, as it is written almost as often as it is read.
--- fs/nfs/nfs4xdr.c | 2 +- fs/nfs/pnfs.c | 79 +++++++++++++++-------------------------------------- fs/nfs/pnfs.h | 7 ++--- 3 files changed, 27 insertions(+), 61 deletions(-)
fs/nfs/nfs4xdr.c +1 -1
@@ -1800,7 +1800,7 @@ encode_layoutget(struct xdr_stream *xdr, p =xdr_encode_hyper (p, args->range.offset); p =xdr_encode_hyper (p, args->range.length); p =xdr_encode_hyper (p, args->minlength); -pnfs_get_layout_stateid (&stateid,NFS_I (args->inode)->layout, +pnfs_choose_layoutget_stateid (&stateid,NFS_I (args->inode)->layout, args->ctx->state); p =xdr_encode_opaque_fixed (p, &stateid.data,NFS4_STATEID_SIZE ); *p =cpu_to_be32 (args->maxcount);
fs/nfs/pnfs.c +23 -56
108 lines not on this page · raw message
fs/nfs/pnfs.h +3 -4
@@ -44,7 +44,6 @@ struct pnfs_layout_segment {enum {NFS_LAYOUT_RO_FAILED =0 ,/* get ro layout failed stop trying */ NFS_LAYOUT_RW_FAILED ,/* get rw layout failed stop trying */ -NFS_LAYOUT_STATEID_SET ,/* have a valid layout stateid */ };/* Per-layout driver specific registration structure */
@@ -63,7 +62,6 @@ struct pnfs_layout_hdr {unsigned long refcount;struct list_head layouts;/* other client layouts */ struct list_head segs;/* layout segments list */ -seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid;unsigned long plh_flags;struct inode *inode;
@@ -143,8 +141,9 @@ int pnfs_layout_process(struct nfs4_layoutget *lgp);void pnfs_destroy_layout (struct nfs_inode *);void pnfs_destroy_all_layouts (struct nfs_client *);void put_layout_hdr (struct inode *inode); -void pnfs_get_layout_stateid (nfs4_stateid *dst,struct pnfs_layout_hdr *lo, -struct nfs4_state *open_state); +int pnfs_choose_layoutget_stateid (nfs4_stateid *dst, +struct pnfs_layout_hdr *lo, +struct nfs4_state *open_state);static inline int lo_fail_bit (u32 iomode)
Signature · 1 line
1.7.2.1
Re: [PATCH 04/14] pnfs: wave 2: change layout state seqlock to a spinlock
Quoted 6 lines · Fred Isaman
This prepares for future changes, where the layout state needs to change atomically with several other variables. In particular, it will need to know if
lo->segsis empty, as we test that instead of manipulating theNFS_LAYOUT_STATEID_SETbit. Moreover, the layoutstateid is not really a read-mostly structure, as it is written almost as often as it is read.
It also renames a couple of functions.
Re: [PATCH 04/14] pnfs: wave 2: change layout state seqlock to a spinlock
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Fred Isaman
This prepares for future changes, where the layout state needs to change atomically with several other variables. In particular, it will need to know if
lo->segsis empty, as we test that instead of manipulating theNFS_LAYOUT_STATEID_SETbit. Moreover, the layoutstateid is not really a read-mostly structure, as it is written almost as often as it is read.It also renames a couple of functions.
I assume you refer to pnfs_get_layout_stateid -> pnfs_choose_layoutget_stateid. I was thinking of them as entirely different functions, as one actually changed the stateid, and the other doesn't. But I can put a comment in the description clarifying that.
Fred
Quoted 5 lines
--
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
PATCH 5/14 pnfs: wave 2: change how lsegs are removed from layout list
In reply to Fred IsamanThis is to prepare the way for sensible io draining. Instead of just removing the lseg from the list, we instead clear the VALID flag (preventing new io from grabbing references to the lseg) and remove the reference holding it in the list. Thus the lseg will be removed once any io in progress completes and any references still held are dropped.
--- fs/nfs/inode.c | 2 +- fs/nfs/pnfs.c | 121 ++++++++++++++++++++++++++++++++++++------------------- fs/nfs/pnfs.h | 8 +++- 3 files changed, 87 insertions(+), 44 deletions(-)
fs/nfs/inode.c +1 -1
@@ -1410,9 +1410,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)*/ void nfs4_evict_inode (struct inode *inode) { +pnfs_destroy_layout (NFS_I (inode));truncate_inode_pages (&inode->i_data,0 );end_writeback (inode); -pnfs_destroy_layout (NFS_I (inode));/* If we are holding a delegation, return it! */ nfs_inode_return_delegation_noreclaim (inode);/* First call standard NFS clear_inode() code */
fs/nfs/pnfs.c +79 -42
178 lines not on this page · raw message
fs/nfs/pnfs.h +7 -1
@@ -30,10 +30,15 @@#ifndef FS_NFS_PNFS_H #define FS_NFS_PNFS_H +enum { +NFS_LSEG_VALID =0 ,/* cleared when lseg is recalled/returned */ +}; +struct pnfs_layout_segment {struct list_head fi_list;struct pnfs_layout_range range; -struct kref kref; +atomic_t pls_refcount; +unsigned long pls_flags;struct pnfs_layout_hdr *layout; };
@@ -44,6 +49,7 @@ struct pnfs_layout_segment {enum {NFS_LAYOUT_RO_FAILED =0 ,/* get ro layout failed stop trying */ NFS_LAYOUT_RW_FAILED ,/* get rw layout failed stop trying */ +NFS_LAYOUT_DESTROYED ,/* no new use of layout allowed */ };/* Per-layout driver specific registration structure */
Signature · 1 line
1.7.2.1
PATCH 6/14 pnfs: wave 2: layoutget rpc code cleanup
In reply to Fred IsamanNo functional changes, just some code minor code rearrangement and comments.
--- fs/nfs/nfs4proc.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
fs/nfs/nfs4proc.c +10 -9
@@ -5297,10 +5297,14 @@ static void nfs4_layoutget_prepare(struct rpc_task *task, void *calldata) { struct nfs4_layoutget *lgp = calldata; -struct inode *ino = lgp->args.inode; -struct nfs_server *server =NFS_SERVER (ino); +struct nfs_server *server =NFS_SERVER (lgp->args.inode);dprintk ("--> %s\n" , __func__); +/* Note the is a race here, where a CB_LAYOUTRECALL can come in +* right now covering the LAYOUTGET we are about to send. +* However, that is not so catastrophic, and there seems +* to be no way to prevent it completely. +*/ if (nfs4_setup_sequence (server, &lgp->args.seq_args, &lgp->res.seq_res,0 , task))return ;
@@ -5383,13 +5387,10 @@ int nfs4_proc_layoutget(struct nfs4_layoutget *lgp)if (IS_ERR (task))return PTR_ERR (task); status =nfs4_wait_for_completion_rpc_task (task); -if (status !=0 ) - goto out; - status = task->tk_status; -if (status !=0 ) - goto out; - status =pnfs_layout_process (lgp); -out: +if (status ==0 ) + status = task->tk_status; +if (status ==0 ) + status =pnfs_layout_process (lgp);rpc_put_task (task);dprintk ("<-- %s status=%d\n" , __func__, status);return status;
Signature · 1 line
1.7.2.1
PATCH 7/14 pnfs: wave 2: serialize LAYOUTGET(openstateid)
In reply to Fred IsamanWe shouldn't send a LAYOUTGET(openstateid) unless all outstanding RPCs using the previous stateid are completed. This requires adding a status to encode_layoutget() to handle the case where we can't choose an appropriate stateid (we want to use the open stateid, but a LAYOUTGET is already out using it), and adding a count of the number of outstanding rpc calls using layout state (which for now consist solely of LAYOUTGETs).
--- fs/nfs/nfs4proc.c | 1 - fs/nfs/nfs4xdr.c | 16 ++++++++++++---- fs/nfs/pnfs.c | 27 ++++++++++++++++++++++----- fs/nfs/pnfs.h | 1 + 4 files changed, 35 insertions(+), 10 deletions(-)
fs/nfs/nfs4proc.c +0 -1
@@ -5342,7 +5342,6 @@ static void nfs4_layoutget_release(void *calldata)struct nfs4_layoutget *lgp = calldata;dprintk ("--> %s\n" , __func__); -put_layout_hdr (lgp->args.inode);if (lgp->res.layout.buf !=NULL )free_page ((unsigned long ) lgp->res.layout.buf);put_nfs_open_context (lgp->args.ctx);
fs/nfs/nfs4xdr.c +12 -4
@@ -1784,13 +1784,14 @@ encode_getdeviceinfo(struct xdr_stream *xdr, hdr->replen += decode_getdeviceinfo_maxsz; } -static void +static int encode_layoutget (struct xdr_stream *xdr,const struct nfs4_layoutget_args *args,struct compound_hdr *hdr) {nfs4_stateid stateid;__be32 *p; +int status; p =reserve_space (xdr,44 +NFS4_STATEID_SIZE ); *p++ =cpu_to_be32 (OP_LAYOUTGET );
@@ -1800,8 +1801,11 @@ encode_layoutget(struct xdr_stream *xdr, p =xdr_encode_hyper (p, args->range.offset); p =xdr_encode_hyper (p, args->range.length); p =xdr_encode_hyper (p, args->minlength); -pnfs_choose_layoutget_stateid (&stateid,NFS_I (args->inode)->layout, - args->ctx->state); + status =pnfs_choose_layoutget_stateid (&stateid, +NFS_I (args->inode)->layout, + args->ctx->state); +if (status) +return status; p =xdr_encode_opaque_fixed (p, &stateid.data,NFS4_STATEID_SIZE ); *p =cpu_to_be32 (args->maxcount);
@@ -1814,6 +1818,7 @@ encode_layoutget(struct xdr_stream *xdr, args->maxcount); hdr->nops++; hdr->replen += decode_layoutget_maxsz; + return 0; }#endif /* CONFIG_NFS_V4_1 */
@@ -2670,12 +2675,15 @@ static int nfs4_xdr_enc_layoutget(struct rpc_rqst *req, uint32_t *p,struct compound_hdr hdr = { .minorversion =nfs4_xdr_minorversion (&args->seq_args), }; +int status;xdr_init_encode (&xdr, &req->rq_snd_buf, p);encode_compound_hdr (&xdr, req, &hdr);encode_sequence (&xdr, &args->seq_args, &hdr);encode_putfh (&xdr,NFS_FH (args->inode), &hdr); -encode_layoutget (&xdr, args, &hdr); + status =encode_layoutget (&xdr, args, &hdr); +if (status) +return status;encode_nops (&hdr);return 0 ; }
fs/nfs/pnfs.c +22 -5
@@ -362,6 +362,14 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo,memcpy (&lo->stateid, &new->stateid,sizeof (new->stateid)); } +/* lget is set to 1 if called from inside send_layoutget call chain */ +static bool +pnfs_layoutgets_blocked (struct pnfs_layout_hdr *lo,int lget) +{ +return (list_empty (&lo->segs) && + (atomic_read (&lo->plh_outstanding) > lget)); +} +int pnfs_choose_layoutget_stateid (nfs4_stateid *dst,struct pnfs_layout_hdr *lo,struct nfs4_state *open_state)
@@ -370,7 +378,12 @@ pnfs_choose_layoutget_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo,dprintk ("--> %s\n" , __func__);spin_lock (&lo->inode->i_lock); -if (list_empty (&lo->segs)) { +if (pnfs_layoutgets_blocked (lo,1 )) { +/* We avoid -EAGAIN, as that has special meaning to +* some callers. +*/ + status = -NFS4ERR_LAYOUTTRYLATER ; + }else if (list_empty (&lo->segs)) {int seq; do {
@@ -405,10 +418,8 @@ send_layoutget(struct pnfs_layout_hdr *lo,BUG_ON (ctx ==NULL ); lgp =kzalloc (sizeof (*lgp),GFP_KERNEL ); -if (lgp ==NULL ) { -put_layout_hdr (lo->inode); +if (lgp ==NULL )return NULL ; - } lgp->args.minlength =NFS4_MAX_UINT64 ; lgp->args.maxcount =PNFS_LAYOUT_MAXSIZE ; lgp->args.range.iomode = iomode;
@@ -604,10 +615,16 @@ pnfs_update_layout(struct inode *ino,if (test_bit (lo_fail_bit (iomode), &nfsi->layout->plh_flags)) goto out_unlock; -get_layout_hdr_locked (lo);/* Matched in nfs4_layoutget_release */ +if (pnfs_layoutgets_blocked (lo,0 )) + goto out_unlock; +atomic_inc (&lo->plh_outstanding); + +get_layout_hdr_locked (lo);spin_unlock (&ino->i_lock); lseg =send_layoutget (lo, ctx, iomode); +atomic_dec (&lo->plh_outstanding); +put_layout_hdr (ino); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, nfsi->layout->plh_flags, lseg);
fs/nfs/pnfs.h +1 -0
@@ -69,6 +69,7 @@ struct pnfs_layout_hdr {struct list_head layouts;/* other client layouts */ struct list_head segs;/* layout segments list */ nfs4_stateid stateid; +atomic_t plh_outstanding;/* number of RPCs out */ unsigned long plh_flags;struct inode *inode; };
Signature · 1 line
1.7.2.1
PATCH 8/14 pnfs: wave 2: Add layout to client list before sending rpc
In reply to Fred IsamanSince this list will be used to search for layouts to recall, this is necessary to avoid a race where the recall comes in, sees there is nothing in the client list, and prepares to return NOMATCHING, while the LAYOUTGET gets processed before the recall updates the stateid.
--- fs/nfs/pnfs.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-)
fs/nfs/pnfs.c +19 -8
@@ -463,14 +463,6 @@ pnfs_insert_layout(struct pnfs_layout_hdr *lo,dprintk ("%s:Begin\n" , __func__);assert_spin_locked (&lo->inode->i_lock); -if (list_empty (&lo->segs)) { -struct nfs_client *clp =NFS_SERVER (lo->inode)->nfs_client; - -spin_lock (&clp->cl_lock); -BUG_ON (!list_empty (&lo->layouts)); -list_add_tail (&lo->layouts, &clp->cl_layouts); -spin_unlock (&clp->cl_lock); - }list_for_each_entry (lp, &lo->segs, fi_list) {if (cmp_layout (lp->range.iomode, lseg->range.iomode) >0 )continue ;
@@ -591,6 +583,7 @@ pnfs_update_layout(struct inode *ino, enum pnfs_iomode iomode) {struct nfs_inode *nfsi =NFS_I (ino); +struct nfs_client *clp =NFS_SERVER (ino)->nfs_client;struct pnfs_layout_hdr *lo;struct pnfs_layout_segment *lseg =NULL ;
@@ -620,9 +613,27 @@ pnfs_update_layout(struct inode *ino,atomic_inc (&lo->plh_outstanding);get_layout_hdr_locked (lo); +if (list_empty (&lo->segs)) { +/* The lo must be on the clp list if there is any +* chance of a CB_LAYOUTRECALL(FILE) coming in. +*/ +spin_lock (&clp->cl_lock); +BUG_ON (!list_empty (&lo->layouts)); +list_add_tail (&lo->layouts, &clp->cl_layouts); +spin_unlock (&clp->cl_lock); + }spin_unlock (&ino->i_lock); lseg =send_layoutget (lo, ctx, iomode); +if (!lseg) { +spin_lock (&ino->i_lock); +if (list_empty (&lo->segs)) { +spin_lock (&clp->cl_lock); +list_del_init (&lo->layouts); +spin_unlock (&clp->cl_lock); + } +spin_unlock (&ino->i_lock); + }atomic_dec (&lo->plh_outstanding);put_layout_hdr (ino); out:
Signature · 1 line
1.7.2.1
PATCH 9/14 pnfs: wave 2: check that partial LAYOUTGET return is ignored
In reply to Fred IsamanEither a bad server reply, or our ignoring of multiple array segments in a reply, can cause a reply to not meet our requirements. Ensure that we ignore such replies.
--- fs/nfs/pnfs.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
fs/nfs/pnfs.c +11 -0
@@ -654,6 +654,17 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)struct inode *ino = lo->inode;int status =0 ; +/* Verify we got what we asked for. +* Note that because the xdr parsing only accepts a single +* element array, this can fail even if the server is behaving +* correctly. +*/ +if (lgp->args.range.iomode > res->range.iomode || + res->range.offset !=0 || + res->range.length !=NFS4_MAX_UINT64 ) { + status = -EINVAL ; + goto out; + }/* Inject layout blob into I/O device driver */ lseg =NFS_SERVER (ino)->pnfs_curr_ld->alloc_lseg (lo, res);if (!lseg ||IS_ERR (lseg)) {
Signature · 1 line
1.7.2.1
PATCH 10/14 pnfs: wave 2: change lo refcounting to atomic_t
In reply to Fred IsamanThis will be required to allow us to grab reference outside of i_lock. While we are at it, make put_layout_hdr take the same argument as all the related functions.
--- fs/nfs/pnfs.c | 50 ++++++++++++++++++++++++++++---------------------- fs/nfs/pnfs.h | 4 ++-- 2 files changed, 30 insertions(+), 24 deletions(-)
fs/nfs/pnfs.c +28 -22
@@ -177,34 +177,40 @@ EXPORT_SYMBOL_GPL(pnfs_unregister_layoutdriver);* pNFS client layout cache */ +/* Need to hold i_lock if caller does not already hold reference */ static void -get_layout_hdr_locked (struct pnfs_layout_hdr *lo) +get_layout_hdr (struct pnfs_layout_hdr *lo) { -assert_spin_locked (&lo->inode->i_lock); - lo->refcount++; +atomic_inc (&lo->plh_refcount); }static void -put_layout_hdr_locked (struct pnfs_layout_hdr *lo) +destroy_layout_hdr (struct pnfs_layout_hdr *lo) { -assert_spin_locked (&lo->inode->i_lock); -BUG_ON (lo->refcount ==0 ); +dprintk ("%s: freeing layout cache %p\n" , __func__, lo); +BUG_ON (!list_empty (&lo->layouts)); +NFS_I (lo->inode)->layout =NULL ; +kfree (lo); +} - lo->refcount--; -if (!lo->refcount) { -dprintk ("%s: freeing layout cache %p\n" , __func__, lo); -BUG_ON (!list_empty (&lo->layouts)); -NFS_I (lo->inode)->layout =NULL ; -kfree (lo); - } +static void +put_layout_hdr_locked (struct pnfs_layout_hdr *lo) +{ +BUG_ON (atomic_read (&lo->plh_refcount) ==0 ); +if (atomic_dec_and_test (&lo->plh_refcount)) +destroy_layout_hdr (lo); }void -put_layout_hdr (struct inode *inode) +put_layout_hdr (struct pnfs_layout_hdr *lo) { -spin_lock (&inode->i_lock); -put_layout_hdr_locked (NFS_I (inode)->layout); -spin_unlock (&inode->i_lock); +struct inode *inode = lo->inode; + +BUG_ON (atomic_read (&lo->plh_refcount) ==0 ); +if (atomic_dec_and_lock (&lo->plh_refcount, &inode->i_lock)) { +destroy_layout_hdr (lo); +spin_unlock (&inode->i_lock); + } } static void
@@ -224,7 +230,7 @@ static void free_lseg(struct pnfs_layout_segment *lseg)BUG_ON (atomic_read (&lseg->pls_refcount) !=0 );NFS_SERVER (ino)->pnfs_curr_ld->free_lseg (lseg);/* Matched by get_layout_hdr in pnfs_insert_layout */ -put_layout_hdr (ino); +put_layout_hdr (NFS_I (ino)->layout); }/* The use of tmp_list is necessary because pnfs_curr_ld->free_lseg
@@ -484,7 +490,7 @@ pnfs_insert_layout(struct pnfs_layout_hdr *lo, __func__, lseg, lseg->range.iomode, lseg->range.offset, lseg->range.length); } -get_layout_hdr_locked (lo); +get_layout_hdr (lo);dprintk ("%s:Return\n" , __func__); }
@@ -497,7 +503,7 @@ alloc_init_layout_hdr(struct inode *ino) lo =kzalloc (sizeof (struct pnfs_layout_hdr ),GFP_KERNEL );if (!lo)return NULL ; - lo->refcount =1 ; +atomic_set (&lo->plh_refcount,1 );INIT_LIST_HEAD (&lo->layouts);INIT_LIST_HEAD (&lo->segs); lo->inode = ino;
@@ -612,7 +618,7 @@ pnfs_update_layout(struct inode *ino, goto out_unlock;atomic_inc (&lo->plh_outstanding); -get_layout_hdr_locked (lo); +get_layout_hdr (lo);if (list_empty (&lo->segs)) {/* The lo must be on the clp list if there is any * chance of a CB_LAYOUTRECALL(FILE) coming in.
@@ -635,7 +641,7 @@ pnfs_update_layout(struct inode *ino,spin_unlock (&ino->i_lock); }atomic_dec (&lo->plh_outstanding); -put_layout_hdr (ino); +put_layout_hdr (lo); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, nfsi->layout->plh_flags, lseg);
fs/nfs/pnfs.h +2 -2
@@ -65,7 +65,7 @@ struct pnfs_layoutdriver_type { };struct pnfs_layout_hdr { -unsigned long refcount; +atomic_t plh_refcount;struct list_head layouts;/* other client layouts */ struct list_head segs;/* layout segments list */ nfs4_stateid stateid;
@@ -147,7 +147,7 @@ void unset_pnfs_layoutdriver(struct nfs_server *);int pnfs_layout_process (struct nfs4_layoutget *lgp);void pnfs_destroy_layout (struct nfs_inode *);void pnfs_destroy_all_layouts (struct nfs_client *); -void put_layout_hdr (struct inode *inode); +void put_layout_hdr (struct pnfs_layout_hdr *lo);int pnfs_choose_layoutget_stateid (nfs4_stateid *dst,struct pnfs_layout_hdr *lo,struct nfs4_state *open_state);
Signature · 1 line
1.7.2.1
PATCH 11/14 pnfs: wave 2: CB_LAYOUTRECALL xdr code
In reply to Fred IsamanThis is the xdr decoding for CB_LAYOUTRECALL.
--- fs/nfs/callback.h | 20 ++++++++++++++ fs/nfs/callback_proc.c | 6 ++++ fs/nfs/callback_xdr.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 94 insertions(+), 1 deletions(-)
fs/nfs/callback.h +20 -0
@@ -138,6 +138,26 @@ extern __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args,void *dummy, struct cb_process_state *cps); +struct cb_layoutrecallargs { +struct sockaddr *cbl_addr; +uint32_t cbl_recall_type; +uint32_t cbl_layout_type; +uint32_t cbl_layoutchanged; +union { +struct { +struct nfs_fh cbl_fh; +struct inode *cbl_inode; +struct pnfs_layout_range cbl_range; +nfs4_stateid cbl_stateid; + }; +struct nfs_fsid cbl_fsid; + }; +}; + +extern unsigned nfs4_callback_layoutrecall ( +struct cb_layoutrecallargs *args, +void *dummy,struct cb_process_state *cps); +extern void nfs4_check_drain_bc_complete (struct nfs4_session *ses);extern void nfs4_cb_take_slot (struct nfs_client *clp);#endif /* CONFIG_NFS_V4_1 */
fs/nfs/callback_proc.c +6 -0
@@ -107,6 +107,12 @@ int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nf#if defined(CONFIG_NFS_V4_1 ) +__be32 nfs4_callback_layoutrecall (struct cb_layoutrecallargs *args, +void *dummy,struct cb_process_state *cps) +{ +return cpu_to_be32 (NFS4ERR_NOTSUPP );/* STUB */ +} +int nfs41_validate_delegation_stateid (struct nfs_delegation *delegation,const nfs4_stateid *stateid) {if (delegation ==NULL )
fs/nfs/callback_xdr.c +68 -1
96 lines not on this page · raw message
Signature · 1 line
1.7.2.1
PATCH 12/14 pnfs: wave 2: add CB_LAYOUTRECALL handling
In reply to Fred IsamanThis is the heart of the wave 2 submission. Add the code to trigger drain and forget of any afected layouts. In addition, we set a "barrier", below which any LAYOUTGET reply is ignored. This is to compensate for the fact that we do not wait for outstanding LAYOUTGETs to complete as per section 12.5.5.2.1 of RFC 5661.
--- fs/nfs/callback_proc.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++- fs/nfs/nfs4_fs.h | 1 + fs/nfs/pnfs.c | 84 +++++++++++++++++++++++++++-------- fs/nfs/pnfs.h | 12 +++++ 4 files changed, 193 insertions(+), 20 deletions(-)
fs/nfs/callback_proc.c +115 -1
@@ -12,6 +12,7 @@#include "callback.h" #include "delegation.h" #include "internal.h" +#include "pnfs.h" #ifdef NFS_DEBUG #define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -107,10 +108,123 @@ int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nf#if defined(CONFIG_NFS_V4_1 ) +static int initiate_layout_draining (struct nfs_client *clp, +struct cb_layoutrecallargs *args) +{ +struct pnfs_layout_hdr *lo; +int rv =NFS4ERR_NOMATCHING_LAYOUT ; + +if (args->cbl_recall_type ==RETURN_FILE ) { +LIST_HEAD (free_me_list); + + args->cbl_inode =NULL ; +spin_lock (&clp->cl_lock); +list_for_each_entry (lo, &clp->cl_layouts, layouts) { +if (nfs_compare_fh (&args->cbl_fh, + &NFS_I (lo->inode)->fh)) +continue ; +if (test_bit (NFS_LAYOUT_BULK_RECALL , &lo->plh_flags)) + rv =NFS4ERR_DELAY ; +else { +/* Without this, layout can be freed as soon +* as we release cl_lock. Matched in +* do_callback_layoutrecall. +*/ +get_layout_hdr (lo); + args->cbl_inode = lo->inode; + rv =NFS4_OK ; + } +break ; + } +spin_unlock (&clp->cl_lock); + +spin_lock (&lo->inode->i_lock); +if (rv ==NFS4_OK ) { + lo->plh_block_lgets++; +mark_matching_lsegs_invalid (lo, &free_me_list, + args->cbl_range.iomode); + } +pnfs_set_layout_stateid (lo, &args->cbl_stateid, true); +spin_unlock (&lo->inode->i_lock); +pnfs_free_lseg_list (&free_me_list); + }else { +struct pnfs_layout_hdr *tmp; +LIST_HEAD (recall_list); +LIST_HEAD (free_me_list); +struct pnfs_layout_range range = { + .iomode =IOMODE_ANY , + .offset =0 , + .length =NFS4_MAX_UINT64 , + }; + +spin_lock (&clp->cl_lock); +list_for_each_entry (lo, &clp->cl_layouts, layouts) { +if ((args->cbl_recall_type ==RETURN_FSID ) && +memcmp (&NFS_SERVER (lo->inode)->fsid, + &args->cbl_fsid,sizeof (struct nfs_fsid ))) +continue ; +get_layout_hdr (lo); +BUG_ON (!list_empty (&lo->plh_bulk_recall)); +list_add (&lo->plh_bulk_recall, &recall_list); + } +spin_unlock (&clp->cl_lock); +list_for_each_entry_safe (lo, tmp, + &recall_list, plh_bulk_recall) { +spin_lock (&lo->inode->i_lock); +set_bit (NFS_LAYOUT_BULK_RECALL , &lo->plh_flags); +mark_matching_lsegs_invalid (lo, &free_me_list, range.iomode); +list_del_init (&lo->plh_bulk_recall); +spin_unlock (&lo->inode->i_lock); +put_layout_hdr (lo); + rv =NFS4_OK ; + } +pnfs_free_lseg_list (&free_me_list); + } +return rv; +} + +static u32 do_callback_layoutrecall (struct nfs_client *clp, +struct cb_layoutrecallargs *args) +{ +u32 status, res =NFS4ERR_DELAY ; + +dprintk ("%s enter, type=%i\n" , __func__, args->cbl_recall_type); +if (test_and_set_bit (NFS4CLNT_LAYOUTRECALL , &clp->cl_state)) + goto out; + status =initiate_layout_draining (clp, args); +if (status) + res = status; +else if (args->cbl_recall_type ==RETURN_FILE ) { +struct pnfs_layout_hdr *lo; + + lo =NFS_I (args->cbl_inode)->layout; +spin_lock (&lo->inode->i_lock); + lo->plh_block_lgets--; +spin_unlock (&lo->inode->i_lock); +put_layout_hdr (lo); + res =NFS4ERR_DELAY ; + } +clear_bit (NFS4CLNT_LAYOUTRECALL , &clp->cl_state); +out: +dprintk ("%s returning %i\n" , __func__, res); +return res; + +} +__be32 nfs4_callback_layoutrecall (struct cb_layoutrecallargs *args,void *dummy,struct cb_process_state *cps) { -return cpu_to_be32 (NFS4ERR_NOTSUPP );/* STUB */ +u32 res; + +dprintk ("%s: -->\n" , __func__); + +if (cps->clp) + res =do_callback_layoutrecall (cps->clp, args); +else + res =NFS4ERR_OP_NOT_IN_SESSION ; + +dprintk ("%s: exit with status = %d\n" , __func__, res); +return cpu_to_be32 (res); }int nfs41_validate_delegation_stateid (struct nfs_delegation *delegation,const nfs4_stateid *stateid)
fs/nfs/nfs4_fs.h +1 -0
@@ -44,6 +44,7 @@ enum nfs4_client_state {NFS4CLNT_RECLAIM_REBOOT ,NFS4CLNT_RECLAIM_NOGRACE ,NFS4CLNT_DELEGRETURN , +NFS4CLNT_LAYOUTRECALL ,NFS4CLNT_SESSION_RESET , NFS4CLNT_RECALL_SLOT, };
fs/nfs/pnfs.c +65 -19
182 lines not on this page · raw message
fs/nfs/pnfs.h +12 -0
@@ -49,6 +49,7 @@ struct pnfs_layout_segment {enum {NFS_LAYOUT_RO_FAILED =0 ,/* get ro layout failed stop trying */ NFS_LAYOUT_RW_FAILED ,/* get rw layout failed stop trying */ +NFS_LAYOUT_BULK_RECALL ,/* bulk recall affecting layout */ NFS_LAYOUT_DESTROYED ,/* no new use of layout allowed */ };
@@ -67,9 +68,12 @@ struct pnfs_layoutdriver_type {struct pnfs_layout_hdr {atomic_t plh_refcount;struct list_head layouts;/* other client layouts */ +struct list_head plh_bulk_recall;/* clnt list of bulk recalls */ struct list_head segs;/* layout segments list */ nfs4_stateid stateid;atomic_t plh_outstanding;/* number of RPCs out */ +unsigned long plh_block_lgets;/* block LAYOUTGET if >0 */ +u32 plh_barrier;/* ignore lower seqids */ unsigned long plh_flags;struct inode *inode; };
@@ -139,18 +143,26 @@ extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,extern int nfs4_proc_layoutget (struct nfs4_layoutget *lgp);/* pnfs.c */ +void get_layout_hdr (struct pnfs_layout_hdr *lo);struct pnfs_layout_segment *pnfs_update_layout (struct inode *ino,struct nfs_open_context *ctx,enum pnfs_iomode access_type);void set_pnfs_layoutdriver (struct nfs_server *,u32 id);void unset_pnfs_layoutdriver (struct nfs_server *);int pnfs_layout_process (struct nfs4_layoutget *lgp); +void pnfs_free_lseg_list (struct list_head *tmp_list);void pnfs_destroy_layout (struct nfs_inode *);void pnfs_destroy_all_layouts (struct nfs_client *);void put_layout_hdr (struct pnfs_layout_hdr *lo); +void pnfs_set_layout_stateid (struct pnfs_layout_hdr *lo, +const nfs4_stateid *new, +bool update_barrier);int pnfs_choose_layoutget_stateid (nfs4_stateid *dst,struct pnfs_layout_hdr *lo,struct nfs4_state *open_state); +bool mark_matching_lsegs_invalid (struct pnfs_layout_hdr *lo, +struct list_head *tmp_list, +u32 iomode);static inline int lo_fail_bit (u32 iomode)
Signature · 1 line
1.7.2.1
PATCH 13/14 pnfs: wave 2: update nfs4_callback_recallany to handle layouts
In reply to Fred IsamanFrom: Alexandros Batsakis <[email protected]>
While here, update the code a bit.
--- fs/nfs/callback.h | 8 ++++++++ fs/nfs/callback_proc.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)
fs/nfs/callback.h +8 -0
@@ -119,6 +119,14 @@ extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation,#define RCA4_TYPE_MASK_RDATA_DLG 0#define RCA4_TYPE_MASK_WDATA_DLG 1 +#define RCA4_TYPE_MASK_DIR_DLG 2 +#define RCA4_TYPE_MASK_FILE_LAYOUT 3 +#define RCA4_TYPE_MASK_BLK_LAYOUT 4 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8 +#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12 +#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15 +#define RCA4_TYPE_MASK_ALL 0xf31fstruct cb_recallanyargs {struct sockaddr *craa_addr;
fs/nfs/callback_proc.c +26 -3
@@ -227,6 +227,17 @@ __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,return cpu_to_be32 (res); } +static void pnfs_recall_all_layouts (struct nfs_client *clp) +{ +struct cb_layoutrecallargs args; + +/* Pretend we got a CB_LAYOUTRECALL(ALL) */ +memset (&args,0 ,sizeof (args)); + args.cbl_recall_type =RETURN_ALL ; +/* FIXME we ignore errors, what should we do? */ +do_callback_layoutrecall (clp, &args); +} +int nfs41_validate_delegation_stateid (struct nfs_delegation *delegation,const nfs4_stateid *stateid) {if (delegation ==NULL )
@@ -418,29 +429,41 @@ out:return status; } +static bool +validate_bitmap_values (unsigned long mask) +{ +return (mask & ~RCA4_TYPE_MASK_ALL ) ==0 ; +} +__be32 nfs4_callback_recallany (struct cb_recallanyargs *args,void *dummy,struct cb_process_state *cps) {__be32 status;fmode_t flags =0 ; - status =htonl (NFS4ERR_OP_NOT_IN_SESSION ); + status =cpu_to_be32 (NFS4ERR_OP_NOT_IN_SESSION );if (!cps->clp)/* set in cb_sequence */ goto out;dprintk ("NFS: RECALL_ANY callback request from %s\n" ,rpc_peeraddr2str (cps->clp->cl_rpcclient,RPC_DISPLAY_ADDR )); + status =cpu_to_be32 (NFS4ERR_INVAL ); +if (!validate_bitmap_values (args->craa_type_mask)) + goto out; + + status =cpu_to_be32 (NFS4_OK );if (test_bit (RCA4_TYPE_MASK_RDATA_DLG , (const unsigned long *) &args->craa_type_mask)) flags =FMODE_READ ;if (test_bit (RCA4_TYPE_MASK_WDATA_DLG , (const unsigned long *) &args->craa_type_mask)) flags |=FMODE_WRITE ; - +if (test_bit (RCA4_TYPE_MASK_FILE_LAYOUT , (const unsigned long *) + &args->craa_type_mask)) +pnfs_recall_all_layouts (cps->clp);if (flags)nfs_expire_all_delegation_types (cps->clp, flags); - status =htonl (NFS4_OK ); out:dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status));return status;
Signature · 1 line
1.7.2.1
PATCH 14/14 pnfs: wave 2: layout roc code
In reply to Fred IsamanA lsyout can request return-on-close. How this interacts with the forgetful model of never sending LAYOUTRETURNS is a bit ambiguous. We forget any layouts marked roc, and wait for them to be completely forgotten before continuing with the close. In addition, to compensate for races with any inflight LAYOUTGETs, and the fact that we do not get any layout stateid back from the server, we set the barrier to the worst case scenario of current_seqid + number of outstanding LAYOUTGETS.
--- fs/nfs/inode.c | 1 + fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4proc.c | 17 ++++++++- fs/nfs/nfs4state.c | 7 +++- fs/nfs/pnfs.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/pnfs.h | 27 +++++++++++++++ include/linux/nfs_fs.h | 1 + 7 files changed, 134 insertions(+), 5 deletions(-)
fs/nfs/inode.c +1 -0
@@ -1450,6 +1450,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi) nfsi->delegation =NULL ; nfsi->delegation_state =0 ;init_rwsem (&nfsi->rwsem); +rpc_init_wait_queue (&nfsi->lo_rpcwaitq,"pNFS Layoutreturn" ); nfsi->layout =NULL ;#endif }
fs/nfs/nfs4_fs.h +1 -1
@@ -242,7 +242,7 @@ extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *);extern int nfs4_proc_renew (struct nfs_client *,struct rpc_cred *);extern int nfs4_init_clientid (struct nfs_client *,struct rpc_cred *);extern int nfs41_init_clientid (struct nfs_client *,struct rpc_cred *); -extern int nfs4_do_close (struct path *path,struct nfs4_state *state,gfp_t gfp_mask,int wait); +extern int nfs4_do_close (struct path *path,struct nfs4_state *state,gfp_t gfp_mask,int wait,bool roc);extern int nfs4_server_capabilities (struct nfs_server *server,struct nfs_fh *fhandle);extern int nfs4_proc_fs_locations (struct inode *dir,const struct qstr *name,struct nfs4_fs_locations *fs_locations,struct page *page);
fs/nfs/nfs4proc.c +15 -2
@@ -1838,6 +1838,8 @@ struct nfs4_closedata {struct nfs_closeres res;struct nfs_fattr fattr;unsigned long timestamp; +bool roc; +u32 roc_barrier; };static void nfs4_free_closedata (void *data)
@@ -1845,6 +1847,8 @@ static void nfs4_free_closedata(void *data)struct nfs4_closedata *calldata = data;struct nfs4_state_owner *sp = calldata->state->owner; +if (calldata->roc) +pnfs_roc_release (calldata->state->inode);nfs4_put_open_state (calldata->state);nfs_free_seqid (calldata->arg.seqid);nfs4_put_state_owner (sp);
@@ -1877,6 +1881,9 @@ static void nfs4_close_done(struct rpc_task *task, void *data)*/ switch (task->tk_status) {case 0 : +if (calldata->roc) +pnfs_roc_set_barrier (state->inode, + calldata->roc_barrier);nfs_set_open_stateid (state, &calldata->res.stateid,0 );renew_lease (server, calldata->timestamp); nfs4_close_clear_stateid_flags(state,
@@ -1929,8 +1936,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)return ; } -if (calldata->arg.fmode ==0 ) +if (calldata->arg.fmode ==0 ) { task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE ]; +if (calldata->roc) +pnfs_roc_drain (state->inode, &calldata->roc_barrier, task); + }nfs_fattr_init (calldata->res.fattr); calldata->timestamp = jiffies;
@@ -1958,7 +1968,7 @@ static const struct rpc_call_ops nfs4_close_ops = {* * NOTE: Caller must be holding the sp->so_owner semaphore! */ -int nfs4_do_close (struct path *path,struct nfs4_state *state,gfp_t gfp_mask,int wait) +int nfs4_do_close (struct path *path,struct nfs4_state *state,gfp_t gfp_mask,int wait,bool roc) {struct nfs_server *server =NFS_SERVER (state->inode);struct nfs4_closedata *calldata;
@@ -1993,6 +2003,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, i calldata->res.fattr = &calldata->fattr; calldata->res.seqid = calldata->arg.seqid; calldata->res.server = server; + calldata->roc = roc;path_get (path); calldata->path = *path;
@@ -2010,6 +2021,8 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, i out_free_calldata:kfree (calldata); out: +if (roc) +pnfs_roc_release (state->inode);nfs4_put_open_state (state);nfs4_put_state_owner (sp);return status;
fs/nfs/nfs4state.c +5 -2
@@ -607,8 +607,11 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,if (!call_close) {nfs4_put_open_state (state);nfs4_put_state_owner (owner); - }else -nfs4_do_close (path, state, gfp_mask, wait); + }else { +bool roc =pnfs_roc (state->inode); + +nfs4_do_close (path, state, gfp_mask, wait, roc); + } }void nfs4_close_state (struct path *path,struct nfs4_state *state,fmode_t fmode)
fs/nfs/pnfs.c +84 -0
102 lines not on this page · raw message
fs/nfs/pnfs.h +27 -0
@@ -32,6 +32,7 @@enum {NFS_LSEG_VALID =0 ,/* cleared when lseg is recalled/returned */ +NFS_LSEG_ROC ,/* roc bit received from server */ };struct pnfs_layout_segment {
@@ -50,6 +51,7 @@ enum {NFS_LAYOUT_RO_FAILED =0 ,/* get ro layout failed stop trying */ NFS_LAYOUT_RW_FAILED ,/* get rw layout failed stop trying */ NFS_LAYOUT_BULK_RECALL ,/* bulk recall affecting layout */ +NFS_LAYOUT_ROC ,/* some lseg had roc bit set */ NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */ };
@@ -163,6 +165,10 @@ int pnfs_choose_layoutget_stateid(nfs4_stateid *dst,bool mark_matching_lsegs_invalid (struct pnfs_layout_hdr *lo,struct list_head *tmp_list,u32 iomode); +bool pnfs_roc (struct inode *ino); +void pnfs_roc_release (struct inode *ino); +void pnfs_roc_set_barrier (struct inode *ino,u32 barrier); +void pnfs_roc_drain (struct inode *ino,u32 *barrier,struct rpc_task *task);static inline int lo_fail_bit (u32 iomode)
@@ -194,6 +200,27 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,return NULL ; } +static inline bool +pnfs_roc (struct inode *ino) +{ +return false; +} + +static inline void +pnfs_roc_release (struct inode *ino) +{ +} + +static inline void +pnfs_roc_set_barrier (struct inode *ino,u32 barrier) +{ +} + +static inline void +pnfs_roc_drain (struct inode *ino,u32 *barrier,struct rpc_task *task) +{ +} +static inline void set_pnfs_layoutdriver (struct nfs_server *s,u32 id) { }
include/linux/nfs_fs.h +1 -0
@@ -190,6 +190,7 @@ struct nfs_inode {struct rw_semaphore rwsem;/* pNFS layout information */ +struct rpc_wait_queue lo_rpcwaitq;struct pnfs_layout_hdr *layout;#endif /* CONFIG_NFS_V4*/ #ifdef CONFIG_NFS_FSCACHE
Signature · 1 line
1.7.2.1
I don't think the wave 2 in the subject lines of the patches is overly useful, care to remove it?
Quoted 3 lines · Christoph Hellwig
I don't think the wave 2 in the subject lines of the patches is overly useful, care to remove it?
Agreed.
Quoted 5 lines
--
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
Quoted 2 lines · On Tue, Dec 21, 2010 at 10:20 AM, Christoph Hellwig <[email protected]>= wrote:
I don't think the wave 2 in the subject lines of the patches is overl=
y useful,
Quoted 2 lines
care to remove it?
Sure.
=46red
Quoted 2 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" =
in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.html