pnfs-submit fix layout allocation and reference counting
Subsystems (2)
cover pnfs-submit fix layout allocation and reference counting
The current nfs_inode has an embedded pnfs_layout_type structure, with per layout type private data allocated. Change nfs_inode->layout to be a pointer to a pnfs_layout_type structure, embed the pnfs_layout_type in the per layout type structure, and allocate both.
The current pnfs_layout_type allocation waits on a bit lock to handle concurrent allocation attempts. Replace this with the normal form.
The current pnfs_layout_type reference counting is very un-clear, and one instance of put_layout was called outside the i_lock which probably was causing the intermittant pnfs_layout_type refcount bug we've been seeing.
Replace the nfs_inode->layout reference counting with the following scheme:
As in the current code, the pnfs_layout_type reference counting is always done with the inode->i_lock held.
The nfs_inode->layout comes into existence when the first layout_segment is cached and stays until inode is destroyed.
1) alloc nfs_inode->layout:
- Initialized to 1. This holds it around for the clp->cl_layouts (layout->lo_layouts) list.
2) Each layoutget
layoutget GET
layoutget release PUT
3) insert lseg into nfs_inode->layout->segs GET
remove lseg from nfs_inode->layout->segs PUT
I/O - no reference (except the lseg is used and referenced in 3)
4) Each layoutcommit references the layout which keeps it around while in use by the call which could race with layoutreturn
layoutcommit GET
layoutcommit release PUT
5) Each layoutreturn references the layout which keeps it around while in use by the call.
layoutreturn GET
layoutreturn release PUT
6) inode destruction (usually umount)
Destroy_layout PUT to balance initial allocation where it is set to 1.
When the reference moves from 1->0 the layout is removed from the nfs_client cl_layouts list and freed.
Change nfs_inode->layout to be a pointer to a pnfs_layout_type strucure.
0001-SQUASHME-pnfs-submit-add-state-flag-for-layoutcommit.patch 0002-SQUASHME-pnfs-submit-move-pnfs_layout_suspend-back-t.patch 0003-SQUASHME-pnfs-submit-embed-pnfs_layout_type.patch 0004-SQUASHME-pnfs-submit-filelayout-use-new-alloc-free_l.patch
Rewrite the pnfs_layout_type allocation and reference counting
0005-SQUASHME-pnfs-submit-rewrite-layout-allocation.patch 0006-SQUASHME-pnfs-submit-fix-pnfs_update_layout-referenc.patch 0007-SQUASHME-pnfs_submit-don-t-get-a-reference-on-bounda.patch 0008-SQUASHME-pnfs-submit-don-t-reference-the-layout-in-i.patch 0009-SQUASHME-pnfs-submit-pnfs_update_layout-always-refer.patch 0010-SQUASHME-pnfs-submit-reference-the-layout-when-inser.patch 0011-SQUASHME-pnfs-submit-rename-put_layout-to-put_layout.patch 0012-SQUASHME-pnfs-submit-reference-layout-across-layoutc.patch 0013-SQUASHME-pnfs-submit-reference-layout-for-layoutretu.patch 0014-SQUASHME-pnfs-submit-remove-put_layout-from-pnfs_fre.patch 0015-SQUASHME-pnfs-submit-do-not-reference-a-layout-in-de.patch 0016-SQUASHME-pnfs-submit-remove-grab_current_layout.patch
Testing;
CONFIG_NFS_V4_1 set:
Connectathon tests pass against GFS2/pNFS and pyNFS file layout server. Tested with layout return-on-close off and on.
CONFIG_NFS_V4_1 not set;
NFSv4.0 mount passes Connectation tests.
-->Andy
PATCH 1/16 SQUASHME pnfs-submit: add state flag for layoutcommit_needed
From: Fred Isaman <[email protected]>
layoutcommit_needed is called outside of any lock. This avoids locking and existance of layout issues
--- fs/nfs/pnfs.c | 3 +++ include/linux/nfs4_pnfs.h | 2 +- include/linux/nfs_fs.h | 1 + 3 files changed, 5 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +3 -0
@@ -154,6 +154,8 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx)spin_lock (&nfsi->vfs_inode.i_lock);if (has_layout (nfsi) && !layoutcommit_needed (nfsi)) { nfsi->layout.lo_cred =get_rpccred (ctx->state->owner->so_cred); +__set_bit (NFS_INO_LAYOUTCOMMIT , + &nfsi->layout.pnfs_layout_state); nfsi->change_attr++;spin_unlock (&nfsi->vfs_inode.i_lock);dprintk ("%s: Set layoutcommit\n" , __func__);
@@ -1643,6 +1645,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync) nfsi->layout.pnfs_write_begin_pos =0 ; nfsi->layout.pnfs_write_end_pos =0 ; nfsi->layout.lo_cred =NULL ; +__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, &nfsi->layout);spin_unlock (&inode->i_lock);
include/linux/nfs4_pnfs.h +1 -1
@@ -83,7 +83,7 @@ has_layout(struct nfs_inode *nfsi)static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return nfsi->layout.lo_cred !=NULL ; +return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); }#else /* CONFIG_NFS_V4_1 */
include/linux/nfs_fs.h +1 -0
@@ -109,6 +109,7 @@ struct pnfs_layout_type {#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ #define NFS_INO_LAYOUT_ALLOC 2/* bit lock for layout allocation */ +#define NFS_INO_LAYOUTCOMMIT 3/* LAYOUTCOMMIT needed */ time_t pnfs_layout_suspend;struct rpc_cred *lo_cred;/* layoutcommit credential */ /* DH: These vars keep track of the maximum write range
Signature · 1 line
1.6.6
PATCH 2/16 SQUASHME: pnfs-submit: move pnfs_layout_suspend back to nfs_inode
From: Fred Isaman <[email protected]>
Prepare to embed struct pnfs_layout_tupe into layout driver private structs and to make layout a pointer. Since a temp error on first LAYOUTGET erases the layout, the suspend timer needs to be moved.
--- fs/nfs/inode.c | 1 + fs/nfs/pnfs.c | 8 ++++---- include/linux/nfs_fs.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
fs/nfs/inode.c +1 -0
@@ -1396,6 +1396,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)init_rwsem (&nfsi->rwsem);#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); + nfsi->pnfs_layout_suspend =0 ;seqlock_init (&nfsi->layout.seqlock);INIT_LIST_HEAD (&nfsi->layout.lo_layouts);INIT_LIST_HEAD (&nfsi->layout.segs);
fs/nfs/pnfs.c +4 -4
@@ -1114,12 +1114,12 @@ _pnfs_update_layout(struct inode *ino,/* if get layout already failed once goto out */ if (test_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state)) { -if (unlikely (nfsi->layout.pnfs_layout_suspend && -get_seconds () >= nfsi->layout.pnfs_layout_suspend)) { +if (unlikely (nfsi->pnfs_layout_suspend && +get_seconds () >= nfsi->pnfs_layout_suspend)) {dprintk ("%s: layout_get resumed\n" , __func__);clear_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state); - nfsi->layout.pnfs_layout_suspend =0 ; + nfsi->pnfs_layout_suspend =0 ; }else goto out_put; }
@@ -1233,7 +1233,7 @@ pnfs_get_layout_done(struct nfs4_pnfs_layoutget *lgp, int rpc_status) }/* remember that get layout failed and suspend trying */ - nfsi->layout.pnfs_layout_suspend = suspend; + nfsi->pnfs_layout_suspend = suspend;set_bit (lo_fail_bit (lgp->args.lseg.iomode), &nfsi->layout.pnfs_layout_state); dprintk("%s: layout_get suspended until %ld\n",
include/linux/nfs_fs.h +1 -1
@@ -110,7 +110,6 @@ struct pnfs_layout_type {#define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ #define NFS_INO_LAYOUT_ALLOC 2/* bit lock for layout allocation */ #define NFS_INO_LAYOUTCOMMIT 3/* LAYOUTCOMMIT needed */ -time_t pnfs_layout_suspend;struct rpc_cred *lo_cred;/* layoutcommit credential */ /* DH: These vars keep track of the maximum write range * so the values can be used for layoutcommit.
@@ -208,6 +207,7 @@ struct nfs_inode {#if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq;struct pnfs_layout_type layout; +time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/ #ifdef CONFIG_NFS_FSCACHE
Signature · 1 line
1.6.6
PATCH 3/16 SQUASHME pnfs-submit embed pnfs_layout_type
From: Andy Adamson <[email protected]>
Change nfs_inode layout field to a pointer
Each layoutdriver embeds the pnfs_layout_type in it's private layout cache head structure, and allocates them both with the alloc_layout layoutdriver_io_operation.
NOTE API change: the layoutdriver_io_operation alloc_layout and free_layout now use pnfs_layout_type pointers instead of void*.
--- fs/nfs/callback_proc.c | 2 +- fs/nfs/inode.c | 12 +----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 111 +++++++++++++++++++++++---------------------- include/linux/nfs4_pnfs.h | 19 +++----- include/linux/nfs_fs.h | 4 +- 7 files changed, 71 insertions(+), 83 deletions(-)
fs/nfs/callback_proc.c +1 -1
@@ -233,7 +233,7 @@ static int pnfs_recall_layout(void *data) rl.cbl_seg.length =NFS4_MAX_UINT64 ;if (rl.cbl_recall_type ==RETURN_FILE ) { -if (pnfs_is_next_layout_stateid (&NFS_I (inode)->layout, +if (pnfs_is_next_layout_stateid (NFS_I (inode)->layout, rl.cbl_stateid)) status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, RETURN_FILE,
fs/nfs/inode.c +1 -11
@@ -1397,17 +1397,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); nfsi->pnfs_layout_suspend =0 ; -seqlock_init (&nfsi->layout.seqlock); -INIT_LIST_HEAD (&nfsi->layout.lo_layouts); -INIT_LIST_HEAD (&nfsi->layout.segs); - nfsi->layout.refcount =0 ; - nfsi->layout.ld_data =NULL ; - nfsi->layout.pnfs_layout_state =0 ; -memset (&nfsi->layout.stateid,0 ,NFS4_STATEID_SIZE ); - nfsi->layout.roc_iomode =0 ; - nfsi->layout.lo_cred =NULL ; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; + nfsi->layout =NULL ;#endif /* CONFIG_NFS_V4_1 */ #endif }
fs/nfs/nfs4proc.c +1 -1
@@ -1086,7 +1086,7 @@ static void pnfs4_layout_reclaim(struct nfs4_state *state)* flag during grace period */ pnfs_destroy_layout (NFS_I (state->inode)); -pnfs_set_layout_stateid (&NFS_I (state->inode)->layout, &zero_stateid); +pnfs_set_layout_stateid (NFS_I (state->inode)->layout, &zero_stateid);#endif /* CONFIG_NFS_V4_1 */ }
fs/nfs/nfs4state.c +2 -2
@@ -597,10 +597,10 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,#ifdef CONFIG_NFS_V4_1 struct nfs_inode *nfsi =NFS_I (state->inode); -if (has_layout (nfsi) && nfsi->layout.roc_iomode) { +if (has_layout (nfsi) && nfsi->layout->roc_iomode) {struct nfs4_pnfs_layout_segment range; - range.iomode = nfsi->layout.roc_iomode; + range.iomode = nfsi->layout->roc_iomode; range.offset =0 ; range.length =NFS4_MAX_UINT64 ; pnfs_return_layout(state->inode, &range, NULL,
fs/nfs/pnfs.c +57 -54
252 lines not on this page · raw message
include/linux/nfs4_pnfs.h +7 -12
@@ -35,13 +35,13 @@ struct pnfs_layoutdriver_type {static inline struct nfs_inode *PNFS_NFS_INODE (struct pnfs_layout_type *lo) { - return container_of(lo, struct nfs_inode, layout); +return NFS_I (lo->lo_inode); }static inline struct inode *PNFS_INODE (struct pnfs_layout_type *lo) { -return &PNFS_NFS_INODE (lo)->vfs_inode; +return lo->lo_inode; } static inline struct nfs_server *
@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)return NFS_SERVER (PNFS_INODE (lo)); } -static inline void * -PNFS_LD_DATA (struct pnfs_layout_type *lo) -{ -return lo->ld_data; -} -static inline struct pnfs_layoutdriver_type *PNFS_LD (struct pnfs_layout_type *lo) {
@@ -77,13 +71,14 @@ PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo)static inline bool has_layout (struct nfs_inode *nfsi) { -return nfsi->layout.ld_data !=NULL ; +return nfsi->layout !=NULL ; }static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state); }#else /* CONFIG_NFS_V4_1 */
@@ -149,8 +144,8 @@ struct layoutdriver_io_operations {/* Layout information. For each inode, alloc_layout is executed once to retrieve an * inode specific layout structure. Each subsequent layoutget operation results in * a set_layout call to set the opaque layout in the layout driver.*/ -void * (*alloc_layout) (struct inode *inode); -void (*free_layout) (void *layoutid); +struct pnfs_layout_type * (*alloc_layout) (struct inode *inode); +void (*free_layout) (struct pnfs_layout_type *);struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid,struct nfs4_pnfs_layoutget_res *lgr);void (*free_lseg) (struct pnfs_layout_segment *lseg);
include/linux/nfs_fs.h +2 -2
@@ -104,7 +104,6 @@ struct pnfs_layout_type {int roc_iomode;/* iomode to return on close, 0=none */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -void *ld_data;/* layout driver private data */ unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */
@@ -116,6 +115,7 @@ struct pnfs_layout_type {*/ loff_t pnfs_write_begin_pos;loff_t pnfs_write_end_pos; +struct inode *lo_inode; };/*
@@ -206,7 +206,7 @@ struct nfs_inode {/* pNFS layout information */ #if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq; -struct pnfs_layout_type layout; +struct pnfs_layout_type *layout;time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/
Signature · 1 line
1.6.6
PATCH 4/16 SQUASHME pnfs-submit: filelayout: use new alloc/free_layout API
From: Andy Adamson <[email protected]>
--- fs/nfs/nfs4filelayout.c | 15 +++++++++------ fs/nfs/nfs4filelayout.h | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-)
fs/nfs/nfs4filelayout.c +9 -6
@@ -301,20 +301,23 @@ filelayout_write_pagelist(struct pnfs_layout_type *layoutid,* will use the pnfs_layout_type type to refer to the layout for this * inode from now on. */ -static void * +static struct pnfs_layout_type *filelayout_alloc_layout (struct inode *inode) { +struct nfs4_filelayout *flp; +dprintk ("NFS_FILELAYOUT: allocating layout\n" ); -return kzalloc (sizeof (struct nfs4_filelayout ),GFP_KERNEL ); + flp =kzalloc (sizeof (struct nfs4_filelayout ),GFP_KERNEL ); +return flp ? &flp->fl_layout :NULL ; }/* Free a filelayout layout structure */ static void -filelayout_free_layout (void *layoutid) +filelayout_free_layout (struct pnfs_layout_type *lo) {dprintk ("NFS_FILELAYOUT: freeing layout\n" ); -kfree (layoutid); +kfree (lo); }/*
@@ -471,7 +474,7 @@ static struct pnfs_layout_segment * filelayout_alloc_lseg(struct pnfs_layout_type *layoutid, struct nfs4_pnfs_layoutget_res *lgr) { - struct nfs4_filelayout *flo = PNFS_LD_DATA(layoutid); + struct nfs4_filelayout *flo = FILE_LO(layoutid);struct pnfs_layout_segment *lseg;int rc;
@@ -693,7 +696,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,ssize_t filelayout_get_stripesize (struct pnfs_layout_type *layoutid) { -struct nfs4_filelayout *flo =PNFS_LD_DATA (layoutid); +struct nfs4_filelayout *flo =FILE_LO (layoutid);return flo->stripe_unit; }
fs/nfs/nfs4filelayout.h +7 -0
@@ -68,6 +68,7 @@ struct nfs4_filelayout_segment { };struct nfs4_filelayout { +struct pnfs_layout_type fl_layout;int uncommitted_write;loff_t last_commit_size;u64 layout_id;
@@ -77,6 +78,12 @@ struct nfs4_filelayout {extern struct nfs_fh *nfs4_fl_select_ds_fh (struct pnfs_layout_segment *lseg,loff_t offset); +static inline struct nfs4_filelayout * +FILE_LO (struct pnfs_layout_type *lo) +{ + return container_of(lo, struct nfs4_filelayout, fl_layout); +} +extern struct pnfs_client_operations *pnfs_callback_ops;extern void nfs4_fl_free_deviceid_callback (struct kref *);
Signature · 1 line
1.6.6
PATCH 5/16 SQUASHME pnfs-submit: rewrite layout allocation
From: Andy Adamson <[email protected]>
Don't wait on a bit if layout is not allocated. Instead, allocate, check for existance, and possibly free.
As per new layout refcounting scheme,don't take a reference on the layout.
--- fs/nfs/pnfs.c | 84 +++++++++++++---------------------------------- include/linux/nfs_fs.h | 1 - 2 files changed, 23 insertions(+), 62 deletions(-)
fs/nfs/pnfs.c +23 -61
@@ -914,7 +914,6 @@ alloc_init_layout(struct inode *ino)struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; -BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; lo = io_ops->alloc_layout (ino);if (!lo) {
@@ -923,84 +922,47 @@ alloc_init_layout(struct inode *ino) __func__);return NULL ; } -spin_lock (&ino->i_lock); lo->refcount =1 ;INIT_LIST_HEAD (&lo->lo_layouts);INIT_LIST_HEAD (&lo->segs);seqlock_init (&lo->seqlock); lo->lo_inode = ino; -NFS_I (ino)->layout = lo; -spin_unlock (&ino->i_lock);return lo; } -static int pnfs_wait_schedule (void *word) -{ -if (signal_pending (current)) -return -ERESTARTSYS ; -schedule (); -return 0 ; -} -/* -* get, possibly allocate, and lock current_layout +* Lock and possibly allocate the inode layout * -* Note: If successful, ino->i_lock is taken and the caller -* must put and unlock current_layout when the returned layout is released. +* If successful, ino->i_lock is taken, and the caller must unlock. */ static struct pnfs_layout_type * -get_lock_alloc_layout (struct inode *ino) +nfs_lock_alloc_layout (struct inode *ino) { -struct nfs_inode *nfsi =NFS_I (ino); -struct pnfs_layout_type *lo; -int res; +struct pnfs_layout_type *new =NULL ;dprintk ("%s Begin\n" , __func__);spin_lock (&ino->i_lock); -while ((lo =grab_current_layout (nfsi)) ==NULL ) { +if (NFS_I (ino)->layout ==NULL ) {spin_unlock (&ino->i_lock); -/* Compete against other threads on who's doing the allocation, -* wait until bit is cleared if we lost this race. -*/ - res =wait_on_bit_lock ( - &nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC , - pnfs_wait_schedule,TASK_KILLABLE ); -if (res) { - lo =ERR_PTR (res); -break ; - } - -/* Was current_layout already allocated while we slept? -* If so, retry get_lock'ing it. Otherwise, allocate it. -*/ -if (nfsi->layout) { -spin_lock (&ino->i_lock); -continue ; + new =alloc_init_layout (ino); +if (new ==NULL ) +return NULL ; +spin_lock (&ino->i_lock); +if (NFS_I (ino)->layout ==NULL ) { +NFS_I (ino)->layout = new; + new =NULL ; } - - lo =alloc_init_layout (ino); -if (lo) -spin_lock (&ino->i_lock); -else - lo =ERR_PTR (-ENOMEM ); - -/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ -clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout->pnfs_layout_state); -wake_up_bit (&nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC ); -break ; } - -#ifdef NFS_DEBUG -if (!IS_ERR (lo)) -dprintk ("%s Return %p\n" , __func__, lo); -else -dprintk ("%s Return error %ld\n" , __func__,PTR_ERR (lo)); -#endif -return lo; +if (new) { +/* Reference the layout accross i_lock release and grab */ +get_layout (NFS_I (ino)->layout); +spin_unlock (&ino->i_lock); +NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops->free_layout (new); +spin_lock (&ino->i_lock); +put_layout (NFS_I (ino)->layout); + } +return NFS_I (ino)->layout; }/*
@@ -1088,8 +1050,8 @@ _pnfs_update_layout(struct inode *ino,if (take_ref) *lsegpp =NULL ; - lo =get_lock_alloc_layout (ino); -if (IS_ERR (lo)) { + lo =nfs_lock_alloc_layout (ino); +if (lo ==NULL ) {dprintk ("%s ERROR: can't get pnfs_layout_type\n" , __func__); goto out; }
include/linux/nfs_fs.h +0 -1
@@ -107,7 +107,6 @@ struct pnfs_layout_type {unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ -#define NFS_INO_LAYOUT_ALLOC 2/* bit lock for layout allocation */ #define NFS_INO_LAYOUTCOMMIT 3/* LAYOUTCOMMIT needed */ struct rpc_cred *lo_cred;/* layoutcommit credential */ /* DH: These vars keep track of the maximum write range
Signature · 1 line
1.6.6
PATCH 6/16 SQUASHME pnfs-submit; fix pnfs_update_layout reference counting
From: Andy Adamson <[email protected]>
Only take a reference on the layout if layoutget is to be called.
--- fs/nfs/pnfs.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
fs/nfs/pnfs.c +7 -6
@@ -362,6 +362,7 @@ pnfs_layout_release(struct pnfs_layout_type *lo,spin_lock (&nfsi->vfs_inode.i_lock);if (range)pnfs_free_layout (lo, range); +/* Matched in _pnfs_update_layout for layoutget */ put_layout (lo);spin_unlock (&nfsi->vfs_inode.i_lock);wake_up_all (&nfsi->lo_waitq);
@@ -1063,7 +1064,7 @@ _pnfs_update_layout(struct inode *ino,put_lseg_locked (lseg);/* someone is cleaning the layout */ lseg =NULL ; - goto out_put; + goto out_unlock; }if (lseg) {
@@ -1074,7 +1075,7 @@ _pnfs_update_layout(struct inode *ino, arg.offset, arg.iomode); - goto out_put; + goto out_unlock; }/* if get layout already failed once goto out */
@@ -1086,10 +1087,11 @@ _pnfs_update_layout(struct inode *ino, &nfsi->layout->pnfs_layout_state); nfsi->pnfs_layout_suspend =0 ; }else - goto out_put; + goto out_unlock; } -/* Lose lock, but not reference, match this with pnfs_layout_release */ +/* Reference the layout for layoutget matched in pnfs_layout_release */ +get_layout (lo);spin_unlock (&ino->i_lock);send_layoutget (ino, ctx, &arg, lsegpp, lo);
@@ -1097,10 +1099,9 @@ out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, nfsi->layout->pnfs_layout_state, lseg);return ; -out_put: +out_unlock:if (lsegpp) *lsegpp = lseg; -put_layout (lo);spin_unlock (&ino->i_lock); goto out; }
Signature · 1 line
1.6.6
PATCH 7/16 SQUASHME pnfs_submit: don't get a reference on boundary calculation
From: Andy Adamson <[email protected]>
The i_lock needs to be held because in the write path, we don't know if any of the pages served by the pgio have a layout segment.
FIXME: Review when we calculate the boundary in the write path, perhaps delaying until we know if pNFS I/O is to occur (at least one page is referencing a layout segment).
--- fs/nfs/pnfs.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
fs/nfs/pnfs.c +2 -8
@@ -1302,8 +1302,6 @@ pnfs_getboundary(struct inode *inode)u32 stripe_size =0 ;struct nfs_server *nfss =NFS_SERVER (inode);struct layoutdriver_policy_operations *policy_ops; -struct nfs_inode *nfsi; -struct pnfs_layout_type *lo;if (!nfss->pnfs_curr_ld) goto out;
@@ -1316,13 +1314,9 @@ pnfs_getboundary(struct inode *inode)if (pnfs_ld_gather_across_stripes (nfss->pnfs_curr_ld)) goto out; - nfsi =NFS_I (inode);spin_lock (&inode->i_lock); - lo =grab_current_layout (nfsi);; -if (lo) { - stripe_size = policy_ops->get_stripesize (lo); -put_layout (lo); - } +if (NFS_I (inode)->layout) + stripe_size = policy_ops->get_stripesize (NFS_I (inode)->layout);spin_unlock (&inode->i_lock); out:return stripe_size;
Signature · 1 line
1.6.6
PATCH 8/16 SQUASHME pnfs-submit: don't reference the layout in init_lseg
From: Andy Adamson <[email protected]>
The layout is referenced when the layout segment is inserted into the cache.
--- fs/nfs/pnfs.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +0 -1
@@ -402,7 +402,6 @@ init_lseg(struct pnfs_layout_type *lo, struct pnfs_layout_segment *lseg)kref_init (&lseg->kref); lseg->valid = true; lseg->layout = lo; -get_layout (lo); } static void
Signature · 1 line
1.6.6
PATCH 9/16 SQUASHME pnfs-submit: pnfs_update_layout always references the lseg
From: Andy Adamson <[email protected]>
So remove test_ref
--- fs/nfs/pnfs.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-)
fs/nfs/pnfs.c +10 -20
@@ -997,9 +997,7 @@ has_matching_lseg(struct pnfs_layout_segment *lseg,*/ static struct pnfs_layout_segment *pnfs_has_layout (struct pnfs_layout_type *lo, -struct nfs4_pnfs_layout_segment *range, -bool take_ref, -bool only_valid) +struct nfs4_pnfs_layout_segment *range) {struct pnfs_layout_segment *lseg, *ret =NULL ;
@@ -1007,28 +1005,24 @@ pnfs_has_layout(struct pnfs_layout_type *lo,BUG_ON_UNLOCKED_LO (lo); list_for_each_entry (lseg, &lo->segs, fi_list) { -if (has_matching_lseg (lseg, range) && - (lseg->valid || !only_valid)) { +if (has_matching_lseg (lseg, range)) { ret = lseg; -if (take_ref) -get_lseg (ret); +get_lseg (ret);break ; }if (cmp_layout (range, &lseg->range) >0 )break ; } -dprintk ("%s:Return lseg %p take_ref %d ref %d valid %d\n" , - __func__, ret, take_ref, - ret ?atomic_read (&ret->kref.refcount) :0 , +dprintk ("%s:Return lseg %p ref %d valid %d\n" , + __func__, ret, ret ?atomic_read (&ret->kref.refcount) :0 , ret ? ret->valid :0 );return ret; }/* Update the file's layout for the given range and iomode. * Layout is retreived from the server if needed. -* If lsegpp is given, the appropriate layout segment is referenced and -* returned to the caller. +* The appropriate layout segment is referenced and returned to the caller. */ void _pnfs_update_layout(struct inode *ino,
@@ -1046,10 +1040,8 @@ _pnfs_update_layout(struct inode *ino,struct nfs_inode *nfsi =NFS_I (ino);struct pnfs_layout_type *lo;struct pnfs_layout_segment *lseg =NULL ; -bool take_ref = (lsegpp !=NULL ); -if (take_ref) - *lsegpp =NULL ; + *lsegpp =NULL ; lo =nfs_lock_alloc_layout (ino);if (lo ==NULL ) {dprintk ("%s ERROR: can't get pnfs_layout_type\n" , __func__);
@@ -1057,10 +1049,9 @@ _pnfs_update_layout(struct inode *ino, }/* Check to see if the layout for the given range already exists */ - lseg =pnfs_has_layout (lo, &arg, take_ref, !take_ref); + lseg =pnfs_has_layout (lo, &arg);if (lseg && !lseg->valid) { -if (take_ref) -put_lseg_locked (lseg); +put_lseg_locked (lseg);/* someone is cleaning the layout */ lseg =NULL ; goto out_unlock;
@@ -1099,8 +1090,7 @@ out: nfsi->layout->pnfs_layout_state, lseg);return ; out_unlock: -if (lsegpp) - *lsegpp = lseg; + *lsegpp = lseg;spin_unlock (&ino->i_lock); goto out; }
Signature · 1 line
1.6.6
PATCH 10/16 SQUASHME pnfs-submit: reference the layout when inserted into segs list
From: Andy Adamson <[email protected]>
We take a reference on the pnfs_layout_type structure at allocation, so we don't need to take another reference when adding it to the nfs_client cl_layouts list.
We do need to take a referece when an lseg is inserted into the layout->segs list to keep the pnfs_layout_type around while the layout segment is in the list.
--- fs/nfs/pnfs.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +2 -1
@@ -411,6 +411,7 @@ destroy_lseg(struct kref *kref) container_of(kref, struct pnfs_layout_segment, kref);dprintk ("--> %s\n" , __func__); +/* Matched by get_layout in pnfs_insert_layout */ put_layout (lseg->layout);PNFS_LD_IO_OPS (lseg->layout)->free_lseg (lseg); }
@@ -876,7 +877,6 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,BUG_ON (!list_empty (&lo->lo_layouts));list_add_tail (&lo->lo_layouts, &clp->cl_layouts);spin_unlock (&clp->cl_lock); -get_layout (lo); } list_for_each_entry (lp, &lo->segs, fi_list) {if (cmp_layout (&lp->range, &lseg->range) >0 )
@@ -899,6 +899,7 @@ pnfs_insert_layout(struct pnfs_layout_type *lo, __func__, lseg, lseg->range.iomode, lseg->range.offset, lseg->range.length); } +get_layout (lo);dprintk ("%s:Return\n" , __func__); }
Signature · 1 line
1.6.6
PATCH 11/16 SQUASHME pnfs-submit: rename put_layout to put_layout_locked
From: Andy Adamson <[email protected]>
In preparation for non-locked put_layout, follow naming convention.
--- fs/nfs/pnfs.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
fs/nfs/pnfs.c +6 -6
@@ -336,7 +336,7 @@ grab_current_layout(struct nfs_inode *nfsi) }static inline void -put_layout (struct pnfs_layout_type *lo) +put_layout_locked (struct pnfs_layout_type *lo) {BUG_ON_UNLOCKED_LO (lo);BUG_ON (lo->refcount <=0 );
@@ -363,7 +363,7 @@ pnfs_layout_release(struct pnfs_layout_type *lo,if (range)pnfs_free_layout (lo, range);/* Matched in _pnfs_update_layout for layoutget */ -put_layout (lo); +put_layout_locked (lo);spin_unlock (&nfsi->vfs_inode.i_lock);wake_up_all (&nfsi->lo_waitq); }
@@ -390,7 +390,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) __func__, nfsi->layout->refcount);WARN_ON (nfsi->layout->refcount !=1 ); -put_layout (lo); +put_layout_locked (lo); }spin_unlock (&nfsi->vfs_inode.i_lock); }
@@ -412,7 +412,7 @@ destroy_lseg(struct kref *kref)dprintk ("--> %s\n" , __func__);/* Matched by get_layout in pnfs_insert_layout */ -put_layout (lseg->layout); +put_layout_locked (lseg->layout);PNFS_LD_IO_OPS (lseg->layout)->free_lseg (lseg); }
@@ -684,7 +684,7 @@ pnfs_free_layout(struct pnfs_layout_type *lo,spin_lock (&clp->cl_lock);list_del_init (&lo->lo_layouts);spin_unlock (&clp->cl_lock); -put_layout (lo); +put_layout_locked (lo); }dprintk ("%s:Return\n" , __func__);
@@ -961,7 +961,7 @@ nfs_lock_alloc_layout(struct inode *ino)spin_unlock (&ino->i_lock);NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops->free_layout (new);spin_lock (&ino->i_lock); -put_layout (NFS_I (ino)->layout); +put_layout_locked (NFS_I (ino)->layout); }return NFS_I (ino)->layout; }
Signature · 1 line
1.6.6
PATCH 12/16 SQUASHME pnfs-submit: reference layout across layoutcommit
From: Andy Adamson <[email protected]>
--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)
fs/nfs/nfs4proc.c +2 -0
@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }
fs/nfs/pnfs.c +13 -0
@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {
@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock);/* Set up layout commit args */
@@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode); goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);
fs/nfs/pnfs.h +1 -0
@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \
Signature · 1 line
1.6.6
PATCH 13/16 SQUASHME pnfs-submit: reference layout for layoutreturn
From: Andy Adamson <[email protected]>
--- fs/nfs/pnfs.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
fs/nfs/pnfs.c +13 -11
@@ -371,7 +371,10 @@ pnfs_layout_release(struct pnfs_layout_type *lo,spin_lock (&nfsi->vfs_inode.i_lock);if (range)pnfs_free_layout (lo, range); -/* Matched in _pnfs_update_layout for layoutget */ +/* +* Matched in _pnfs_update_layout for layoutget +* and by get_layout in _pnfs_return_layout for layoutreturn +*/ put_layout_locked (lo);spin_unlock (&nfsi->vfs_inode.i_lock);wake_up_all (&nfsi->lo_waitq);
@@ -776,9 +779,8 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,if (type ==RETURN_FILE ) {spin_lock (&ino->i_lock); - lo =grab_current_layout (nfsi); + lo = nfsi->layout;if (lo && !has_layout_to_return (lo, &arg)) { -put_layout (lo); lo =NULL ; }if (!lo) {
@@ -787,18 +789,15 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, goto out; } -/* unlock w/o put rebalanced by eventual call to -* pnfs_layout_release -*/ +/* Reference for layoutreturn matched in pnfs_layout_release */ +get_layout (lo); +spin_unlock (&ino->i_lock);if (pnfs_return_layout_barrier (nfsi, &arg)) {if (stateid) {/* callback */ status = -EAGAIN ; -spin_lock (&ino->i_lock); -put_layout (lo); -spin_unlock (&ino->i_lock); - goto out; + goto out_put; }dprintk ("%s: waiting\n" , __func__); wait_event(nfsi->lo_waitq,
@@ -809,7 +808,7 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range,if (stateid && !wait) {/* callback */ dprintk ("%s: layoutcommit pending\n" , __func__); status = -EAGAIN ; - goto out; + goto out_put; } status =pnfs_layoutcommit_inode (ino, wait);if (status) {
@@ -828,6 +827,9 @@ _pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range, out:dprintk ("<-- %s status: %d\n" , __func__, status);return status; +out_put: +put_layout (ino); + goto out; }void
Signature · 1 line
1.6.6
PATCH 14/16 SQUASHME pnfs-submit: remove put_layout from pnfs_free_layout
From: Andy Adamson <[email protected]>
--- fs/nfs/pnfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +1 -1
@@ -402,6 +402,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) __func__, nfsi->layout->refcount);WARN_ON (nfsi->layout->refcount !=1 ); +/* Matched by refcount set to 1 in alloc_init_layout */ put_layout_locked (lo); }spin_unlock (&nfsi->vfs_inode.i_lock);
@@ -696,7 +697,6 @@ pnfs_free_layout(struct pnfs_layout_type *lo,spin_lock (&clp->cl_lock);list_del_init (&lo->lo_layouts);spin_unlock (&clp->cl_lock); -put_layout_locked (lo); }dprintk ("%s:Return\n" , __func__);
Signature · 1 line
1.6.6
PATCH 15/16 SQUASHME pnfs-submit: do not reference a layout in destroy_layout.
From: Andy Adamson <[email protected]>
--- fs/nfs/pnfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/pnfs.c +1 -1
@@ -391,7 +391,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) };spin_lock (&nfsi->vfs_inode.i_lock); - lo =grab_current_layout (nfsi); + lo = nfsi->layout;if (lo) {pnfs_free_layout (lo, &range);WARN_ON (!list_empty (&nfsi->layout->segs));
Signature · 1 line
1.6.6
PATCH 16/16 SQUASHME pnfs-submit: remove grab_current_layout
From: Andy Adamson <[email protected]>
--- fs/nfs/pnfs.c | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
fs/nfs/pnfs.c +0 -11
@@ -324,17 +324,6 @@ get_layout(struct pnfs_layout_type *lo) lo->refcount++; } -static inline struct pnfs_layout_type * -grab_current_layout (struct nfs_inode *nfsi) -{ -struct pnfs_layout_type *lo = nfsi->layout; - -if (!lo) -return NULL ; -get_layout (lo); -return lo; -} -static inline void put_layout_locked (struct pnfs_layout_type *lo) {
Signature · 1 line
1.6.6
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
In reply to [email protected]Quoted 43 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +
Has of your rules this should be now called get_layout_locked
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1621
Quoted 8 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode);
And it is really nice that put_layout takes an inode and get_layout takes an struct layout_type.
Quoted 8 lines
fs/nfs/pnfs.c +0
-0goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0
fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \
I still think they can all go away.
What is the point of a layout without it's nfsi+inode. And who cares if we free the layout_type structure 2 milliseconds before, and in the error case?
Boaz
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 47 lines · Boaz Harrosh
Quoted 46 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);
Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 3 lines
fs/nfs/pnfs.c +3
-0+/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +Has of your rules this should be now called
get_layout_locked
OK
Quoted 39 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1621
Quoted 9 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode);And it is really nice that
put_layouttakes an inode andget_layouttakes an structlayout_type.Quoted 8 lines
fs/nfs/pnfs.c +0
-0goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \I still think they can all go away.
What is the point of a layout without it's nfsi+inode. And who cares if we free thelayout_typestructure 2 milliseconds before, and in the error case?Boaz
--
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
A message that is not in the archive (sent off-list or not yet received): AANLkTilWfV86wpO7vFho3FmL9y9Y6Sx9_-knKq7T-snu-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 48 lines · William A. (Andy) Adamson
Quoted 47 lines · Boaz Harrosh
Quoted 46 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);
Quoted 7 lines
Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 3 lines
fs/nfs/pnfs.c +3
-0+/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +Has of your rules this should be now called
get_layout_lockedOK
Andy, before you crank another version, I've already merged this patchset with obvious fixes into my tree so it might be better to fix that up.
I also fixed a couple other less trivial bugs for which I'm going to send patches soon, and I fixed up the obj and block layout alloc/free methods to agree with the new API.
Benny
Quoted 41 lines
Quoted 41 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1621
Quoted 11 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode);And it is really nice that
put_layouttakes an inode andget_layouttakes an structlayout_type.Quoted 8 lines
fs/nfs/pnfs.c +0
-0goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \I still think they can all go away.
What is the point of a layout without it's nfsi+inode. And who cares if we free thelayout_typestructure 2 milliseconds before, and in the error case?Boaz
--
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 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 55 lines · Benny Halevy
Quoted 54 lines · William A. (Andy) Adamson
Quoted 52 lines · Boaz Harrosh
Quoted 43 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +Has of your rules this should be now called
get_layout_locked
Quoted 8 lines
Quoted 1 line
OK
Andy, before you crank another version, I've already merged this patchset with obvious fixes into my tree so it might be better to fix that up.
I also fixed a couple other less trivial bugs for which I'm going to send patches soon, and I fixed up the obj and block layout alloc/free methods to agree with the new API.
OK, Thanks. :)
I'll grab it and we can move forward together from there.
-->Andy
Quoted 45 lines
Benny
Quoted 41 lines
Quoted 41 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1621
Quoted 11 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode);And it is really nice that
put_layouttakes an inode andget_layouttakes an structlayout_type.Quoted 8 lines
fs/nfs/pnfs.c +0
-0goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \I still think they can all go away.
What is the point of a layout without it's nfsi+inode. And who cares if we free thelayout_typestructure 2 milliseconds before, and in the error case?Boaz
--
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
A message that is not in the archive (sent off-list or not yet received): AANLkTilrcKirEQLe5mhtYNAnaJBSn6q4edC3TlXJd1rm-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 61 lines · William A. (Andy) Adamson
Quoted 60 lines · Benny Halevy
Quoted 48 lines · William A. (Andy) Adamson
Quoted 47 lines · Boaz Harrosh
Quoted 46 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);Quoted 7 lines
Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 3 lines
fs/nfs/pnfs.c +3
-0+/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +Has of your rules this should be now called
get_layout_lockedOK
Andy, before you crank another version, I've already merged this patchset with obvious fixes into my tree so it might be better to fix that up.
Quoted 7 lines
Quoted 3 lines
I also fixed a couple other less trivial bugs for which I'm going to send patches soon, and I fixed up the obj and block layout alloc/free methods to agree with the new API.
OK, Thanks. :)
I'll grab it and we can move forward together from there.
Super. It's out.
Time for me to call it a day (11 pm here) :-/
Enjoy :)
Benny
Quoted 51 lines
-->Andy
Quoted 45 lines
Benny
Quoted 41 lines
Quoted 41 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1621
Quoted 11 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode);And it is really nice that
put_layouttakes an inode andget_layouttakes an structlayout_type.Quoted 8 lines
fs/nfs/pnfs.c +0
-0goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \I still think they can all go away.
What is the point of a layout without it's nfsi+inode. And who cares if we free thelayout_typestructure 2 milliseconds before, and in the error case?Boaz
--
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--
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 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
In reply to [email protected]Quoted 43 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +
So from the 30000 foot level, I need to remind myself what do we need the refcount on the layout hdr (pnfs_layout_type) for?
Can we really use it detached from the inode? NO
Is it only for debugging to make catch the case that the inode is released while there are references to the layout?
Benny
Quoted 23 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode); goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 54 lines · Benny Halevy
Quoted 43 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +So from the 30000 foot level, I need to remind myself what do we need the refcount on the layout hdr (
pnfs_layout_type) for?
Quoted 3 lines
Can we really use it detached from the inode? NO
Is it only for debugging to make catch the case that the inode is released while there are references to the layout?
When we migrate the filesystem, we need to reap the nfs_inode->layout while keeping the nfs_inode.
Same with server reboot, network partition, and use of a different replica.
-->Andy
Quoted 32 lines
Benny
Quoted 16 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode); goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \--
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
A message that is not in the archive (sent off-list or not yet received): AANLkTil1wUQUTht0QP7_Ttaagw0-LXef2J8wU6wSFUWG-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
Quoted 55 lines · William A. (Andy) Adamson
Quoted 53 lines · Benny Halevy
Quoted 43 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4proc.c | 2 ++ fs/nfs/pnfs.c | 13 +++++++++++++ fs/nfs/pnfs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +2
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *lcdata)struct pnfs_layoutcommit_data *data = (struct pnfs_layoutcommit_data *)lcdata; +/* Matched by get_layout in pnfs_layoutcommit_inode */ +put_layout (data->args.inode);put_rpccred (data->cred);pnfs_layoutcommit_free (lcdata); }fs/nfs/pnfs.c +9
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo) }void +put_layout (struct inode *inode) +{ +spin_lock (&inode->i_lock); +put_layout_locked (NFS_I (inode)->layout); +spin_unlock (&inode->i_lock); + +} + +void pnfs_layout_release (struct pnfs_layout_type *lo,struct nfs4_pnfs_layout_segment *range) {fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, int sync) · line 1612
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout); +/* Reference for layoutcommit matched in pnfs_layoutcommit_release */ +get_layout (NFS_I (inode)->layout); +So from the 30000 foot level, I need to remind myself what do we need the refcount on the layout hdr (
pnfs_layout_type) for?
Quoted 7 lines
Quoted 3 lines
Can we really use it detached from the inode? NO
Is it only for debugging to make catch the case that the inode is released while there are references to the layout?When we migrate the filesystem, we need to reap the
nfs_inode->layoutwhile keeping thenfs_inode.
But how does the refcount help us with that?
Don't we have to do this synchronously before reusing the nfs_inode?
Benny
Quoted 36 lines
Same with server reboot, network partition, and use of a different replica.
-->Andy
Quoted 32 lines
Benny
Quoted 16 lines
fs/nfs/pnfs.c +1
-0spin_unlock (&inode->i_lock);/* Set up layout commit args */ @@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)if (status) {/* The layout driver failed to setup the layoutcommit */ put_rpccred (data->cred); +put_layout (inode); goto out_free; } status =pnfs4_proc_layoutcommit (data, sync);fs/nfs/pnfs.h +0
-0fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segm · line 70
Quoted 7 lines
fs/nfs/pnfs.h +1
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type *, struct nfs4_pnfs_layout_segmvoid pnfs_set_layout_stateid (struct pnfs_layout_type *lo,const nfs4_stateid *stateid);void pnfs_destroy_layout (struct nfs_inode *); +void put_layout (struct inode *inode);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \--
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 12/16] SQUASHME pnfs-submit: reference layout across layoutcommit
On Mon, Jul 12, 2010 at 2:29 PM, Benny Halevy <[email protected]> wro= te:
Quoted 1 line
On Jul. 12, 2010, 21:27 +0300, "William A. (Andy) Adamson" <androsada=
Quoted 1 line · [email protected]> wrote:
Quoted 1 line
On Mon, Jul 12, 2010 at 1:19 PM, Benny Halevy <[email protected]> =
Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
Quoted 9 lines
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>---
=A0fs/nfs/nfs4proc.c | =A0 =A02 ++ =A0fs/nfs/pnfs.c =A0 =A0 | =A0 13 +++++++++++++ =A0fs/nfs/pnfs.h =A0 =A0 | =A0 =A01 +
=A03 files changed, 16 insertions(+), 0 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/nfs/nfs4proc.c static void pnfs_layoutcommit_release(void *=
Quoted 5 lines
fs/nfs/nfs4proc.c +0
-0@@ -5565,6 +5565,8 @@ static void pnfs_layoutcommit_release(void *=
lcdata)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
=A0 =A0 =A0 struct
pnfs_layoutcommit_data*data =3D
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (structpnfs_layoutcommit_data*)lcdat=
a;
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
fs/nfs/pnfs.c put_layout_locked(struct pnfs_layout_type *lo=
Quoted 11 lines
+ =A0 =A0 /* Matched by
get_layoutinpnfs_layoutcommit_inode*/
+ =A0 =A0put_layout(data->args.inode);
=A0 =A0 =A0put_rpccred(data->cred);
=A0 =A0 =A0pnfs_layoutcommit_free(lcdata);
=A0}fs/nfs/pnfs.c +0
-0@@ -354,6 +354,15 @@ put_layout_locked(struct pnfs_layout_type *lo=
)
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 12 lines
fs/nfs/pnfs.c +0
-0=A0}=A0void
fs/nfs/pnfs.c +9
-0+put_layout(struct inode *inode) +{ + =A0 =A0 spin_lock(&inode->i_lock); + =A0 =A0 put_layout_locked(NFS_I(inode)->layout); + =A0 =A0 spin_unlock(&inode->i_lock); + +} + +void Quoted 2 lines
=A0pnfs_layout_release(struct
pnfs_layout_type*lo,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct nfs4_pnfs_layout_segmen=
t *range)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode,=
Quoted 2 lines
=A0{
fs/nfs/pnfs.c +0
-0@@ -1598,6 +1607,9 @@ pnfs_layoutcommit_inode(struct inode *inode,=
int sync)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 __clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->layout->pnfs_=
layout_state);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 pnfs_get_layout_stateid(&data->args.stateid, nfsi->lay=
out);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ =A0 =A0 /* Reference for layoutcommit matched in pnfs_layoutcomm=
it_release */
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
+ =A0 =A0 get_layout(NFS_I(inode)->layout);
+So from the 30000 foot level, I need to remind myself what do we need the refcount on the layout hdr (
pnfs_layout_type) for?Can we really use it detached from the inode? NO
Is it only for debugging to make catch the case that the inode is released while there are references to the layout?When we migrate the filesystem, we need to reap the nfs_inode->layou=
t
Quoted 5 lines
Quoted 2 lines
while keeping the
nfs_inode.But how does the refcount help us with that?
Don't we have to do this synchronously before reusing thenfs_inode?
We need to drain all slots which could have async LAYOUTCOMMITs or async LAYOUTRETURNs still on the wire. The refcount keeps the nfs_inode->layout allocated for the LAYOUTCOMMIT return.
-->Andy
Quoted 4 lines
Benny
Quoted 1 line
Same with server reboot, network partition, and use of a different r=
eplica.
Quoted 10 lines
Quoted 10 lines
-->Andy
Quoted 7 lines
Benny
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode,=
Quoted 4 lines
=A0 =A0 =A0
spin_unlock(&inode->i_lock);=A0 =A0 =A0 /* Set up layout commit args */
fs/nfs/pnfs.c +0
-0@@ -1606,6 +1618,7 @@ pnfs_layoutcommit_inode(struct inode *inode,=
int sync)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
fs/nfs/pnfs.c +0
-0=A0 =A0 =A0 if (status) {=A0 =A0 =A0 =A0 =A0 =A0 =A0 /* The layout driver failed to setup t=
he layoutcommit */
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
fs/nfs/pnfs.h void pnfs_layout_release(struct pnfs_layout_type=
Quoted 10 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0
put_rpccred(data->cred);
+ =A0 =A0 =A0 =A0 =A0 =A0put_layout(inode);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 gotoout_free;
=A0 =A0 =A0 }
=A0 =A0 =A0 status =3Dpnfs4_proc_layoutcommit(data, sync);fs/nfs/pnfs.h +0
-0@@ -64,6 +64,7 @@ void pnfs_layout_release(struct pnfs_layout_type=
*, struct nfs4_pnfs_layout_segm
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
fs/nfs/pnfs.h +0
-0=A0void pnfs_set_layout_stateid(struct pnfs_layout_type *lo,=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const nfs4_=
stateid *stateid);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
=A0void
pnfs_destroy_layout(struct nfs_inode *);
+voidput_layout(struct inode *inode);=A0#define
PNFS_EXISTS_LDIO_OP(srv, opname)((srv)->pnfs_curr_ld &=
& =A0 =A0 \
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0(srv)->pnfs_curr_ld->ld_io_ops && =A0\
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs=
" in
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.htm=
l
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Re: [PATCH 09/16] SQUASHME pnfs-submit: pnfs_update_layout always references the lseg
In reply to [email protected]Quoted 5 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
So remove
test_refSigned-off-by Andy Adamson <[email protected]>
OK, but this has to be reintroduced in post submit for better synchronization with parallel layout gets and returns.
Benny
Quoted 88 lines
--- fs/nfs/pnfs.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-)fs/nfs/pnfs.c +10
-20@@ -997,9 +997,7 @@ has_matching_lseg(struct pnfs_layout_segment *lseg,*/ static struct pnfs_layout_segment *pnfs_has_layout (struct pnfs_layout_type *lo, -struct nfs4_pnfs_layout_segment *range, -bool take_ref, -bool only_valid) +struct nfs4_pnfs_layout_segment *range) {struct pnfs_layout_segment *lseg, *ret =NULL ;@@ -1007,28 +1005,24 @@ pnfs_has_layout(struct pnfs_layout_type *lo,BUG_ON_UNLOCKED_LO (lo); list_for_each_entry (lseg, &lo->segs, fi_list) { -if (has_matching_lseg (lseg, range) && - (lseg->valid || !only_valid)) { +if (has_matching_lseg (lseg, range)) { ret = lseg; -if (take_ref) -get_lseg (ret); +get_lseg (ret);break ; }if (cmp_layout (range, &lseg->range) >0 )break ; } -dprintk ("%s:Return lseg %p take_ref %d ref %d valid %d\n" , - __func__, ret, take_ref, - ret ?atomic_read (&ret->kref.refcount) :0 , +dprintk ("%s:Return lseg %p ref %d valid %d\n" , + __func__, ret, ret ?atomic_read (&ret->kref.refcount) :0 , ret ? ret->valid :0 );return ret; }/* Update the file's layout for the given range and iomode. * Layout is retreived from the server if needed. -* If lsegpp is given, the appropriate layout segment is referenced and -* returned to the caller. +* The appropriate layout segment is referenced and returned to the caller. */ void _pnfs_update_layout(struct inode *ino,@@ -1046,10 +1040,8 @@ _pnfs_update_layout(struct inode *ino,struct nfs_inode *nfsi =NFS_I (ino);struct pnfs_layout_type *lo;struct pnfs_layout_segment *lseg =NULL ; -bool take_ref = (lsegpp !=NULL ); -if (take_ref) - *lsegpp =NULL ; + *lsegpp =NULL ; lo =nfs_lock_alloc_layout (ino);if (lo ==NULL ) {dprintk ("%s ERROR: can't get pnfs_layout_type\n" , __func__);@@ -1057,10 +1049,9 @@ _pnfs_update_layout(struct inode *ino, }/* Check to see if the layout for the given range already exists */ - lseg =pnfs_has_layout (lo, &arg, take_ref, !take_ref); + lseg =pnfs_has_layout (lo, &arg);if (lseg && !lseg->valid) { -if (take_ref) -put_lseg_locked (lseg); +put_lseg_locked (lseg);/* someone is cleaning the layout */ lseg =NULL ; goto out_unlock;@@ -1099,8 +1090,7 @@ out: nfsi->layout->pnfs_layout_state, lseg);return ; out_unlock: -if (lsegpp) - *lsegpp = lseg; + *lsegpp = lseg;spin_unlock (&ino->i_lock); goto out; }
Re: [PATCH 05/16] SQUASHME pnfs-submit: rewrite layout allocation
In reply to [email protected]Quoted 61 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
Don't wait on a bit if layout is not allocated. Instead, allocate, check for existance, and possibly free.
As per new layout refcounting scheme,don't take a reference on the layout.
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/pnfs.c | 84 +++++++++++++---------------------------------- include/linux/nfs_fs.h | 1 - 2 files changed, 23 insertions(+), 62 deletions(-)fs/nfs/pnfs.c +3
-17@@ -914,7 +914,6 @@ alloc_init_layout(struct inode *ino)struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; -BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; lo = io_ops->alloc_layout (ino);if (!lo) {@@ -923,84 +922,47 @@ alloc_init_layout(struct inode *ino) __func__);return NULL ; } -spin_lock (&ino->i_lock); lo->refcount =1 ;INIT_LIST_HEAD (&lo->lo_layouts);INIT_LIST_HEAD (&lo->segs);seqlock_init (&lo->seqlock); lo->lo_inode = ino; -NFS_I (ino)->layout = lo; -spin_unlock (&ino->i_lock);return lo; } -static int pnfs_wait_schedule (void *word) -{ -if (signal_pending (current)) -return -ERESTARTSYS ; -schedule (); -return 0 ; -} -/* -* get, possibly allocate, and lock current_layout +* Lock and possibly allocate the inode layout * -* Note: If successful, ino->i_lock is taken and the caller -* must put and unlock current_layout when the returned layout is released. +* If successful, ino->i_lock is taken, and the caller must unlock. */ static struct pnfs_layout_type * -get_lock_alloc_layout (struct inode *ino) +nfs_lock_alloc_layout (struct inode *ino) { -struct nfs_inode *nfsi =NFS_I (ino);
fs/nfs/pnfs.c alloc_init_layout(struct inode *ino) · line 947
Quoted 10 lines
fs/nfs/pnfs.c +2
-3-struct pnfs_layout_type *lo; -int res; +struct pnfs_layout_type *new =NULL ;dprintk ("%s Begin\n" , __func__);spin_lock (&ino->i_lock); -while ((lo =grab_current_layout (nfsi)) ==NULL ) { +if (NFS_I (ino)->layout ==NULL ) {spin_unlock (&ino->i_lock);
There's no real need to take the lock here just for checking for NULL, only down below before actually committing the newly allocated struct. [I'll make this fix)
Benny
Quoted 83 lines
fs/nfs/pnfs.c +18
-41-/* Compete against other threads on who's doing the allocation, -* wait until bit is cleared if we lost this race. -*/ - res =wait_on_bit_lock ( - &nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC , - pnfs_wait_schedule,TASK_KILLABLE ); -if (res) { - lo =ERR_PTR (res); -break ; - } - -/* Was current_layout already allocated while we slept? -* If so, retry get_lock'ing it. Otherwise, allocate it. -*/ -if (nfsi->layout) { -spin_lock (&ino->i_lock); -continue ; + new =alloc_init_layout (ino); +if (new ==NULL ) +return NULL ; +spin_lock (&ino->i_lock); +if (NFS_I (ino)->layout ==NULL ) { +NFS_I (ino)->layout = new; + new =NULL ; } - - lo =alloc_init_layout (ino); -if (lo) -spin_lock (&ino->i_lock); -else - lo =ERR_PTR (-ENOMEM ); - -/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ -clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout->pnfs_layout_state); -wake_up_bit (&nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC ); -break ; } - -#ifdef NFS_DEBUG -if (!IS_ERR (lo)) -dprintk ("%s Return %p\n" , __func__, lo); -else -dprintk ("%s Return error %ld\n" , __func__,PTR_ERR (lo)); -#endif -return lo; +if (new) { +/* Reference the layout accross i_lock release and grab */ +get_layout (NFS_I (ino)->layout); +spin_unlock (&ino->i_lock); +NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops->free_layout (new); +spin_lock (&ino->i_lock); +put_layout (NFS_I (ino)->layout); + } +return NFS_I (ino)->layout; }/* @@ -1088,8 +1050,8 @@ _pnfs_update_layout(struct inode *ino,if (take_ref) *lsegpp =NULL ; - lo =get_lock_alloc_layout (ino); -if (IS_ERR (lo)) { + lo =nfs_lock_alloc_layout (ino); +if (lo ==NULL ) {dprintk ("%s ERROR: can't get pnfs_layout_type\n" , __func__); goto out; }include/linux/nfs_fs.h +0
-1@@ -107,7 +107,6 @@ struct pnfs_layout_type {unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ -#define NFS_INO_LAYOUT_ALLOC 2/* bit lock for layout allocation */ #define NFS_INO_LAYOUTCOMMIT 3/* LAYOUTCOMMIT needed */ struct rpc_cred *lo_cred;/* layoutcommit credential */ /* DH: These vars keep track of the maximum write range
Re: [PATCH 05/16] SQUASHME pnfs-submit: rewrite layout allocation
On Mon, Jul 12, 2010 at 4:30 AM, Benny Halevy <[email protected]> wro= te:
Quoted 7 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
Quoted 6 lines
From: Andy Adamson <[email protected]>
Don't wait on a bit if layout is not allocated. Instead, allocate, check for existance, and possibly free.
As per new layout refcounting scheme,don't take a reference on the l=
ayout.
Quoted 4 lines
Quoted 4 lines
Signed-off-by Andy Adamson <[email protected]>---
=A0fs/nfs/pnfs.c =A0 =A0 =A0 =A0 =A0| =A0 84 +++++++++++++----------=
------------------------
Quoted 30 lines
Quoted 30 lines
=A0include/linux/nfs_fs.h | =A0 =A01 -
=A02 files changed, 23 insertions(+), 62 deletions(-)fs/nfs/pnfs.c +0
-4@@ -914,7 +914,6 @@ alloc_init_layout(struct inode *ino) =A0 =A0 =A0 struct pnfs_layout_type *lo; =A0 =A0 =A0 struct layoutdriver_io_operations *io_ops; - =A0 =A0 BUG_ON(NFS_I(ino)->layout !=3D NULL); =A0 =A0 =A0 io_ops =3D NFS_SERVER(ino)->pnfs_curr_ld->ld_io_ops; =A0 =A0 =A0 lo =3D io_ops->alloc_layout(ino); =A0 =A0 =A0 if (!lo) {@@ -923,84 +922,47 @@ alloc_init_layout(struct inode *ino) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 __func__); =A0 =A0 =A0 =A0 =A0 =A0 =A0 return NULL; =A0 =A0 =A0 } - =A0 =A0 spin_lock(&ino->i_lock); =A0 =A0 =A0 lo->refcount =3D 1; =A0 =A0 =A0 INIT_LIST_HEAD(&lo->lo_layouts); =A0 =A0 =A0 INIT_LIST_HEAD(&lo->segs); =A0 =A0 =A0 seqlock_init(&lo->seqlock); =A0 =A0 =A0 lo->lo_inode =3D ino; - =A0 =A0 NFS_I(ino)->layout =3D lo; - =A0 =A0 spin_unlock(&ino->i_lock); =A0 =A0 =A0 return lo; =A0}
Quoted 14 lines
Quoted 8 lines
fs/nfs/pnfs.c +0
-8-static int pnfs_wait_schedule (void *word) -{ - =A0 =A0 if (signal_pending(current)) - =A0 =A0 =A0 =A0 =A0 =A0 return -ERESTARTSYS; - =A0 =A0 schedule(); - =A0 =A0 return 0; -} -Quoted 6 lines
=A0/*
- * get, possibly allocate, and lockcurrent_layout
+ * Lock and possibly allocate the inode layout
=A0 *
- * Note: If successful,ino->i_lockis taken and the caller
- * must put and unlockcurrent_layoutwhen the returned layout is r=
eleased.
Quoted 11 lines
Quoted 11 lines
+ * If successful,
ino->i_lockis taken, and the caller must unlock. =A0 */
=A0static structpnfs_layout_type*fs/nfs/pnfs.c +1
-1-get_lock_alloc_layout(struct inode *ino) +nfs_lock_alloc_layout(struct inode *ino)=A0{
- =A0 =A0 structnfs_inode*nfsi =3DNFS_I(ino);
- =A0 =A0 structpnfs_layout_type*lo;
- =A0 =A0 int res;
+ =A0 =A0 structpnfs_layout_type*new =3D NULL;
Quoted 8 lines
Quoted 6 lines
=A0 =A0 =A0
dprintk("%s Begin\n", __func__);=A0 =A0 =A0
spin_lock(&ino->i_lock);
- =A0 =A0 while ((lo =3Dgrab_current_layout(nfsi)) =3D=3D NULL) {
+ =A0 =A0 if (NFS_I(ino)->layout =3D=3D NULL) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0spin_unlock(&ino->i_lock);There's no real need to take the lock here just for checking for NULL=
,
Quoted 1 line
only down below before actually committing the newly allocated struct=
=2E
Quoted 1 line
[I'll make this fix)
I'm not taking the lock just to check for NULL. I'm taking the lock because the function returns a locked i_lock - (or did before you changed it!)
-->Andy
Quoted 4 lines
Benny
Quoted 1 line
- =A0 =A0 =A0 =A0 =A0 =A0 /* Compete against other threads on who's =
doing the allocation,
Quoted 1 line
Quoted 1 line
- =A0 =A0 =A0 =A0 =A0 =A0 =A0* wait until bit is cleared if we lost =
this race.
Quoted 3 lines
Quoted 3 lines
- =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
- =A0 =A0 =A0 =A0 =A0 =A0 res =3D wait_on_bit_lock(
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &nfsi->layout->pnfs_layout=
_state,
Quoted 2 lines
Quoted 2 lines
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
NFS_INO_LAYOUT_ALLOC,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pnfs_wait_schedule, TASK_K=
ILLABLE);
Quoted 6 lines
Quoted 6 lines
- =A0 =A0 =A0 =A0 =A0 =A0 if (res) {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lo =3DERR_PTR(res);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
- =A0 =A0 =A0 =A0 =A0 =A0 }
-
- =A0 =A0 =A0 =A0 =A0 =A0 /* Wascurrent_layoutalready allocated wh=
ile we slept?
Quoted 1 line
Quoted 1 line
- =A0 =A0 =A0 =A0 =A0 =A0 =A0* If so, retry get_lock'ing it. Otherwi=
se, allocate it.
Quoted 10 lines
Quoted 10 lines
- =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
- =A0 =A0 =A0 =A0 =A0 =A0 if (nfsi->layout) {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spin_lock(&ino->i_lock);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;
+ =A0 =A0 =A0 =A0 =A0 =A0 new =3Dalloc_init_layout(ino);
+ =A0 =A0 =A0 =A0 =A0 =A0 if (new =3D=3D NULL)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return NULL;
+ =A0 =A0 =A0 =A0 =A0 =A0spin_lock(&ino->i_lock);
+ =A0 =A0 =A0 =A0 =A0 =A0 if (NFS_I(ino)->layout =3D=3D NULL) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NFS_I(ino)->layout =3D new=
;
Quoted 10 lines
fs/nfs/pnfs.c
Quoted 10 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 new =3D NULL; =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
fs/nfs/pnfs.c +0
-8- - =A0 =A0 =A0 =A0 =A0 =A0 lo =3D alloc_init_layout(ino); - =A0 =A0 =A0 =A0 =A0 =A0 if (lo) - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_lock(&ino->i_lock); - =A0 =A0 =A0 =A0 =A0 =A0 else - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 lo =3D ERR_PTR(-ENOMEM); - - =A0 =A0 =A0 =A0 =A0 =A0 /* release the NFS_INO_LAYOUT_ALLOC bit an=
d wake up waiters */
Quoted 2 lines
Quoted 2 lines
- =A0 =A0 =A0 =A0 =A0 =A0 clear_bit_unlock(NFS_INO_LAYOUT_ALLOC,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&nfsi->=
layout->pnfs_layout_state);
Quoted 1 line
Quoted 1 line
- =A0 =A0 =A0 =A0 =A0 =A0 wake_up_bit(&nfsi->layout->pnfs_layout_sta=
te,
Quoted 1 line
Quoted 1 line
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NFS_INO_LAYOUT_ALL=
OC);
Quoted 8 lines
fs/nfs/pnfs.c
Quoted 8 lines
- =A0 =A0 =A0 =A0 =A0 =A0 break;
=A0 =A0 =A0 }fs/nfs/pnfs.c +0
-6- -#ifdef NFS_DEBUG - =A0 =A0 if (!IS_ERR(lo)) - =A0 =A0 =A0 =A0 =A0 =A0 dprintk("%s Return %p\n", __func__, lo); - =A0 =A0 else - =A0 =A0 =A0 =A0 =A0 =A0 dprintk("%s Return error %ld\n", __func__,=
PTR_ERR(lo));
Quoted 4 lines
Quoted 4 lines
-#endif
- =A0 =A0 return lo;
+ =A0 =A0 if (new) {
+ =A0 =A0 =A0 =A0 =A0 =A0 /* Reference the layout accrossi_lockrel=
ease and grab */
Quoted 3 lines
Quoted 3 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 get_layout(NFS_I(ino)->layout);
+ =A0 =A0 =A0 =A0 =A0 =A0spin_unlock(&ino->i_lock);
+ =A0 =A0 =A0 =A0 =A0 =A0 NFS_SERVER(ino)->pnfs_curr_ld->ld_io_ops->=
free_layout(new);
Quoted 9 lines
Quoted 9 lines
+ =A0 =A0 =A0 =A0 =A0 =A0
spin_lock(&ino->i_lock);
+ =A0 =A0 =A0 =A0 =A0 =A0 put_layout(NFS_I(ino)->layout);
+ =A0 =A0 }
+ =A0 =A0 return NFS_I(ino)->layout;
=A0}=A0/*
fs/nfs/pnfs.c +0
-0@@ -1088,8 +1050,8 @@ _pnfs_update_layout(struct inode *ino,
Quoted 7 lines
Quoted 7 lines
fs/nfs/pnfs.c +2
-2=A0 =A0 =A0 if (take_ref) =A0 =A0 =A0 =A0 =A0 =A0 =A0 *lsegpp =3D NULL; - =A0 =A0 lo =3D get_lock_alloc_layout(ino); - =A0 =A0 if (IS_ERR(lo)) { + =A0 =A0 lo =3D nfs_lock_alloc_layout(ino); + =A0 =A0 if (lo =3D=3D NULL) {=A0 =A0 =A0 =A0 =A0 =A0 =A0 dprintk("%s ERROR: can't get pnfs_layout=
_type\n", __func__);
Quoted 9 lines
Quoted 9 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out;
=A0 =A0 =A0 }include/linux/nfs_fs.h +0
-0@@ -107,7 +107,6 @@ struct pnfs_layout_type { =A0 =A0 =A0 unsigned long pnfs_layout_state;=A0 =A0 =A0 #define
NFS_INO_RO_LAYOUT_FAILED0 =A0 =A0 =A0/* get ro =
layout failed stop trying */
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 #define
NFS_INO_RW_LAYOUT_FAILED1 =A0 =A0 =A0/* get rw =
layout failed stop trying */
Quoted 1 line
Quoted 1 line
- =A0 =A0 #define
NFS_INO_LAYOUT_ALLOC=A0 =A0 2 =A0 =A0 =A0/* bit l=
ock for layout allocation */
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 #define
NFS_INO_LAYOUTCOMMIT=A0 =A0 3 =A0 =A0 =A0/* LAY=
OUTCOMMIT needed */
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 struct
rpc_cred=A0 =A0 =A0 =A0*lo_cred; /* layoutcommi=
t credential */
Quoted 3 lines
Quoted 1 line
=A0 =A0 =A0 /* DH: These vars keep track of the maximum write range
--
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
A message that is not in the archive (sent off-list or not yet received): AANLkTilb6ePL7s6H4TbhGfJt05Yw7Gc24V0C8cPHC22K-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 05/16] SQUASHME pnfs-submit: rewrite layout allocation
Quoted 79 lines · William A. (Andy) Adamson
Quoted 68 lines · Benny Halevy
Quoted 67 lines · On Jul. 08, 2010, 1:34 +0300, [email protected] wrote:
From: Andy Adamson <[email protected]>
Don't wait on a bit if layout is not allocated. Instead, allocate, check for existance, and possibly free.
As per new layout refcounting scheme,don't take a reference on the layout.
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/pnfs.c | 84 +++++++++++++---------------------------------- include/linux/nfs_fs.h | 1 - 2 files changed, 23 insertions(+), 62 deletions(-)fs/nfs/pnfs.c +4
-19@@ -914,7 +914,6 @@ alloc_init_layout(struct inode *ino)struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; -BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; lo = io_ops->alloc_layout (ino);if (!lo) {@@ -923,84 +922,47 @@ alloc_init_layout(struct inode *ino) __func__);return NULL ; } -spin_lock (&ino->i_lock); lo->refcount =1 ;INIT_LIST_HEAD (&lo->lo_layouts);INIT_LIST_HEAD (&lo->segs);seqlock_init (&lo->seqlock); lo->lo_inode = ino; -NFS_I (ino)->layout = lo; -spin_unlock (&ino->i_lock);return lo; } -static int pnfs_wait_schedule (void *word) -{ -if (signal_pending (current)) -return -ERESTARTSYS ; -schedule (); -return 0 ; -} -/* -* get, possibly allocate, and lock current_layout +* Lock and possibly allocate the inode layout * -* Note: If successful, ino->i_lock is taken and the caller -* must put and unlock current_layout when the returned layout is released. +* If successful, ino->i_lock is taken, and the caller must unlock. */ static struct pnfs_layout_type * -get_lock_alloc_layout (struct inode *ino) +nfs_lock_alloc_layout (struct inode *ino) { -struct nfs_inode *nfsi =NFS_I (ino); -struct pnfs_layout_type *lo; -int res; +struct pnfs_layout_type *new =NULL ;dprintk ("%s Begin\n" , __func__);Quoted 8 lines
fs/nfs/pnfs.c alloc_init_layout(struct inode *ino) · line 947
Quoted 4 lines
fs/nfs/pnfs.c +1
-1spin_lock (&ino->i_lock); -while ((lo =grab_current_layout (nfsi)) ==NULL ) { +if (NFS_I (ino)->layout ==NULL ) {spin_unlock (&ino->i_lock);There's no real need to take the lock here just for checking for NULL, only down below before actually committing the newly allocated struct. [I'll make this fix)
Quoted 3 lines
I'm not taking the lock just to check for NULL. I'm taking the lock because the function returns a locked
i_lock- (or did before you changed it!)
True. My mistake.
Benny
Quoted 94 lines
-->Andy
Quoted 91 lines
Benny
Quoted 76 lines
fs/nfs/pnfs.c +18
-41-/* Compete against other threads on who's doing the allocation, -* wait until bit is cleared if we lost this race. -*/ - res =wait_on_bit_lock ( - &nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC , - pnfs_wait_schedule,TASK_KILLABLE ); -if (res) { - lo =ERR_PTR (res); -break ; - } - -/* Was current_layout already allocated while we slept? -* If so, retry get_lock'ing it. Otherwise, allocate it. -*/ -if (nfsi->layout) { -spin_lock (&ino->i_lock); -continue ; + new =alloc_init_layout (ino); +if (new ==NULL ) +return NULL ; +spin_lock (&ino->i_lock); +if (NFS_I (ino)->layout ==NULL ) { +NFS_I (ino)->layout = new; + new =NULL ; } - - lo =alloc_init_layout (ino); -if (lo) -spin_lock (&ino->i_lock); -else - lo =ERR_PTR (-ENOMEM ); - -/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ -clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout->pnfs_layout_state); -wake_up_bit (&nfsi->layout->pnfs_layout_state, -NFS_INO_LAYOUT_ALLOC ); -break ; } - -#ifdef NFS_DEBUG -if (!IS_ERR (lo)) -dprintk ("%s Return %p\n" , __func__, lo); -else -dprintk ("%s Return error %ld\n" , __func__,PTR_ERR (lo)); -#endif -return lo; +if (new) { +/* Reference the layout accross i_lock release and grab */ +get_layout (NFS_I (ino)->layout); +spin_unlock (&ino->i_lock); +NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops->free_layout (new); +spin_lock (&ino->i_lock); +put_layout (NFS_I (ino)->layout); + } +return NFS_I (ino)->layout; }/* @@ -1088,8 +1050,8 @@ _pnfs_update_layout(struct inode *ino,if (take_ref) *lsegpp =NULL ; - lo =get_lock_alloc_layout (ino); -if (IS_ERR (lo)) { + lo =nfs_lock_alloc_layout (ino); +if (lo ==NULL ) {dprintk ("%s ERROR: can't get pnfs_layout_type\n" , __func__); goto out; }include/linux/nfs_fs.h +0
-0include/linux/nfs_fs.h struct pnfs_layout_type { · line 112
Quoted 7 lines
include/linux/nfs_fs.h +0
-1@@ -107,7 +107,6 @@ struct pnfs_layout_type {unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ -#define NFS_INO_LAYOUT_ALLOC 2/* bit lock for layout allocation */ #define NFS_INO_LAYOUTCOMMIT 3/* LAYOUTCOMMIT needed */ struct rpc_cred *lo_cred;/* layoutcommit credential */ /* DH: These vars keep track of the maximum write range --
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 04/16] SQUASHME pnfs-submit: filelayout: use new alloc/free_layout API
In reply to [email protected]Quoted 27 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4filelayout.c | 15 +++++++++------ fs/nfs/nfs4filelayout.h | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-)fs/nfs/nfs4filelayout.c +5
-2@@ -301,20 +301,23 @@ filelayout_write_pagelist(struct pnfs_layout_type *layoutid,* will use the pnfs_layout_type type to refer to the layout for this * inode from now on. */ -static void * +static struct pnfs_layout_type *filelayout_alloc_layout (struct inode *inode) { +struct nfs4_filelayout *flp; +dprintk ("NFS_FILELAYOUT: allocating layout\n" ); -return kzalloc (sizeof (struct nfs4_filelayout ),GFP_KERNEL ); + flp =kzalloc (sizeof (struct nfs4_filelayout ),GFP_KERNEL ); +return flp ? &flp->fl_layout :NULL ; }
fs/nfs/nfs4filelayout.c filelayout_write_pagelist(struct pnfs_layout_type *layoutid, · line 320
Quoted 10 lines
fs/nfs/nfs4filelayout.c +2
-2/* Free a filelayout layout structure */ static void -filelayout_free_layout (void *layoutid) +filelayout_free_layout (struct pnfs_layout_type *lo) {dprintk ("NFS_FILELAYOUT: freeing layout\n" ); -kfree (layoutid); +kfree (lo);
+ kfree(FILE_LO(lo));
Quoted 36 lines
fs/nfs/nfs4filelayout.c +2
-2}/* @@ -471,7 +474,7 @@ static struct pnfs_layout_segment * filelayout_alloc_lseg(struct pnfs_layout_type *layoutid, struct nfs4_pnfs_layoutget_res *lgr) { - struct nfs4_filelayout *flo = PNFS_LD_DATA(layoutid); + struct nfs4_filelayout *flo = FILE_LO(layoutid);struct pnfs_layout_segment *lseg;int rc;@@ -693,7 +696,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,ssize_t filelayout_get_stripesize (struct pnfs_layout_type *layoutid) { -struct nfs4_filelayout *flo =PNFS_LD_DATA (layoutid); +struct nfs4_filelayout *flo =FILE_LO (layoutid);return flo->stripe_unit; }fs/nfs/nfs4filelayout.h +1
-0@@ -68,6 +68,7 @@ struct nfs4_filelayout_segment { };struct nfs4_filelayout { +struct pnfs_layout_type fl_layout;int uncommitted_write;loff_t last_commit_size;u64 layout_id;@@ -77,6 +78,12 @@ struct nfs4_filelayout {extern struct nfs_fh *nfs4_fl_select_ds_fh (struct pnfs_layout_segment *lseg,loff_t offset);
fs/nfs/nfs4filelayout.h struct nfs4_filelayout { · line 89
Quoted 10 lines
fs/nfs/nfs4filelayout.h +6
-0+static inline struct nfs4_filelayout * +FILE_LO (struct pnfs_layout_type *lo) +{ + return container_of(lo, struct nfs4_filelayout, fl_layout); +} +extern struct pnfs_client_operations *pnfs_callback_ops;extern void nfs4_fl_free_deviceid_callback (struct kref *);
Boaz
Re: [PATCH 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
In reply to [email protected]Quoted 93 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Change
nfs_inodelayout field to a pointerEach layoutdriver embeds the
pnfs_layout_typein it's private layout cache head structure, and allocates them both with thealloc_layoutlayoutdriver_io_operation.NOTE API change: the
layoutdriver_io_operationalloc_layoutandfree_layoutnow usepnfs_layout_typepointers instead of void*.Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/callback_proc.c | 2 +- fs/nfs/inode.c | 12 +----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 111 +++++++++++++++++++++++---------------------- include/linux/nfs4_pnfs.h | 19 +++----- include/linux/nfs_fs.h | 4 +- 7 files changed, 71 insertions(+), 83 deletions(-)fs/nfs/callback_proc.c +1
-1@@ -233,7 +233,7 @@ static int pnfs_recall_layout(void *data) rl.cbl_seg.length =NFS4_MAX_UINT64 ;if (rl.cbl_recall_type ==RETURN_FILE ) { -if (pnfs_is_next_layout_stateid (&NFS_I (inode)->layout, +if (pnfs_is_next_layout_stateid (NFS_I (inode)->layout, rl.cbl_stateid)) status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, RETURN_FILE,fs/nfs/inode.c +1
-11@@ -1397,17 +1397,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); nfsi->pnfs_layout_suspend =0 ; -seqlock_init (&nfsi->layout.seqlock); -INIT_LIST_HEAD (&nfsi->layout.lo_layouts); -INIT_LIST_HEAD (&nfsi->layout.segs); - nfsi->layout.refcount =0 ; - nfsi->layout.ld_data =NULL ; - nfsi->layout.pnfs_layout_state =0 ; -memset (&nfsi->layout.stateid,0 ,NFS4_STATEID_SIZE ); - nfsi->layout.roc_iomode =0 ; - nfsi->layout.lo_cred =NULL ; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; + nfsi->layout =NULL ;#endif /* CONFIG_NFS_V4_1 */ #endif }fs/nfs/nfs4proc.c +1
-1@@ -1086,7 +1086,7 @@ static void pnfs4_layout_reclaim(struct nfs4_state *state)* flag during grace period */ pnfs_destroy_layout (NFS_I (state->inode)); -pnfs_set_layout_stateid (&NFS_I (state->inode)->layout, &zero_stateid); +pnfs_set_layout_stateid (NFS_I (state->inode)->layout, &zero_stateid);#endif /* CONFIG_NFS_V4_1 */ }fs/nfs/nfs4state.c +2
-2@@ -597,10 +597,10 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,#ifdef CONFIG_NFS_V4_1 struct nfs_inode *nfsi =NFS_I (state->inode); -if (has_layout (nfsi) && nfsi->layout.roc_iomode) { +if (has_layout (nfsi) && nfsi->layout->roc_iomode) {struct nfs4_pnfs_layout_segment range; - range.iomode = nfsi->layout.roc_iomode; + range.iomode = nfsi->layout->roc_iomode; range.offset =0 ; range.length =NFS4_MAX_UINT64 ; pnfs_return_layout(state->inode, &range, NULL,fs/nfs/pnfs.c +0
-0
fs/nfs/pnfs.c pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) · line 156
Quoted 7 lines
fs/nfs/pnfs.c +2
-2@@ -152,10 +152,11 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) {dprintk ("%s: has_layout=%d ctx=%p\n" , __func__,has_layout (nfsi), ctx);spin_lock (&nfsi->vfs_inode.i_lock); -if (has_layout (nfsi) && !layoutcommit_needed (nfsi)) { - nfsi->layout.lo_cred =get_rpccred (ctx->state->owner->so_cred); +if (has_layout (nfsi) && ! + !test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state)) {
Is the "!!" intended
Why did you open code layoutcommit_needed() ?
Quoted 121 lines
fs/nfs/pnfs.c +29
-27+ nfsi->layout->lo_cred =get_rpccred (ctx->state->owner->so_cred);__set_bit (NFS_INO_LAYOUTCOMMIT , - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->change_attr++;spin_unlock (&nfsi->vfs_inode.i_lock);dprintk ("%s: Set layoutcommit\n" , __func__);@@ -175,17 +176,17 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)loff_t end_pos;spin_lock (&nfsi->vfs_inode.i_lock); -if (offset < nfsi->layout.pnfs_write_begin_pos) - nfsi->layout.pnfs_write_begin_pos = offset; +if (offset < nfsi->layout->pnfs_write_begin_pos) + nfsi->layout->pnfs_write_begin_pos = offset; end_pos = offset + extent -1 ;/* I'm being inclusive */ -if (end_pos > nfsi->layout.pnfs_write_end_pos) - nfsi->layout.pnfs_write_end_pos = end_pos; +if (end_pos > nfsi->layout->pnfs_write_end_pos) + nfsi->layout->pnfs_write_end_pos = end_pos;dprintk ("%s: Wrote %lu@%lu bpos %lu, epos: %lu\n" , __func__, (unsigned long ) extent, (unsigned long ) offset , - (unsigned long ) nfsi->layout.pnfs_write_begin_pos, - (unsigned long ) nfsi->layout.pnfs_write_end_pos); + (unsigned long ) nfsi->layout->pnfs_write_begin_pos, + (unsigned long ) nfsi->layout->pnfs_write_end_pos);spin_unlock (&nfsi->vfs_inode.i_lock); }@@ -326,10 +327,9 @@ get_layout(struct pnfs_layout_type *lo)static inline struct pnfs_layout_type *grab_current_layout (struct nfs_inode *nfsi) { -struct pnfs_layout_type *lo = &nfsi->layout; +struct pnfs_layout_type *lo = nfsi->layout; -BUG_ON_UNLOCKED_LO (lo); -if (!lo->ld_data) +if (!lo)return NULL ;get_layout (lo);return lo;@@ -343,13 +343,13 @@ put_layout(struct pnfs_layout_type *lo) lo->refcount--;if (!lo->refcount) { -struct layoutdriver_io_operations *io_ops = -PNFS_LD_IO_OPS (lo); +struct layoutdriver_io_operations *io_ops =PNFS_LD_IO_OPS (lo); +struct nfs_inode *nfsi =PNFS_NFS_INODE (lo); -dprintk ("%s: freeing layout %p\n" , __func__, lo->ld_data); +dprintk ("%s: freeing layout cache %p\n" , __func__, lo);WARN_ON (!list_empty (&lo->lo_layouts)); - io_ops->free_layout (lo->ld_data); - lo->ld_data =NULL ; + io_ops->free_layout (lo); + nfsi->layout =NULL ; } }@@ -381,14 +381,13 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) lo =grab_current_layout (nfsi);if (lo) {pnfs_free_layout (lo, &range); -WARN_ON (!list_empty (&nfsi->layout.segs)); -WARN_ON (!list_empty (&nfsi->layout.lo_layouts)); -WARN_ON (nfsi->layout.ld_data); +WARN_ON (!list_empty (&nfsi->layout->segs)); +WARN_ON (!list_empty (&nfsi->layout->lo_layouts)); -if (nfsi->layout.refcount !=1 ) +if (nfsi->layout->refcount !=1 )printk (KERN_WARNING "%s: layout refcount not=1 %d\n" , - __func__, nfsi->layout.refcount); -WARN_ON (nfsi->layout.refcount !=1 ); + __func__, nfsi->layout->refcount); +WARN_ON (nfsi->layout->refcount !=1 );put_layout (lo); }@@ -698,7 +697,7 @@ pnfs_return_layout_barrier(struct nfs_inode *nfsi,bool ret = false;spin_lock (&nfsi->vfs_inode.i_lock); - list_for_each_entry (lseg, &nfsi->layout.segs, fi_list) { +list_for_each_entry (lseg, &nfsi->layout->segs, fi_list) {if (!should_free_lseg (lseg, range))continue ; lseg->valid = false;@@ -904,29 +903,33 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,dprintk ("%s:Return\n" , __func__); } +/* +* Each layoutdriver embeds pnfs_layout_type as the first field in it's +* per-layout type layout cache structure and returns it ZEROed +* from layoutdriver_io_ops->alloc_layout +*/ static struct pnfs_layout_type *alloc_init_layout (struct inode *ino) { -void *ld_data;struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; +BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; - lo = &NFS_I (ino)->layout; - ld_data = io_ops->alloc_layout (ino); -if (!ld_data) { + lo = io_ops->alloc_layout (ino); +if (!lo) {printk (KERN_ERR "%s: out of memory: io_ops->alloc_layout failed\n" , __func__);return NULL ; } -
fs/nfs/pnfs.c pnfs_insert_layout(struct pnfs_layout_type *lo, · line 931
Quoted 10 lines
fs/nfs/pnfs.c +4
-4spin_lock (&ino->i_lock); -BUG_ON (lo->ld_data !=NULL ); - lo->ld_data = ld_data; -memset (&lo->stateid,0 ,NFS4_STATEID_SIZE ); lo->refcount =1 ; - lo->roc_iomode =0 ; +INIT_LIST_HEAD (&lo->lo_layouts); +INIT_LIST_HEAD (&lo->segs); +seqlock_init (&lo->seqlock); + lo->lo_inode = ino;
The spin_lock() could be moved to here, it's the single place that actually touches the nfsi.
Quoted 165 lines
fs/nfs/pnfs.c +22
-21+NFS_I (ino)->layout = lo;spin_unlock (&ino->i_lock);return lo; }@@ -961,7 +964,7 @@ get_lock_alloc_layout(struct inode *ino)* wait until bit is cleared if we lost this race. */ res =wait_on_bit_lock ( - &nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC , pnfs_wait_schedule,TASK_KILLABLE );if (res) {@@ -972,7 +975,7 @@ get_lock_alloc_layout(struct inode *ino)/* Was current_layout already allocated while we slept? * If so, retry get_lock'ing it. Otherwise, allocate it. */ -if (nfsi->layout.ld_data) { +if (nfsi->layout) {spin_lock (&ino->i_lock);continue ; }@@ -985,8 +988,8 @@ get_lock_alloc_layout(struct inode *ino)/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout.pnfs_layout_state); -wake_up_bit (&nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state); +wake_up_bit (&nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC );break ; }@@ -1113,12 +1116,12 @@ _pnfs_update_layout(struct inode *ino, }/* if get layout already failed once goto out */ -if (test_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state)) { +if (test_bit (lo_fail_bit (iomode), &nfsi->layout->pnfs_layout_state)) {if (unlikely (nfsi->pnfs_layout_suspend &&get_seconds () >= nfsi->pnfs_layout_suspend)) {dprintk ("%s: layout_get resumed\n" , __func__);clear_bit (lo_fail_bit (iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->pnfs_layout_suspend =0 ; }else goto out_put;@@ -1130,7 +1133,7 @@ _pnfs_update_layout(struct inode *ino,send_layoutget (ino, ctx, &arg, lsegpp, lo); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, - nfsi->layout.pnfs_layout_state, lseg); + nfsi->layout->pnfs_layout_state, lseg);return ; out_put:if (lsegpp)@@ -1235,12 +1238,12 @@ pnfs_get_layout_done(struct nfs4_pnfs_layoutget *lgp, int rpc_status)/* remember that get layout failed and suspend trying */ nfsi->pnfs_layout_suspend = suspend;set_bit (lo_fail_bit (lgp->args.lseg.iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state);dprintk ("%s: layout_get suspended until %ld\n" , __func__, suspend); out:dprintk ("%s end (err:%d) state 0x%lx lseg %p\n" , - __func__, lgp->status, nfsi->layout.pnfs_layout_state, lseg); + __func__, lgp->status, nfsi->layout->pnfs_layout_state, lseg);return ; }@@ -1321,7 +1324,7 @@ pnfs_set_pg_test(struct inode *inode, struct nfs_pageio_descriptor *pgio) pgio->pg_test =NULL ; - laytype = &NFS_I (inode)->layout; + laytype =NFS_I (inode)->layout; ld =NFS_SERVER (inode)->pnfs_curr_ld;if (!pnfs_enabled_sb (NFS_SERVER (inode)) || !laytype)return ;@@ -1454,7 +1457,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) numpages); wdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1507,7 +1510,7 @@ pnfs_readpages(struct nfs_read_data *rdata) __func__, numpages); rdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1568,7 +1571,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)* This will be done by passing the buck to the layout driver. */ data->pdata.lseg =NULL ; - trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (&nfsi->layout, + trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (nfsi->layout, sync, data);dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs);return trypnfs;@@ -1639,14 +1642,14 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)/* Clear layoutcommit properties in the inode so * new lc info can be generated */ - write_begin_pos = nfsi->layout.pnfs_write_begin_pos; - write_end_pos = nfsi->layout.pnfs_write_end_pos; - data->cred = nfsi->layout.lo_cred; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; - nfsi->layout.lo_cred =NULL ; -__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); -pnfs_get_layout_stateid (&data->args.stateid, &nfsi->layout); + write_begin_pos = nfsi->layout->pnfs_write_begin_pos; + write_end_pos = nfsi->layout->pnfs_write_end_pos; + data->cred = nfsi->layout->lo_cred; + nfsi->layout->pnfs_write_begin_pos =0 ; + nfsi->layout->pnfs_write_end_pos =0 ; + nfsi->layout->lo_cred =NULL ; +__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state); +pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);spin_unlock (&inode->i_lock);include/linux/nfs4_pnfs.h +2
-8@@ -35,13 +35,13 @@ struct pnfs_layoutdriver_type {static inline struct nfs_inode *PNFS_NFS_INODE (struct pnfs_layout_type *lo) { - return container_of(lo, struct nfs_inode, layout); +return NFS_I (lo->lo_inode); }static inline struct inode *PNFS_INODE (struct pnfs_layout_type *lo) { -return &PNFS_NFS_INODE (lo)->vfs_inode; +return lo->lo_inode; } static inline struct nfs_server *@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)return NFS_SERVER (PNFS_INODE (lo)); } -static inline void * -PNFS_LD_DATA (struct pnfs_layout_type *lo) -{ -return lo->ld_data; -} -static inline struct pnfs_layoutdriver_type *PNFS_LD (struct pnfs_layout_type *lo) {
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 74
Quoted 5 lines
include/linux/nfs4_pnfs.h +1
-1@@ -77,13 +71,14 @@ PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo)static inline bool has_layout (struct nfs_inode *nfsi) { -return nfsi->layout.ld_data !=NULL ; +return nfsi->layout !=NULL ;
does this mean the same thing now?
You could perhaps optimize with a bit flag that is set on first segment insert, and reset on last segment removal. Or some other/better scheme.
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 81
Quoted 8 lines
include/linux/nfs4_pnfs.h +2
-1}static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);
What is the purpose of patch[1/1] ?
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
Quoted 43 lines
include/linux/nfs4_pnfs.h +2
-2}#else /* CONFIG_NFS_V4_1 */ @@ -149,8 +144,8 @@ struct layoutdriver_io_operations {/* Layout information. For each inode, alloc_layout is executed once to retrieve an * inode specific layout structure. Each subsequent layoutget operation results in * a set_layout call to set the opaque layout in the layout driver.*/ -void * (*alloc_layout) (struct inode *inode); -void (*free_layout) (void *layoutid); +struct pnfs_layout_type * (*alloc_layout) (struct inode *inode); +void (*free_layout) (struct pnfs_layout_type *);struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid,struct nfs4_pnfs_layoutget_res *lgr);void (*free_lseg) (struct pnfs_layout_segment *lseg);include/linux/nfs_fs.h +2
-2@@ -104,7 +104,6 @@ struct pnfs_layout_type {int roc_iomode;/* iomode to return on close, 0=none */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -void *ld_data;/* layout driver private data */ unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ @@ -116,6 +115,7 @@ struct pnfs_layout_type {*/ loff_t pnfs_write_begin_pos;loff_t pnfs_write_end_pos; +struct inode *lo_inode; };/* @@ -206,7 +206,7 @@ struct nfs_inode {/* pNFS layout information */ #if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq; -struct pnfs_layout_type layout; +struct pnfs_layout_type *layout;time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/
Re: [PATCH 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
Quoted 415 lines · Boaz Harrosh
Quoted 93 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Change
nfs_inodelayout field to a pointerEach layoutdriver embeds the
pnfs_layout_typein it's private layout cache head structure, and allocates them both with thealloc_layoutlayoutdriver_io_operation.NOTE API change: the
layoutdriver_io_operationalloc_layoutandfree_layoutnow usepnfs_layout_typepointers instead of void*.Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/callback_proc.c | 2 +- fs/nfs/inode.c | 12 +----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 111 +++++++++++++++++++++++---------------------- include/linux/nfs4_pnfs.h | 19 +++----- include/linux/nfs_fs.h | 4 +- 7 files changed, 71 insertions(+), 83 deletions(-)fs/nfs/callback_proc.c +1
-1@@ -233,7 +233,7 @@ static int pnfs_recall_layout(void *data) rl.cbl_seg.length =NFS4_MAX_UINT64 ;if (rl.cbl_recall_type ==RETURN_FILE ) { -if (pnfs_is_next_layout_stateid (&NFS_I (inode)->layout, +if (pnfs_is_next_layout_stateid (NFS_I (inode)->layout, rl.cbl_stateid)) status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, RETURN_FILE,fs/nfs/inode.c +1
-11@@ -1397,17 +1397,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); nfsi->pnfs_layout_suspend =0 ; -seqlock_init (&nfsi->layout.seqlock); -INIT_LIST_HEAD (&nfsi->layout.lo_layouts); -INIT_LIST_HEAD (&nfsi->layout.segs); - nfsi->layout.refcount =0 ; - nfsi->layout.ld_data =NULL ; - nfsi->layout.pnfs_layout_state =0 ; -memset (&nfsi->layout.stateid,0 ,NFS4_STATEID_SIZE ); - nfsi->layout.roc_iomode =0 ; - nfsi->layout.lo_cred =NULL ; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; + nfsi->layout =NULL ;#endif /* CONFIG_NFS_V4_1 */ #endif }fs/nfs/nfs4proc.c +1
-1@@ -1086,7 +1086,7 @@ static void pnfs4_layout_reclaim(struct nfs4_state *state)* flag during grace period */ pnfs_destroy_layout (NFS_I (state->inode)); -pnfs_set_layout_stateid (&NFS_I (state->inode)->layout, &zero_stateid); +pnfs_set_layout_stateid (NFS_I (state->inode)->layout, &zero_stateid);#endif /* CONFIG_NFS_V4_1 */ }fs/nfs/nfs4state.c +2
-2@@ -597,10 +597,10 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,#ifdef CONFIG_NFS_V4_1 struct nfs_inode *nfsi =NFS_I (state->inode); -if (has_layout (nfsi) && nfsi->layout.roc_iomode) { +if (has_layout (nfsi) && nfsi->layout->roc_iomode) {struct nfs4_pnfs_layout_segment range; - range.iomode = nfsi->layout.roc_iomode; + range.iomode = nfsi->layout->roc_iomode; range.offset =0 ; range.length =NFS4_MAX_UINT64 ; pnfs_return_layout(state->inode, &range, NULL,fs/nfs/pnfs.c +0
-0fs/nfs/pnfs.c pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) · line 156
Quoted 7 lines
fs/nfs/pnfs.c +2
-2@@ -152,10 +152,11 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) {dprintk ("%s: has_layout=%d ctx=%p\n" , __func__,has_layout (nfsi), ctx);spin_lock (&nfsi->vfs_inode.i_lock); -if (has_layout (nfsi) && !layoutcommit_needed (nfsi)) { - nfsi->layout.lo_cred =get_rpccred (ctx->state->owner->so_cred); +if (has_layout (nfsi) && ! + !test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state)) {Is the "!!" intended
Why did you open code
layoutcommit_needed()?Quoted 121 lines
fs/nfs/pnfs.c +29
-27+ nfsi->layout->lo_cred =get_rpccred (ctx->state->owner->so_cred);__set_bit (NFS_INO_LAYOUTCOMMIT , - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->change_attr++;spin_unlock (&nfsi->vfs_inode.i_lock);dprintk ("%s: Set layoutcommit\n" , __func__);@@ -175,17 +176,17 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)loff_t end_pos;spin_lock (&nfsi->vfs_inode.i_lock); -if (offset < nfsi->layout.pnfs_write_begin_pos) - nfsi->layout.pnfs_write_begin_pos = offset; +if (offset < nfsi->layout->pnfs_write_begin_pos) + nfsi->layout->pnfs_write_begin_pos = offset; end_pos = offset + extent -1 ;/* I'm being inclusive */ -if (end_pos > nfsi->layout.pnfs_write_end_pos) - nfsi->layout.pnfs_write_end_pos = end_pos; +if (end_pos > nfsi->layout->pnfs_write_end_pos) + nfsi->layout->pnfs_write_end_pos = end_pos;dprintk ("%s: Wrote %lu@%lu bpos %lu, epos: %lu\n" , __func__, (unsigned long ) extent, (unsigned long ) offset , - (unsigned long ) nfsi->layout.pnfs_write_begin_pos, - (unsigned long ) nfsi->layout.pnfs_write_end_pos); + (unsigned long ) nfsi->layout->pnfs_write_begin_pos, + (unsigned long ) nfsi->layout->pnfs_write_end_pos);spin_unlock (&nfsi->vfs_inode.i_lock); }@@ -326,10 +327,9 @@ get_layout(struct pnfs_layout_type *lo)static inline struct pnfs_layout_type *grab_current_layout (struct nfs_inode *nfsi) { -struct pnfs_layout_type *lo = &nfsi->layout; +struct pnfs_layout_type *lo = nfsi->layout; -BUG_ON_UNLOCKED_LO (lo); -if (!lo->ld_data) +if (!lo)return NULL ;get_layout (lo);return lo;@@ -343,13 +343,13 @@ put_layout(struct pnfs_layout_type *lo) lo->refcount--;if (!lo->refcount) { -struct layoutdriver_io_operations *io_ops = -PNFS_LD_IO_OPS (lo); +struct layoutdriver_io_operations *io_ops =PNFS_LD_IO_OPS (lo); +struct nfs_inode *nfsi =PNFS_NFS_INODE (lo); -dprintk ("%s: freeing layout %p\n" , __func__, lo->ld_data); +dprintk ("%s: freeing layout cache %p\n" , __func__, lo);WARN_ON (!list_empty (&lo->lo_layouts)); - io_ops->free_layout (lo->ld_data); - lo->ld_data =NULL ; + io_ops->free_layout (lo); + nfsi->layout =NULL ; } }@@ -381,14 +381,13 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) lo =grab_current_layout (nfsi);if (lo) {pnfs_free_layout (lo, &range); -WARN_ON (!list_empty (&nfsi->layout.segs)); -WARN_ON (!list_empty (&nfsi->layout.lo_layouts)); -WARN_ON (nfsi->layout.ld_data); +WARN_ON (!list_empty (&nfsi->layout->segs)); +WARN_ON (!list_empty (&nfsi->layout->lo_layouts)); -if (nfsi->layout.refcount !=1 ) +if (nfsi->layout->refcount !=1 )printk (KERN_WARNING "%s: layout refcount not=1 %d\n" , - __func__, nfsi->layout.refcount); -WARN_ON (nfsi->layout.refcount !=1 ); + __func__, nfsi->layout->refcount); +WARN_ON (nfsi->layout->refcount !=1 );put_layout (lo); }@@ -698,7 +697,7 @@ pnfs_return_layout_barrier(struct nfs_inode *nfsi,bool ret = false;spin_lock (&nfsi->vfs_inode.i_lock); - list_for_each_entry (lseg, &nfsi->layout.segs, fi_list) { +list_for_each_entry (lseg, &nfsi->layout->segs, fi_list) {if (!should_free_lseg (lseg, range))continue ; lseg->valid = false;@@ -904,29 +903,33 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,dprintk ("%s:Return\n" , __func__); } +/* +* Each layoutdriver embeds pnfs_layout_type as the first field in it's +* per-layout type layout cache structure and returns it ZEROed +* from layoutdriver_io_ops->alloc_layout +*/ static struct pnfs_layout_type *alloc_init_layout (struct inode *ino) { -void *ld_data;struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; +BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; - lo = &NFS_I (ino)->layout; - ld_data = io_ops->alloc_layout (ino); -if (!ld_data) { + lo = io_ops->alloc_layout (ino); +if (!lo) {printk (KERN_ERR "%s: out of memory: io_ops->alloc_layout failed\n" , __func__);return NULL ; } -fs/nfs/pnfs.c pnfs_insert_layout(struct pnfs_layout_type *lo, · line 931
Quoted 10 lines
fs/nfs/pnfs.c +4
-4spin_lock (&ino->i_lock); -BUG_ON (lo->ld_data !=NULL ); - lo->ld_data = ld_data; -memset (&lo->stateid,0 ,NFS4_STATEID_SIZE ); lo->refcount =1 ; - lo->roc_iomode =0 ; +INIT_LIST_HEAD (&lo->lo_layouts); +INIT_LIST_HEAD (&lo->segs); +seqlock_init (&lo->seqlock); + lo->lo_inode = ino;The
spin_lock()could be moved to here, it's the single place that actually touches the nfsi.Quoted 165 lines
fs/nfs/pnfs.c +22
-21+NFS_I (ino)->layout = lo;spin_unlock (&ino->i_lock);return lo; }@@ -961,7 +964,7 @@ get_lock_alloc_layout(struct inode *ino)* wait until bit is cleared if we lost this race. */ res =wait_on_bit_lock ( - &nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC , pnfs_wait_schedule,TASK_KILLABLE );if (res) {@@ -972,7 +975,7 @@ get_lock_alloc_layout(struct inode *ino)/* Was current_layout already allocated while we slept? * If so, retry get_lock'ing it. Otherwise, allocate it. */ -if (nfsi->layout.ld_data) { +if (nfsi->layout) {spin_lock (&ino->i_lock);continue ; }@@ -985,8 +988,8 @@ get_lock_alloc_layout(struct inode *ino)/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout.pnfs_layout_state); -wake_up_bit (&nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state); +wake_up_bit (&nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC );break ; }@@ -1113,12 +1116,12 @@ _pnfs_update_layout(struct inode *ino, }/* if get layout already failed once goto out */ -if (test_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state)) { +if (test_bit (lo_fail_bit (iomode), &nfsi->layout->pnfs_layout_state)) {if (unlikely (nfsi->pnfs_layout_suspend &&get_seconds () >= nfsi->pnfs_layout_suspend)) {dprintk ("%s: layout_get resumed\n" , __func__);clear_bit (lo_fail_bit (iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->pnfs_layout_suspend =0 ; }else goto out_put;@@ -1130,7 +1133,7 @@ _pnfs_update_layout(struct inode *ino,send_layoutget (ino, ctx, &arg, lsegpp, lo); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, - nfsi->layout.pnfs_layout_state, lseg); + nfsi->layout->pnfs_layout_state, lseg);return ; out_put:if (lsegpp)@@ -1235,12 +1238,12 @@ pnfs_get_layout_done(struct nfs4_pnfs_layoutget *lgp, int rpc_status)/* remember that get layout failed and suspend trying */ nfsi->pnfs_layout_suspend = suspend;set_bit (lo_fail_bit (lgp->args.lseg.iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state);dprintk ("%s: layout_get suspended until %ld\n" , __func__, suspend); out:dprintk ("%s end (err:%d) state 0x%lx lseg %p\n" , - __func__, lgp->status, nfsi->layout.pnfs_layout_state, lseg); + __func__, lgp->status, nfsi->layout->pnfs_layout_state, lseg);return ; }@@ -1321,7 +1324,7 @@ pnfs_set_pg_test(struct inode *inode, struct nfs_pageio_descriptor *pgio) pgio->pg_test =NULL ; - laytype = &NFS_I (inode)->layout; + laytype =NFS_I (inode)->layout; ld =NFS_SERVER (inode)->pnfs_curr_ld;if (!pnfs_enabled_sb (NFS_SERVER (inode)) || !laytype)return ;@@ -1454,7 +1457,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) numpages); wdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1507,7 +1510,7 @@ pnfs_readpages(struct nfs_read_data *rdata) __func__, numpages); rdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1568,7 +1571,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)* This will be done by passing the buck to the layout driver. */ data->pdata.lseg =NULL ; - trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (&nfsi->layout, + trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (nfsi->layout, sync, data);dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs);return trypnfs;@@ -1639,14 +1642,14 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)/* Clear layoutcommit properties in the inode so * new lc info can be generated */ - write_begin_pos = nfsi->layout.pnfs_write_begin_pos; - write_end_pos = nfsi->layout.pnfs_write_end_pos; - data->cred = nfsi->layout.lo_cred; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; - nfsi->layout.lo_cred =NULL ; -__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); -pnfs_get_layout_stateid (&data->args.stateid, &nfsi->layout); + write_begin_pos = nfsi->layout->pnfs_write_begin_pos; + write_end_pos = nfsi->layout->pnfs_write_end_pos; + data->cred = nfsi->layout->lo_cred; + nfsi->layout->pnfs_write_begin_pos =0 ; + nfsi->layout->pnfs_write_end_pos =0 ; + nfsi->layout->lo_cred =NULL ; +__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state); +pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);spin_unlock (&inode->i_lock);include/linux/nfs4_pnfs.h +2
-8@@ -35,13 +35,13 @@ struct pnfs_layoutdriver_type {static inline struct nfs_inode *PNFS_NFS_INODE (struct pnfs_layout_type *lo) { - return container_of(lo, struct nfs_inode, layout); +return NFS_I (lo->lo_inode); }static inline struct inode *PNFS_INODE (struct pnfs_layout_type *lo) { -return &PNFS_NFS_INODE (lo)->vfs_inode; +return lo->lo_inode; } static inline struct nfs_server *@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)return NFS_SERVER (PNFS_INODE (lo)); } -static inline void * -PNFS_LD_DATA (struct pnfs_layout_type *lo) -{ -return lo->ld_data; -} -static inline struct pnfs_layoutdriver_type *PNFS_LD (struct pnfs_layout_type *lo) {include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 74
Quoted 5 lines
include/linux/nfs4_pnfs.h +1
-1@@ -77,13 +71,14 @@ PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo)static inline bool has_layout (struct nfs_inode *nfsi) { -return nfsi->layout.ld_data !=NULL ; +return nfsi->layout !=NULL ;does this mean the same thing now?
Quoted 3 lines
You could perhaps optimize with a bit flag that is set on first segment insert, and reset on last segment removal. Or some other/better scheme.
We may want to have has_layout() as well as has_layout_segs() which will check that the lsegs list is not empty.
Benny
Quoted 59 lines
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 81
Quoted 9 lines
include/linux/nfs4_pnfs.h +2
-1}static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);What is the purpose of patch[1/1] ?
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
Quoted 43 lines
include/linux/nfs4_pnfs.h +2
-2}#else /* CONFIG_NFS_V4_1 */ @@ -149,8 +144,8 @@ struct layoutdriver_io_operations {/* Layout information. For each inode, alloc_layout is executed once to retrieve an * inode specific layout structure. Each subsequent layoutget operation results in * a set_layout call to set the opaque layout in the layout driver.*/ -void * (*alloc_layout) (struct inode *inode); -void (*free_layout) (void *layoutid); +struct pnfs_layout_type * (*alloc_layout) (struct inode *inode); +void (*free_layout) (struct pnfs_layout_type *);struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid,struct nfs4_pnfs_layoutget_res *lgr);void (*free_lseg) (struct pnfs_layout_segment *lseg);include/linux/nfs_fs.h +2
-2@@ -104,7 +104,6 @@ struct pnfs_layout_type {int roc_iomode;/* iomode to return on close, 0=none */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -void *ld_data;/* layout driver private data */ unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ @@ -116,6 +115,7 @@ struct pnfs_layout_type {*/ loff_t pnfs_write_begin_pos;loff_t pnfs_write_end_pos; +struct inode *lo_inode; };/* @@ -206,7 +206,7 @@ struct nfs_inode {/* pNFS layout information */ #if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq; -struct pnfs_layout_type layout; +struct pnfs_layout_type *layout;time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/
Re: [PATCH 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
Quoted 416 lines · Benny Halevy
Quoted 415 lines · Boaz Harrosh
Quoted 93 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Change
nfs_inodelayout field to a pointerEach layoutdriver embeds the
pnfs_layout_typein it's private layout cache head structure, and allocates them both with thealloc_layoutlayoutdriver_io_operation.NOTE API change: the
layoutdriver_io_operationalloc_layoutandfree_layoutnow usepnfs_layout_typepointers instead of void*.Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/callback_proc.c | 2 +- fs/nfs/inode.c | 12 +----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 111 +++++++++++++++++++++++---------------------- include/linux/nfs4_pnfs.h | 19 +++----- include/linux/nfs_fs.h | 4 +- 7 files changed, 71 insertions(+), 83 deletions(-)fs/nfs/callback_proc.c +1
-1@@ -233,7 +233,7 @@ static int pnfs_recall_layout(void *data) rl.cbl_seg.length =NFS4_MAX_UINT64 ;if (rl.cbl_recall_type ==RETURN_FILE ) { -if (pnfs_is_next_layout_stateid (&NFS_I (inode)->layout, +if (pnfs_is_next_layout_stateid (NFS_I (inode)->layout, rl.cbl_stateid)) status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, RETURN_FILE,fs/nfs/inode.c +1
-11@@ -1397,17 +1397,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); nfsi->pnfs_layout_suspend =0 ; -seqlock_init (&nfsi->layout.seqlock); -INIT_LIST_HEAD (&nfsi->layout.lo_layouts); -INIT_LIST_HEAD (&nfsi->layout.segs); - nfsi->layout.refcount =0 ; - nfsi->layout.ld_data =NULL ; - nfsi->layout.pnfs_layout_state =0 ; -memset (&nfsi->layout.stateid,0 ,NFS4_STATEID_SIZE ); - nfsi->layout.roc_iomode =0 ; - nfsi->layout.lo_cred =NULL ; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; + nfsi->layout =NULL ;#endif /* CONFIG_NFS_V4_1 */ #endif }fs/nfs/nfs4proc.c +1
-1@@ -1086,7 +1086,7 @@ static void pnfs4_layout_reclaim(struct nfs4_state *state)* flag during grace period */ pnfs_destroy_layout (NFS_I (state->inode)); -pnfs_set_layout_stateid (&NFS_I (state->inode)->layout, &zero_stateid); +pnfs_set_layout_stateid (NFS_I (state->inode)->layout, &zero_stateid);#endif /* CONFIG_NFS_V4_1 */ }fs/nfs/nfs4state.c +2
-2@@ -597,10 +597,10 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,#ifdef CONFIG_NFS_V4_1 struct nfs_inode *nfsi =NFS_I (state->inode); -if (has_layout (nfsi) && nfsi->layout.roc_iomode) { +if (has_layout (nfsi) && nfsi->layout->roc_iomode) {struct nfs4_pnfs_layout_segment range; - range.iomode = nfsi->layout.roc_iomode; + range.iomode = nfsi->layout->roc_iomode; range.offset =0 ; range.length =NFS4_MAX_UINT64 ; pnfs_return_layout(state->inode, &range, NULL,fs/nfs/pnfs.c +0
-0fs/nfs/pnfs.c pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) · line 156
Quoted 7 lines
fs/nfs/pnfs.c +2
-2@@ -152,10 +152,11 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) {dprintk ("%s: has_layout=%d ctx=%p\n" , __func__,has_layout (nfsi), ctx);spin_lock (&nfsi->vfs_inode.i_lock); -if (has_layout (nfsi) && !layoutcommit_needed (nfsi)) { - nfsi->layout.lo_cred =get_rpccred (ctx->state->owner->so_cred); +if (has_layout (nfsi) && ! + !test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state)) {Is the "!!" intended
Why did you open code
layoutcommit_needed()?Quoted 121 lines
fs/nfs/pnfs.c +29
-27+ nfsi->layout->lo_cred =get_rpccred (ctx->state->owner->so_cred);__set_bit (NFS_INO_LAYOUTCOMMIT , - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->change_attr++;spin_unlock (&nfsi->vfs_inode.i_lock);dprintk ("%s: Set layoutcommit\n" , __func__);@@ -175,17 +176,17 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)loff_t end_pos;spin_lock (&nfsi->vfs_inode.i_lock); -if (offset < nfsi->layout.pnfs_write_begin_pos) - nfsi->layout.pnfs_write_begin_pos = offset; +if (offset < nfsi->layout->pnfs_write_begin_pos) + nfsi->layout->pnfs_write_begin_pos = offset; end_pos = offset + extent -1 ;/* I'm being inclusive */ -if (end_pos > nfsi->layout.pnfs_write_end_pos) - nfsi->layout.pnfs_write_end_pos = end_pos; +if (end_pos > nfsi->layout->pnfs_write_end_pos) + nfsi->layout->pnfs_write_end_pos = end_pos;dprintk ("%s: Wrote %lu@%lu bpos %lu, epos: %lu\n" , __func__, (unsigned long ) extent, (unsigned long ) offset , - (unsigned long ) nfsi->layout.pnfs_write_begin_pos, - (unsigned long ) nfsi->layout.pnfs_write_end_pos); + (unsigned long ) nfsi->layout->pnfs_write_begin_pos, + (unsigned long ) nfsi->layout->pnfs_write_end_pos);spin_unlock (&nfsi->vfs_inode.i_lock); }@@ -326,10 +327,9 @@ get_layout(struct pnfs_layout_type *lo)static inline struct pnfs_layout_type *grab_current_layout (struct nfs_inode *nfsi) { -struct pnfs_layout_type *lo = &nfsi->layout; +struct pnfs_layout_type *lo = nfsi->layout; -BUG_ON_UNLOCKED_LO (lo); -if (!lo->ld_data) +if (!lo)return NULL ;get_layout (lo);return lo;@@ -343,13 +343,13 @@ put_layout(struct pnfs_layout_type *lo) lo->refcount--;if (!lo->refcount) { -struct layoutdriver_io_operations *io_ops = -PNFS_LD_IO_OPS (lo); +struct layoutdriver_io_operations *io_ops =PNFS_LD_IO_OPS (lo); +struct nfs_inode *nfsi =PNFS_NFS_INODE (lo); -dprintk ("%s: freeing layout %p\n" , __func__, lo->ld_data); +dprintk ("%s: freeing layout cache %p\n" , __func__, lo);WARN_ON (!list_empty (&lo->lo_layouts)); - io_ops->free_layout (lo->ld_data); - lo->ld_data =NULL ; + io_ops->free_layout (lo); + nfsi->layout =NULL ; } }@@ -381,14 +381,13 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) lo =grab_current_layout (nfsi);if (lo) {pnfs_free_layout (lo, &range); -WARN_ON (!list_empty (&nfsi->layout.segs)); -WARN_ON (!list_empty (&nfsi->layout.lo_layouts)); -WARN_ON (nfsi->layout.ld_data); +WARN_ON (!list_empty (&nfsi->layout->segs)); +WARN_ON (!list_empty (&nfsi->layout->lo_layouts)); -if (nfsi->layout.refcount !=1 ) +if (nfsi->layout->refcount !=1 )printk (KERN_WARNING "%s: layout refcount not=1 %d\n" , - __func__, nfsi->layout.refcount); -WARN_ON (nfsi->layout.refcount !=1 ); + __func__, nfsi->layout->refcount); +WARN_ON (nfsi->layout->refcount !=1 );put_layout (lo); }@@ -698,7 +697,7 @@ pnfs_return_layout_barrier(struct nfs_inode *nfsi,bool ret = false;spin_lock (&nfsi->vfs_inode.i_lock); - list_for_each_entry (lseg, &nfsi->layout.segs, fi_list) { +list_for_each_entry (lseg, &nfsi->layout->segs, fi_list) {if (!should_free_lseg (lseg, range))continue ; lseg->valid = false;@@ -904,29 +903,33 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,dprintk ("%s:Return\n" , __func__); } +/* +* Each layoutdriver embeds pnfs_layout_type as the first field in it's +* per-layout type layout cache structure and returns it ZEROed +* from layoutdriver_io_ops->alloc_layout +*/ static struct pnfs_layout_type *alloc_init_layout (struct inode *ino) { -void *ld_data;struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; +BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; - lo = &NFS_I (ino)->layout; - ld_data = io_ops->alloc_layout (ino); -if (!ld_data) { + lo = io_ops->alloc_layout (ino); +if (!lo) {printk (KERN_ERR "%s: out of memory: io_ops->alloc_layout failed\n" , __func__);return NULL ; } -fs/nfs/pnfs.c pnfs_insert_layout(struct pnfs_layout_type *lo, · line 931
Quoted 10 lines
fs/nfs/pnfs.c +4
-4spin_lock (&ino->i_lock); -BUG_ON (lo->ld_data !=NULL ); - lo->ld_data = ld_data; -memset (&lo->stateid,0 ,NFS4_STATEID_SIZE ); lo->refcount =1 ; - lo->roc_iomode =0 ; +INIT_LIST_HEAD (&lo->lo_layouts); +INIT_LIST_HEAD (&lo->segs); +seqlock_init (&lo->seqlock); + lo->lo_inode = ino;The
spin_lock()could be moved to here, it's the single place that actually touches the nfsi.Quoted 165 lines
fs/nfs/pnfs.c +22
-21+NFS_I (ino)->layout = lo;spin_unlock (&ino->i_lock);return lo; }@@ -961,7 +964,7 @@ get_lock_alloc_layout(struct inode *ino)* wait until bit is cleared if we lost this race. */ res =wait_on_bit_lock ( - &nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC , pnfs_wait_schedule,TASK_KILLABLE );if (res) {@@ -972,7 +975,7 @@ get_lock_alloc_layout(struct inode *ino)/* Was current_layout already allocated while we slept? * If so, retry get_lock'ing it. Otherwise, allocate it. */ -if (nfsi->layout.ld_data) { +if (nfsi->layout) {spin_lock (&ino->i_lock);continue ; }@@ -985,8 +988,8 @@ get_lock_alloc_layout(struct inode *ino)/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout.pnfs_layout_state); -wake_up_bit (&nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state); +wake_up_bit (&nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC );break ; }@@ -1113,12 +1116,12 @@ _pnfs_update_layout(struct inode *ino, }/* if get layout already failed once goto out */ -if (test_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state)) { +if (test_bit (lo_fail_bit (iomode), &nfsi->layout->pnfs_layout_state)) {if (unlikely (nfsi->pnfs_layout_suspend &&get_seconds () >= nfsi->pnfs_layout_suspend)) {dprintk ("%s: layout_get resumed\n" , __func__);clear_bit (lo_fail_bit (iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->pnfs_layout_suspend =0 ; }else goto out_put;@@ -1130,7 +1133,7 @@ _pnfs_update_layout(struct inode *ino,send_layoutget (ino, ctx, &arg, lsegpp, lo); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, - nfsi->layout.pnfs_layout_state, lseg); + nfsi->layout->pnfs_layout_state, lseg);return ; out_put:if (lsegpp)@@ -1235,12 +1238,12 @@ pnfs_get_layout_done(struct nfs4_pnfs_layoutget *lgp, int rpc_status)/* remember that get layout failed and suspend trying */ nfsi->pnfs_layout_suspend = suspend;set_bit (lo_fail_bit (lgp->args.lseg.iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state);dprintk ("%s: layout_get suspended until %ld\n" , __func__, suspend); out:dprintk ("%s end (err:%d) state 0x%lx lseg %p\n" , - __func__, lgp->status, nfsi->layout.pnfs_layout_state, lseg); + __func__, lgp->status, nfsi->layout->pnfs_layout_state, lseg);return ; }@@ -1321,7 +1324,7 @@ pnfs_set_pg_test(struct inode *inode, struct nfs_pageio_descriptor *pgio) pgio->pg_test =NULL ; - laytype = &NFS_I (inode)->layout; + laytype =NFS_I (inode)->layout; ld =NFS_SERVER (inode)->pnfs_curr_ld;if (!pnfs_enabled_sb (NFS_SERVER (inode)) || !laytype)return ;@@ -1454,7 +1457,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) numpages); wdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1507,7 +1510,7 @@ pnfs_readpages(struct nfs_read_data *rdata) __func__, numpages); rdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1568,7 +1571,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)* This will be done by passing the buck to the layout driver. */ data->pdata.lseg =NULL ; - trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (&nfsi->layout, + trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (nfsi->layout, sync, data);dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs);return trypnfs;@@ -1639,14 +1642,14 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)/* Clear layoutcommit properties in the inode so * new lc info can be generated */ - write_begin_pos = nfsi->layout.pnfs_write_begin_pos; - write_end_pos = nfsi->layout.pnfs_write_end_pos; - data->cred = nfsi->layout.lo_cred; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; - nfsi->layout.lo_cred =NULL ; -__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); -pnfs_get_layout_stateid (&data->args.stateid, &nfsi->layout); + write_begin_pos = nfsi->layout->pnfs_write_begin_pos; + write_end_pos = nfsi->layout->pnfs_write_end_pos; + data->cred = nfsi->layout->lo_cred; + nfsi->layout->pnfs_write_begin_pos =0 ; + nfsi->layout->pnfs_write_end_pos =0 ; + nfsi->layout->lo_cred =NULL ; +__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state); +pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);spin_unlock (&inode->i_lock);include/linux/nfs4_pnfs.h +2
-8@@ -35,13 +35,13 @@ struct pnfs_layoutdriver_type {static inline struct nfs_inode *PNFS_NFS_INODE (struct pnfs_layout_type *lo) { - return container_of(lo, struct nfs_inode, layout); +return NFS_I (lo->lo_inode); }static inline struct inode *PNFS_INODE (struct pnfs_layout_type *lo) { -return &PNFS_NFS_INODE (lo)->vfs_inode; +return lo->lo_inode; } static inline struct nfs_server *@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)return NFS_SERVER (PNFS_INODE (lo)); } -static inline void * -PNFS_LD_DATA (struct pnfs_layout_type *lo) -{ -return lo->ld_data; -} -static inline struct pnfs_layoutdriver_type *PNFS_LD (struct pnfs_layout_type *lo) {include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 74
Quoted 5 lines
include/linux/nfs4_pnfs.h +1
-1@@ -77,13 +71,14 @@ PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo)static inline bool has_layout (struct nfs_inode *nfsi) { -return nfsi->layout.ld_data !=NULL ; +return nfsi->layout !=NULL ;does this mean the same thing now?
Quoted 6 lines
Quoted 3 lines
You could perhaps optimize with a bit flag that is set on first segment insert, and reset on last segment removal. Or some other/better scheme.
We may want to have
has_layout()as well ashas_layout_segs()which will check that the lsegs list is not empty.
Won't be necessary when we initialize the layout when the segs list is empty.
-->Andy
Quoted 67 lines
Benny
Quoted 48 lines
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 81
Quoted 9 lines
include/linux/nfs4_pnfs.h +2
-1}static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);What is the purpose of patch[1/1] ?
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
Quoted 33 lines
include/linux/nfs4_pnfs.h +2
-2}#else /* CONFIG_NFS_V4_1 */ @@ -149,8 +144,8 @@ struct layoutdriver_io_operations {/* Layout information. For each inode, alloc_layout is executed once to retrieve an * inode specific layout structure. Each subsequent layoutget operation results in * a set_layout call to set the opaque layout in the layout driver.*/ -void * (*alloc_layout) (struct inode *inode); -void (*free_layout) (void *layoutid); +struct pnfs_layout_type * (*alloc_layout) (struct inode *inode); +void (*free_layout) (struct pnfs_layout_type *);struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid,struct nfs4_pnfs_layoutget_res *lgr);void (*free_lseg) (struct pnfs_layout_segment *lseg);include/linux/nfs_fs.h +1
-1@@ -104,7 +104,6 @@ struct pnfs_layout_type {int roc_iomode;/* iomode to return on close, 0=none */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -void *ld_data;/* layout driver private data */ unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ @@ -116,6 +115,7 @@ struct pnfs_layout_type {*/ loff_t pnfs_write_begin_pos;loff_t pnfs_write_end_pos; +struct inode *lo_inode; };Quoted 11 lines
include/linux/nfs_fs.h struct nfs_inode { · line 212
Quoted 10 lines
include/linux/nfs_fs.h +1
-1/* @@ -206,7 +206,7 @@ struct nfs_inode {/* pNFS layout information */ #if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq; -struct pnfs_layout_type layout; +struct pnfs_layout_type *layout;time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/ --
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 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
In reply to Boaz HarroshQuoted 95 lines · Boaz Harrosh
Quoted 94 lines · On 07/08/2010 01:34 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Change
nfs_inodelayout field to a pointerEach layoutdriver embeds the
pnfs_layout_typein it's private layout cache head structure, and allocates them both with thealloc_layoutlayoutdriver_io_operation.NOTE API change: the
layoutdriver_io_operationalloc_layoutandfree_layoutnow usepnfs_layout_typepointers instead of void*.Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/callback_proc.c | 2 +- fs/nfs/inode.c | 12 +----- fs/nfs/nfs4proc.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 111 +++++++++++++++++++++++---------------------- include/linux/nfs4_pnfs.h | 19 +++----- include/linux/nfs_fs.h | 4 +- 7 files changed, 71 insertions(+), 83 deletions(-)fs/nfs/callback_proc.c +1
-1@@ -233,7 +233,7 @@ static int pnfs_recall_layout(void *data) rl.cbl_seg.length =NFS4_MAX_UINT64 ;if (rl.cbl_recall_type ==RETURN_FILE ) { -if (pnfs_is_next_layout_stateid (&NFS_I (inode)->layout, +if (pnfs_is_next_layout_stateid (NFS_I (inode)->layout, rl.cbl_stateid)) status = pnfs_return_layout(inode, &rl.cbl_seg, &rl.cbl_stateid, RETURN_FILE,fs/nfs/inode.c +1
-11@@ -1397,17 +1397,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)#ifdef CONFIG_NFS_V4_1 init_waitqueue_head (&nfsi->lo_waitq); nfsi->pnfs_layout_suspend =0 ; -seqlock_init (&nfsi->layout.seqlock); -INIT_LIST_HEAD (&nfsi->layout.lo_layouts); -INIT_LIST_HEAD (&nfsi->layout.segs); - nfsi->layout.refcount =0 ; - nfsi->layout.ld_data =NULL ; - nfsi->layout.pnfs_layout_state =0 ; -memset (&nfsi->layout.stateid,0 ,NFS4_STATEID_SIZE ); - nfsi->layout.roc_iomode =0 ; - nfsi->layout.lo_cred =NULL ; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; + nfsi->layout =NULL ;#endif /* CONFIG_NFS_V4_1 */ #endif }fs/nfs/nfs4proc.c +1
-1@@ -1086,7 +1086,7 @@ static void pnfs4_layout_reclaim(struct nfs4_state *state)* flag during grace period */ pnfs_destroy_layout (NFS_I (state->inode)); -pnfs_set_layout_stateid (&NFS_I (state->inode)->layout, &zero_stateid); +pnfs_set_layout_stateid (NFS_I (state->inode)->layout, &zero_stateid);#endif /* CONFIG_NFS_V4_1 */ }fs/nfs/nfs4state.c +2
-2@@ -597,10 +597,10 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,#ifdef CONFIG_NFS_V4_1 struct nfs_inode *nfsi =NFS_I (state->inode); -if (has_layout (nfsi) && nfsi->layout.roc_iomode) { +if (has_layout (nfsi) && nfsi->layout->roc_iomode) {struct nfs4_pnfs_layout_segment range; - range.iomode = nfsi->layout.roc_iomode; + range.iomode = nfsi->layout->roc_iomode; range.offset =0 ; range.length =NFS4_MAX_UINT64 ; pnfs_return_layout(state->inode, &range, NULL,fs/nfs/pnfs.c +0
-0@@ -152,10 +152,11 @@ pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) {
Quoted 8 lines
fs/nfs/pnfs.c pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx) · line 156
Quoted 6 lines
fs/nfs/pnfs.c +2
-2dprintk ("%s: has_layout=%d ctx=%p\n" , __func__,has_layout (nfsi), ctx);spin_lock (&nfsi->vfs_inode.i_lock); -if (has_layout (nfsi) && !layoutcommit_needed (nfsi)) { - nfsi->layout.lo_cred =get_rpccred (ctx->state->owner->so_cred); +if (has_layout (nfsi) && ! + !test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state)) {Is the "!!" intended
No! :)
Quoted 2 lines
Why did you open code
layoutcommit_needed()?
Because I added a has_layout test to the layoutcommit_needed, and so can't use !layoutcommit_needed.
Quoted 128 lines
Quoted 128 lines
fs/nfs/pnfs.c +29
-31+ nfsi->layout->lo_cred =get_rpccred (ctx->state->owner->so_cred);__set_bit (NFS_INO_LAYOUTCOMMIT , - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->change_attr++;spin_unlock (&nfsi->vfs_inode.i_lock);dprintk ("%s: Set layoutcommit\n" , __func__);@@ -175,17 +176,17 @@ pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent)loff_t end_pos;spin_lock (&nfsi->vfs_inode.i_lock); -if (offset < nfsi->layout.pnfs_write_begin_pos) - nfsi->layout.pnfs_write_begin_pos = offset; +if (offset < nfsi->layout->pnfs_write_begin_pos) + nfsi->layout->pnfs_write_begin_pos = offset; end_pos = offset + extent -1 ;/* I'm being inclusive */ -if (end_pos > nfsi->layout.pnfs_write_end_pos) - nfsi->layout.pnfs_write_end_pos = end_pos; +if (end_pos > nfsi->layout->pnfs_write_end_pos) + nfsi->layout->pnfs_write_end_pos = end_pos;dprintk ("%s: Wrote %lu@%lu bpos %lu, epos: %lu\n" , __func__, (unsigned long ) extent, (unsigned long ) offset , - (unsigned long ) nfsi->layout.pnfs_write_begin_pos, - (unsigned long ) nfsi->layout.pnfs_write_end_pos); + (unsigned long ) nfsi->layout->pnfs_write_begin_pos, + (unsigned long ) nfsi->layout->pnfs_write_end_pos);spin_unlock (&nfsi->vfs_inode.i_lock); }@@ -326,10 +327,9 @@ get_layout(struct pnfs_layout_type *lo)static inline struct pnfs_layout_type *grab_current_layout (struct nfs_inode *nfsi) { -struct pnfs_layout_type *lo = &nfsi->layout; +struct pnfs_layout_type *lo = nfsi->layout; -BUG_ON_UNLOCKED_LO (lo); -if (!lo->ld_data) +if (!lo)return NULL ;get_layout (lo);return lo;@@ -343,13 +343,13 @@ put_layout(struct pnfs_layout_type *lo) lo->refcount--;if (!lo->refcount) { -struct layoutdriver_io_operations *io_ops = -PNFS_LD_IO_OPS (lo); +struct layoutdriver_io_operations *io_ops =PNFS_LD_IO_OPS (lo); +struct nfs_inode *nfsi =PNFS_NFS_INODE (lo); -dprintk ("%s: freeing layout %p\n" , __func__, lo->ld_data); +dprintk ("%s: freeing layout cache %p\n" , __func__, lo);WARN_ON (!list_empty (&lo->lo_layouts)); - io_ops->free_layout (lo->ld_data); - lo->ld_data =NULL ; + io_ops->free_layout (lo); + nfsi->layout =NULL ; } }@@ -381,14 +381,13 @@ pnfs_destroy_layout(struct nfs_inode *nfsi) lo =grab_current_layout (nfsi);if (lo) {pnfs_free_layout (lo, &range); -WARN_ON (!list_empty (&nfsi->layout.segs)); -WARN_ON (!list_empty (&nfsi->layout.lo_layouts)); -WARN_ON (nfsi->layout.ld_data); +WARN_ON (!list_empty (&nfsi->layout->segs)); +WARN_ON (!list_empty (&nfsi->layout->lo_layouts)); -if (nfsi->layout.refcount !=1 ) +if (nfsi->layout->refcount !=1 )printk (KERN_WARNING "%s: layout refcount not=1 %d\n" , - __func__, nfsi->layout.refcount); -WARN_ON (nfsi->layout.refcount !=1 ); + __func__, nfsi->layout->refcount); +WARN_ON (nfsi->layout->refcount !=1 );put_layout (lo); }@@ -698,7 +697,7 @@ pnfs_return_layout_barrier(struct nfs_inode *nfsi,bool ret = false;spin_lock (&nfsi->vfs_inode.i_lock); - list_for_each_entry (lseg, &nfsi->layout.segs, fi_list) { +list_for_each_entry (lseg, &nfsi->layout->segs, fi_list) {if (!should_free_lseg (lseg, range))continue ; lseg->valid = false;@@ -904,29 +903,33 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,dprintk ("%s:Return\n" , __func__); } +/* +* Each layoutdriver embeds pnfs_layout_type as the first field in it's +* per-layout type layout cache structure and returns it ZEROed +* from layoutdriver_io_ops->alloc_layout +*/ static struct pnfs_layout_type *alloc_init_layout (struct inode *ino) { -void *ld_data;struct pnfs_layout_type *lo;struct layoutdriver_io_operations *io_ops; +BUG_ON (NFS_I (ino)->layout !=NULL ); io_ops =NFS_SERVER (ino)->pnfs_curr_ld->ld_io_ops; - lo = &NFS_I (ino)->layout; - ld_data = io_ops->alloc_layout (ino); -if (!ld_data) { + lo = io_ops->alloc_layout (ino); +if (!lo) {printk (KERN_ERR "%s: out of memory: io_ops->alloc_layout failed\n" , __func__);return NULL ; } -spin_lock (&ino->i_lock); -BUG_ON (lo->ld_data !=NULL ); - lo->ld_data = ld_data; -memset (&lo->stateid,0 ,NFS4_STATEID_SIZE ); lo->refcount =1 ; - lo->roc_iomode =0 ;
Quoted 8 lines
fs/nfs/pnfs.c pnfs_insert_layout(struct pnfs_layout_type *lo, · line 931
Quoted 4 lines
fs/nfs/pnfs.c +4
-0+INIT_LIST_HEAD (&lo->lo_layouts); +INIT_LIST_HEAD (&lo->segs); +seqlock_init (&lo->seqlock); + lo->lo_inode = ino;The
spin_lock()could be moved to here, it's the single place that actually touches the nfsi.
True, but it gets moved in 'pnfs-submti rewrite layout allocation"
Quoted 165 lines
Quoted 165 lines
fs/nfs/pnfs.c +22
-21+NFS_I (ino)->layout = lo;spin_unlock (&ino->i_lock);return lo; }@@ -961,7 +964,7 @@ get_lock_alloc_layout(struct inode *ino)* wait until bit is cleared if we lost this race. */ res =wait_on_bit_lock ( - &nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC , pnfs_wait_schedule,TASK_KILLABLE );if (res) {@@ -972,7 +975,7 @@ get_lock_alloc_layout(struct inode *ino)/* Was current_layout already allocated while we slept? * If so, retry get_lock'ing it. Otherwise, allocate it. */ -if (nfsi->layout.ld_data) { +if (nfsi->layout) {spin_lock (&ino->i_lock);continue ; }@@ -985,8 +988,8 @@ get_lock_alloc_layout(struct inode *ino)/* release the NFS_INO_LAYOUT_ALLOC bit and wake up waiters */ clear_bit_unlock (NFS_INO_LAYOUT_ALLOC , - &nfsi->layout.pnfs_layout_state); -wake_up_bit (&nfsi->layout.pnfs_layout_state, + &nfsi->layout->pnfs_layout_state); +wake_up_bit (&nfsi->layout->pnfs_layout_state,NFS_INO_LAYOUT_ALLOC );break ; }@@ -1113,12 +1116,12 @@ _pnfs_update_layout(struct inode *ino, }/* if get layout already failed once goto out */ -if (test_bit (lo_fail_bit (iomode), &nfsi->layout.pnfs_layout_state)) { +if (test_bit (lo_fail_bit (iomode), &nfsi->layout->pnfs_layout_state)) {if (unlikely (nfsi->pnfs_layout_suspend &&get_seconds () >= nfsi->pnfs_layout_suspend)) {dprintk ("%s: layout_get resumed\n" , __func__);clear_bit (lo_fail_bit (iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state); nfsi->pnfs_layout_suspend =0 ; }else goto out_put;@@ -1130,7 +1133,7 @@ _pnfs_update_layout(struct inode *ino,send_layoutget (ino, ctx, &arg, lsegpp, lo); out:dprintk ("%s end, state 0x%lx lseg %p\n" , __func__, - nfsi->layout.pnfs_layout_state, lseg); + nfsi->layout->pnfs_layout_state, lseg);return ; out_put:if (lsegpp)@@ -1235,12 +1238,12 @@ pnfs_get_layout_done(struct nfs4_pnfs_layoutget *lgp, int rpc_status)/* remember that get layout failed and suspend trying */ nfsi->pnfs_layout_suspend = suspend;set_bit (lo_fail_bit (lgp->args.lseg.iomode), - &nfsi->layout.pnfs_layout_state); + &nfsi->layout->pnfs_layout_state);dprintk ("%s: layout_get suspended until %ld\n" , __func__, suspend); out:dprintk ("%s end (err:%d) state 0x%lx lseg %p\n" , - __func__, lgp->status, nfsi->layout.pnfs_layout_state, lseg); + __func__, lgp->status, nfsi->layout->pnfs_layout_state, lseg);return ; }@@ -1321,7 +1324,7 @@ pnfs_set_pg_test(struct inode *inode, struct nfs_pageio_descriptor *pgio) pgio->pg_test =NULL ; - laytype = &NFS_I (inode)->layout; + laytype =NFS_I (inode)->layout; ld =NFS_SERVER (inode)->pnfs_curr_ld;if (!pnfs_enabled_sb (NFS_SERVER (inode)) || !laytype)return ;@@ -1454,7 +1457,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) numpages); wdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1507,7 +1510,7 @@ pnfs_readpages(struct nfs_read_data *rdata) __func__, numpages); rdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist( - &nfsi->layout, + nfsi->layout, args->pages, args->pgbase, numpages,@@ -1568,7 +1571,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)* This will be done by passing the buck to the layout driver. */ data->pdata.lseg =NULL ; - trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (&nfsi->layout, + trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (nfsi->layout, sync, data);dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs);return trypnfs;@@ -1639,14 +1642,14 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync)/* Clear layoutcommit properties in the inode so * new lc info can be generated */ - write_begin_pos = nfsi->layout.pnfs_write_begin_pos; - write_end_pos = nfsi->layout.pnfs_write_end_pos; - data->cred = nfsi->layout.lo_cred; - nfsi->layout.pnfs_write_begin_pos =0 ; - nfsi->layout.pnfs_write_end_pos =0 ; - nfsi->layout.lo_cred =NULL ; -__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); -pnfs_get_layout_stateid (&data->args.stateid, &nfsi->layout); + write_begin_pos = nfsi->layout->pnfs_write_begin_pos; + write_end_pos = nfsi->layout->pnfs_write_end_pos; + data->cred = nfsi->layout->lo_cred; + nfsi->layout->pnfs_write_begin_pos =0 ; + nfsi->layout->pnfs_write_end_pos =0 ; + nfsi->layout->lo_cred =NULL ; +__clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state); +pnfs_get_layout_stateid (&data->args.stateid, nfsi->layout);spin_unlock (&inode->i_lock);include/linux/nfs4_pnfs.h +2
-8@@ -35,13 +35,13 @@ struct pnfs_layoutdriver_type {static inline struct nfs_inode *PNFS_NFS_INODE (struct pnfs_layout_type *lo) { - return container_of(lo, struct nfs_inode, layout); +return NFS_I (lo->lo_inode); }static inline struct inode *PNFS_INODE (struct pnfs_layout_type *lo) { -return &PNFS_NFS_INODE (lo)->vfs_inode; +return lo->lo_inode; } static inline struct nfs_server *@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)return NFS_SERVER (PNFS_INODE (lo)); } -static inline void * -PNFS_LD_DATA (struct pnfs_layout_type *lo) -{ -return lo->ld_data; -} -static inline struct pnfs_layoutdriver_type *PNFS_LD (struct pnfs_layout_type *lo) {
Quoted 8 lines
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 74
Quoted 6 lines
include/linux/nfs4_pnfs.h +1
-1@@ -77,13 +71,14 @@ PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo)static inline bool has_layout (struct nfs_inode *nfsi) { -return nfsi->layout.ld_data !=NULL ; +return nfsi->layout !=NULL ;does this mean the same thing now?
Yes, the pnfs_layout_type and the ld_data are allocated together.
Quoted 4 lines
You could perhaps optimize with a bit flag that is set on first segment insert, and reset on last segment removal. Or some other/better scheme.
Are you suggesting adding a bit flag to nfs_inode, or perhaps moving the pnfs_layout_state back to the nfs_inode?
Quoted 11 lines
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 81
Quoted 9 lines
include/linux/nfs4_pnfs.h +2
-1}static inline bool layoutcommit_needed (struct nfs_inode *nfsi) { -return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);What is the purpose of patch[1/1] ?
To not segfault when the nfs_inode->layout field is NULL.
Quoted 3 lines
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
No, it simply has not been allocated. The pnfs_layout_type reference counting will be done under the inode->i_lock and all in-flight RPC's will hold a reference, so there is no reason to hold a lock to call has_layout().
-->Andy
Quoted 50 lines
Quoted 36 lines
include/linux/nfs4_pnfs.h +2
-2}#else /* CONFIG_NFS_V4_1 */ @@ -149,8 +144,8 @@ struct layoutdriver_io_operations {/* Layout information. For each inode, alloc_layout is executed once to retrieve an * inode specific layout structure. Each subsequent layoutget operation results in * a set_layout call to set the opaque layout in the layout driver.*/ -void * (*alloc_layout) (struct inode *inode); -void (*free_layout) (void *layoutid); +struct pnfs_layout_type * (*alloc_layout) (struct inode *inode); +void (*free_layout) (struct pnfs_layout_type *);struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid,struct nfs4_pnfs_layoutget_res *lgr);void (*free_lseg) (struct pnfs_layout_segment *lseg);include/linux/nfs_fs.h +1
-1@@ -104,7 +104,6 @@ struct pnfs_layout_type {int roc_iomode;/* iomode to return on close, 0=none */ seqlock_t seqlock;/* Protects the stateid */ nfs4_stateid stateid; -void *ld_data;/* layout driver private data */ unsigned long pnfs_layout_state;#define NFS_INO_RO_LAYOUT_FAILED 0/* get ro layout failed stop trying */ #define NFS_INO_RW_LAYOUT_FAILED 1/* get rw layout failed stop trying */ @@ -116,6 +115,7 @@ struct pnfs_layout_type {*/ loff_t pnfs_write_begin_pos;loff_t pnfs_write_end_pos; +struct inode *lo_inode; };/* include/linux/nfs_fs.h struct nfs_inode { · line 212
Quoted 8 lines
include/linux/nfs_fs.h +1
-1@@ -206,7 +206,7 @@ struct nfs_inode {/* pNFS layout information */ #if defined(CONFIG_NFS_V4_1 )wait_queue_head_t lo_waitq; -struct pnfs_layout_type layout; +struct pnfs_layout_type *layout;time_t pnfs_layout_suspend;#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4*/ --
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
A message that is not in the archive (sent off-list or not yet received): AANLkTikTMLQJwj1PeW2Y0dfmRcVFdNr6sasxJtaAiMg4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
Quoted 8 lines · William A. (Andy) Adamson
Quoted 7 lines · Boaz Harrosh
Quoted 6 lines
static inline bool
layoutcommit_needed(struct nfs_inode *nfsi)
{include/linux/nfs4_pnfs.h +2
-1-return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);
Quoted 4 lines
Quoted 1 line
What is the purpose of patch[1/1] ?
To not segfault when the
nfs_inode->layoutfield is NULL.
Yes that is this patch [3/16].
I was asking about [PATCH 01/16] that changed it to a state_bit from lo_cred why do we need that one. Now that you proved that has_layout(nfsi) cannot become negative on us while asking?
Quoted 9 lines
Quoted 3 lines
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
No, it simply has not been allocated. The
pnfs_layout_typereference counting will be done under theinode->i_lockand all in-flight RPC's will hold a reference, so there is no reason to hold a lock to callhas_layout().
I agree it is safe.
Boaz
Quoted 2 lines
-->Andy
Re: [PATCH 03/16] SQUASHME pnfs-submit embed pnfs_layout_type
Quoted 11 lines · Boaz Harrosh
Quoted 10 lines · William A. (Andy) Adamson
Quoted 8 lines · Boaz Harrosh
include/linux/nfs4_pnfs.h PNFS_LD_POLICY_OPS(struct pnfs_layout_type *lo) · line 81
Quoted 6 lines
static inline bool
layoutcommit_needed(struct nfs_inode *nfsi)
{include/linux/nfs4_pnfs.h +2
-1-return test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout.pnfs_layout_state); +return has_layout (nfsi) && +test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->layout->pnfs_layout_state);What is the purpose of patch[1/1] ?
Quoted 8 lines
Quoted 2 lines
To not segfault when the
nfs_inode->layoutfield is NULL.Yes that is this patch [3/16].
I was asking about [PATCH 01/16] that changed it to a
state_bitfromlo_credwhy do we need that one. Now that you proved thathas_layout(nfsi)cannot become negative on us while asking?
Hmm. Looks like you're right, it's not needed. We do need to document that the existance of the lo_cred is what signals the need for layout commit.....
Thanks
-->Andy
Quoted 18 lines
Quoted 10 lines
Quoted 4 lines
you are unlocked and asking about a layout pointer. Which according to you might go away mid-flight?
No, it simply has not been allocated. The
pnfs_layout_typereference counting will be done under theinode->i_lockand all in-flight RPC's will hold a reference, so there is no reason to hold a lock to callhas_layout().I agree it is safe.
Boaz
Quoted 2 lines
-->Andy
Quoted 19 lines
-----Original Message-----
From: [email protected] [mailto:linux-nfs- [email protected]] On Behalf Of [email protected]
Sent: Wednesday, July 07, 2010 3:34 PM
To: [email protected]
Cc: [email protected]
Subject: [PATCH 0/16] pnfs-submit fix layout allocation and reference countingThe current
nfs_inodehas an embeddedpnfs_layout_typestructure, with per layout type private data allocated. Changenfs_inode->layoutto be a pointer
to apnfs_layout_typestructure, embed thepnfs_layout_typein the per layout type structure, and allocate both.
Quoted 8 lines
The current
pnfs_layout_typeallocation waits on a bit lock to handle concurrent allocation attempts. Replace this with the normal form.The current
pnfs_layout_typereference counting is very un-clear, and one instance ofput_layoutwas called outside thei_lockwhich probably was causing the intermittantpnfs_layout_typerefcount bug we've been seeing.Replace the
nfs_inode->layoutreference counting with the following scheme:
I am a newbee and would appreciate a little enlightenment:
I read an article from a few years ago that stated 'The "kobject" structure first made its appearance in the 2.5.45 development kernel. It was initially meant as a simple way of unifying kernel code which manages reference counted objects.'
It seems from my naïve viewpoint that a "kobject" might be used here. Why not? Does it have something to do with the "mission creep" mentioned in the article?
Thanks for your patients.
-=# Paul Gilliam #=-
On 07/08/2010 01:34 AM, [email protected] wrote:
Hi Andy,
Quoted 5 lines
The current
nfs_inodehas an embeddedpnfs_layout_typestructure, with per layout type private data allocated. Changenfs_inode->layoutto be a pointer to apnfs_layout_typestructure, embed thepnfs_layout_typein the per layout type structure, and allocate both.
Amen
Quoted 3 lines
The current
pnfs_layout_typeallocation waits on a bit lock to handle concurrent allocation attempts. Replace this with the normal form.
Why don't we allocate this at inode allocation. Or inode iget() once and be done with it. Why the fights, races, and error handling? In a normal pnfs-able mount five-9(s) percent of IO operations need a layout_type structure. Let's optimize the fast path. On these rare "error" cases when we could not get any lsegs and eventually did not use the nfsi->layout, who cares that we allocated extra 20 bytes.
Quoted 4 lines
The current
pnfs_layout_typereference counting is very un-clear, and one instance ofput_layoutwas called outside thei_lockwhich probably was causing the intermittantpnfs_layout_typerefcount bug we've been seeing.
Quoted 8 lines
Replace the
nfs_inode->layoutreference counting with the following scheme:As in the current code, the
pnfs_layout_typereference counting is always done with theinode->i_lockheld.The
nfs_inode->layoutcomes into existence when the firstlayout_segmentis cached and stays until inode is destroyed.
I see that you have thought about my proposal. I have not looked at the patches yet, will do soon.
So I have a brave question. If nfs_inode->layout is only freed at inode-destroy, why do we need to ref-count it. Refcounting is for holding things so they don't go away. But since now the nfsi->layout stays until the very end then what's the point?
If you really think it is possible that the layout is held longer then the inode itself then, 1- this is surly a bug, I'm not sure you can do much with a layout with a dangling inode pointer. 2- Fine then just take the inode reference. If you equate the life time of these two objects why not use the ref that is already there?
Quoted 16 lines
1) alloc
nfs_inode->layout:
- Initialized to 1. This holds it around for theclp->cl_layouts(layout->lo_layouts) list.2) Each layoutget
layoutget GET
layoutget release PUT3) insert lseg into
nfs_inode->layout->segsGET
remove lseg fromnfs_inode->layout->segsPUTI/O - no reference (except the lseg is used and referenced in 3)
4) Each layoutcommit references the layout which keeps it around while in use by the call which could race with layoutreturn
Quoted 9 lines
layoutcommit GET
layoutcommit release PUT5) Each layoutreturn references the layout which keeps it around while in use by the call.
layoutreturn GET
layoutreturn release PUT
2, 4, 5 - surly the inode ref-count is taken during RPC? 3 - inode gone while IO? I don't think so.
Quoted 4 lines
6) inode destruction (usually umount)
Destroy_layoutPUT to balance initial allocation where it is set to 1.
inode are destructed when evicted from cache and/or at last reference drop. Also at umount, but you should start testing like I do, "git clone" you'll see inodes start to be destroyed 27 seconds into the operation.
Quoted 3 lines
When the reference moves from 1->0 the layout is removed from the
nfs_clientcl_layoutslist and freed.
The nfs_client->cl_layouts operations can be moved to the first/last lseg insertion/removal, as an optimization step.
Quoted 25 lines
Change
nfs_inode->layoutto be a pointer to apnfs_layout_typestrucure.0001-SQUASHME-pnfs-submit-add-state-flag-for-layoutcommit.patch 0002-SQUASHME-pnfs-submit-move-pnfs_layout_suspend-back-t.patch 0003-SQUASHME-pnfs-submit-embed-pnfs_layout_type.patch 0004-SQUASHME-pnfs-submit-filelayout-use-new-alloc-free_l.patch
Rewrite the
pnfs_layout_typeallocation and reference counting0005-SQUASHME-pnfs-submit-rewrite-layout-allocation.patch 0006-SQUASHME-pnfs-submit-fix-pnfs_update_layout-referenc.patch 0007-SQUASHME-pnfs_submit-don-t-get-a-reference-on-bounda.patch 0008-SQUASHME-pnfs-submit-don-t-reference-the-layout-in-i.patch 0009-SQUASHME-pnfs-submit-pnfs_update_layout-always-refer.patch 0010-SQUASHME-pnfs-submit-reference-the-layout-when-inser.patch 0011-SQUASHME-pnfs-submit-rename-put_layout-to-put_layout.patch 0012-SQUASHME-pnfs-submit-reference-layout-across-layoutc.patch 0013-SQUASHME-pnfs-submit-reference-layout-for-layoutretu.patch 0014-SQUASHME-pnfs-submit-remove-put_layout-from-pnfs_fre.patch 0015-SQUASHME-pnfs-submit-do-not-reference-a-layout-in-de.patch 0016-SQUASHME-pnfs-submit-remove-grab_current_layout.patch
Testing;
Quoted 8 lines
CONFIG_NFS_V4_1set:
Connectathon tests pass against GFS2/pNFS and pyNFS file layout server. Tested with layout return-on-close off and on.
CONFIG_NFS_V4_1not set;
NFSv4.0 mount passes Connectation tests.-->Andy
Thanks Andy for this work. The code is really getting clearer finally.
Boaz
Quoted 10 lines · Boaz Harrosh
On 07/08/2010 01:34 AM, [email protected] wrote:
Hi Andy,
Quoted 5 lines
The current
nfs_inodehas an embeddedpnfs_layout_typestructure, with per layout type private data allocated. Changenfs_inode->layoutto be a pointer to apnfs_layout_typestructure, embed thepnfs_layout_typein the per layout type structure, and allocate both.
Quoted 7 lines
Amen
Quoted 3 lines
The current
pnfs_layout_typeallocation waits on a bit lock to handle concurrent allocation attempts. Replace this with the normal form.Why don't we allocate this at inode allocation.
We don't know if we need it at inode allocation. Remember, GFS2 only uses RO layouts. Plus, the protocol allows a file system to use more than one layout type and each layout type has a different private portion of the layout structure.
Quoted 20 lines
Or inode
iget()once
and be done with it.
Why the fights, races, and error handling?
In a normal pnfs-able mount five-9(s) percent of IO operations need alayout_typestructure. Let's optimize the fast path. On these rare "error" cases when we could not get any lsegs and eventually did not use thenfsi->layout, who cares that we allocated extra 20 bytes.Quoted 11 lines
The current
pnfs_layout_typereference counting is very un-clear, and one instance ofput_layoutwas called outside thei_lockwhich probably was causing the intermittantpnfs_layout_typerefcount bug we've been seeing.Replace the
nfs_inode->layoutreference counting with the following scheme:As in the current code, the
pnfs_layout_typereference counting is always done with theinode->i_lockheld.The
nfs_inode->layoutcomes into existence when the firstlayout_segmentis cached and stays until inode is destroyed.
Actually this is not true. pnfs_destroy_layout is not only called a inode destruction - it is also called in pnfs_reclaim_layout (state reclaim after reboot)
In this case, the layout will be destroyed while the inode continues on.
The use and implementation of pnfs_reclaim_layout needs a review.
The question is, when should the nfs_inode->layout be freed when the inode is not? These are candidates.
- reclaim state after server reboot (current code does this)
- reclaim state after a network partition (current code does this)
- file system migration
- switching to a different file system replica
- CB_LAYOUTRECALL FSID
- CB_LAYOUTRECALL ALL
Quoted 103 lines
Quoted 1 line
I see that you have thought about my proposal. I have not looked at the patches yet, will do soon.
So I have a brave question. If
nfs_inode->layoutis only freed at inode-destroy, why do we need to ref-count it. Refcounting is for holding things so they don't go away. But since now thenfsi->layoutstays until the very end then what's the point?If you really think it is possible that the layout is held longer then the inode itself then, 1- this is surly a bug, I'm not sure you can do much with a layout with a dangling inode pointer. 2- Fine then just take the inode reference. If you equate the life time of these two objects why not use the ref that is already there?
Quoted 16 lines
1) alloc
nfs_inode->layout:
- Initialized to 1. This holds it around for theclp->cl_layouts(layout->lo_layouts) list.2) Each layoutget
layoutget GET
layoutget release PUT3) insert lseg into
nfs_inode->layout->segsGET
remove lseg fromnfs_inode->layout->segsPUTI/O - no reference (except the lseg is used and referenced in 3)
4) Each layoutcommit references the layout which keeps it around while in use by the call which could race with layoutreturn
Quoted 9 lines
layoutcommit GET
layoutcommit release PUT5) Each layoutreturn references the layout which keeps it around while in use by the call.
layoutreturn GET
layoutreturn release PUT2, 4, 5 - surly the inode ref-count is taken during RPC? 3 - inode gone while IO? I don't think so.
Quoted 4 lines
6) inode destruction (usually umount)
Destroy_layout PUT to balance initial allocation where it is set to 1.
inode are destructed when evicted from cache and/or at last reference drop. Also at umount, but you should start testing like I do, "git clone" you'll see inodes start to be destroyed 27 seconds into the operation.
Quoted 3 lines
When the reference moves from 1->0 the layout is removed from the
nfs_clientcl_layoutslist and freed.The
nfs_client->cl_layoutsoperations can be moved to the first/last lseg insertion/removal, as an optimization step.Quoted 25 lines
Change
nfs_inode->layoutto be a pointer to apnfs_layout_typestrucure.0001-SQUASHME-pnfs-submit-add-state-flag-for-layoutcommit.patch 0002-SQUASHME-pnfs-submit-move-pnfs_layout_suspend-back-t.patch 0003-SQUASHME-pnfs-submit-embed-pnfs_layout_type.patch 0004-SQUASHME-pnfs-submit-filelayout-use-new-alloc-free_l.patch
Rewrite the
pnfs_layout_typeallocation and reference counting0005-SQUASHME-pnfs-submit-rewrite-layout-allocation.patch 0006-SQUASHME-pnfs-submit-fix-pnfs_update_layout-referenc.patch 0007-SQUASHME-pnfs_submit-don-t-get-a-reference-on-bounda.patch 0008-SQUASHME-pnfs-submit-don-t-reference-the-layout-in-i.patch 0009-SQUASHME-pnfs-submit-pnfs_update_layout-always-refer.patch 0010-SQUASHME-pnfs-submit-reference-the-layout-when-inser.patch 0011-SQUASHME-pnfs-submit-rename-put_layout-to-put_layout.patch 0012-SQUASHME-pnfs-submit-reference-layout-across-layoutc.patch 0013-SQUASHME-pnfs-submit-reference-layout-for-layoutretu.patch 0014-SQUASHME-pnfs-submit-remove-put_layout-from-pnfs_fre.patch 0015-SQUASHME-pnfs-submit-do-not-reference-a-layout-in-de.patch 0016-SQUASHME-pnfs-submit-remove-grab_current_layout.patch
Testing;
Quoted 8 lines
CONFIG_NFS_V4_1set:
Connectathon tests pass against GFS2/pNFS and pyNFS file layout server. Tested with layout return-on-close off and on.
CONFIG_NFS_V4_1not set;
NFSv4.0 mount passes Connectation tests.-->Andy
Thanks Andy for this work. The code is really getting clearer finally.
Boaz
--
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 7 lines · William A. (Andy) Adamson
Quoted 3 lines · Boaz Harrosh
On 07/08/2010 01:34 AM, [email protected] wrote:
Why don't we allocate this at inode allocation.
We don't know if we need it at inode allocation. Remember, GFS2 only uses RO layouts.
right! optimize for a specific File System (broken at that).
I don't mind if you leave the current code placement and allocate layout_type on first layout-request (first call to _pnfs_update_layout) Then deallocate at inode destruction.
The few places that couple the destruction of all layout segments and return them, with the layout_type structure deallocation should just be de-coupled. Don't mix up between the allocation/deallocation of layout_type and destruction of layout-segments.
Quoted 3 lines
Plus, the protocol allows a file system to use more than one layout type and each layout type has a different private portion of the layout structure.
We don't support that, now, for other reasons. Lets not go there.
Quoted 8 lines
Actually this is not true.
pnfs_destroy_layoutis not only called a inode destruction - it is also called inpnfs_reclaim_layout(state reclaim after reboot)In this case, the layout will be destroyed while the inode continues on.
You mean the layout-segments. But the layout_type can stay, why deallocate it? it will be needed again.
Quoted 11 lines
The use and implementation of
pnfs_reclaim_layoutneeds a review.The question is, when should the
nfs_inode->layoutbe freed when the inode is not? These are candidates.
- reclaim state after server reboot (current code does this)
- reclaim state after a network partition (current code does this)
- file system migration
- switching to a different file system replica
-CB_LAYOUTRECALLFSID
-CB_LAYOUTRECALLALL
None of the above. These are all related to on-the-line layouts which are layout-segments in our code. The governing structure is just an inode-thing/per-layout-type.
If we follow my simple rules then you see that all these run-away pnfs flags and states that where put back into nfsi can return to ->layout.
Boaz