nfs4: serialize layoutcommit
Subsystems (2)
PATCH 1/1 nfs4: serialize layoutcommit
Current pnfs_layoutcommit_inode can not handle parallel layoutcommit. As Trond suggested, there is no need for client to optimize for parallel layoutcommit. The patch add NFS_INO_LAYOUTCOMMITTING flag to mark inflight layoutcommit and serialize lalyoutcommit with it. It also fixes the pls_lc_list corruption that Vitaliy found.
--- fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/pnfs.c | 9 +++++++++ include/linux/nfs_fs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)
fs/nfs/nfs4proc.c +6 -0
@@ -5970,6 +5970,7 @@ static void nfs4_layoutcommit_release(void *calldata) {struct nfs4_layoutcommit_data *data = calldata;struct pnfs_layout_segment *lseg, *tmp; +unsigned long *bitlock = &NFS_I (data->args.inode)->flags;pnfs_cleanup_layoutcommit (data);/* Matched by references in pnfs_set_layoutcommit */
@@ -5979,6 +5980,11 @@ static void nfs4_layoutcommit_release(void *calldata) &lseg->pls_flags))put_lseg (lseg); } + +clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); +put_rpccred (data->cred);kfree (data); }
fs/nfs/pnfs.c +9 -0
@@ -1451,10 +1451,19 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) goto out; } +if (!test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags) || + (status =wait_on_bit_lock (&nfsi->flags,NFS_INO_LAYOUTCOMMITTING , + nfs_wait_bit_killable,TASK_KILLABLE ))) { +kfree (data); + goto out; + } +INIT_LIST_HEAD (&data->lseg_list);spin_lock (&inode->i_lock);if (!test_and_clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags)) { +clear_bit (NFS_INO_LAYOUTCOMMITTING , &nfsi->flags);spin_unlock (&inode->i_lock); +wake_up_bit (&nfsi->flags,NFS_INO_LAYOUTCOMMITTING );kfree (data); goto out; }
include/linux/nfs_fs.h +1 -0
@@ -230,6 +230,7 @@ struct nfs_inode {#define NFS_INO_COMMIT (7)/* inode is committing unstable writes */ #define NFS_INO_PNFS_COMMIT (8)/* use pnfs code for commit */ #define NFS_INO_LAYOUTCOMMIT (9)/* layoutcommit required */ +#define NFS_INO_LAYOUTCOMMITTING (10)/* layoutcommit inflight */ static inline struct nfs_inode *NFS_I (const struct inode *inode) {
Signature · 1 line
1.7.1.262.g5ef3d
Quoted 43 lines · Peng Tao
Current
pnfs_layoutcommit_inodecan not handle parallel layoutcommit. As Trond suggested, there is no need for client to optimize for parallel layoutcommit. The patch addNFS_INO_LAYOUTCOMMITTINGflag to mark inflight layoutcommit and serialize lalyoutcommit with it. It also fixes thepls_lc_listcorruption that Vitaliy found.Reported-by Vitaliy Gusev <[email protected]>Signed-off-by Peng Tao <[email protected]>--- fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/pnfs.c | 9 +++++++++ include/linux/nfs_fs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +6
-0@@ -5970,6 +5970,7 @@ static void nfs4_layoutcommit_release(void *calldata) {struct nfs4_layoutcommit_data *data = calldata;struct pnfs_layout_segment *lseg, *tmp; +unsigned long *bitlock = &NFS_I (data->args.inode)->flags;pnfs_cleanup_layoutcommit (data);/* Matched by references in pnfs_set_layoutcommit */ @@ -5979,6 +5980,11 @@ static void nfs4_layoutcommit_release(void *calldata) &lseg->pls_flags))put_lseg (lseg); } + +clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); +put_rpccred (data->cred);kfree (data); }fs/nfs/pnfs.c +0
-0
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync) · line 1456
Quoted 6 lines
fs/nfs/pnfs.c +3
-0@@ -1451,10 +1451,19 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) goto out; } +if (!test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags) || + (status =wait_on_bit_lock (&nfsi->flags,NFS_INO_LAYOUTCOMMITTING , + nfs_wait_bit_killable,TASK_KILLABLE ))) {
You want the sleeping behaviour above to be subject to the 'sync' flag (in the same way we do for regular commit). If !sync, then try to grab the bit lock anyway, and exit on failure.
Quoted 25 lines
fs/nfs/pnfs.c +6
-0+kfree (data); + goto out; + } +INIT_LIST_HEAD (&data->lseg_list);spin_lock (&inode->i_lock);if (!test_and_clear_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags)) { +clear_bit (NFS_INO_LAYOUTCOMMITTING , &nfsi->flags);spin_unlock (&inode->i_lock); +wake_up_bit (&nfsi->flags,NFS_INO_LAYOUTCOMMITTING );kfree (data); goto out; }include/linux/nfs_fs.h +1
-0@@ -230,6 +230,7 @@ struct nfs_inode {#define NFS_INO_COMMIT (7)/* inode is committing unstable writes */ #define NFS_INO_PNFS_COMMIT (8)/* use pnfs code for commit */ #define NFS_INO_LAYOUTCOMMIT (9)/* layoutcommit required */ +#define NFS_INO_LAYOUTCOMMITTING (10)/* layoutcommit inflight */ static inline struct nfs_inode *NFS_I (const struct inode *inode) {
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Quoted 47 lines · Trond Myklebust
Quoted 46 lines · Peng Tao
Current
pnfs_layoutcommit_inodecan not handle parallel layoutcommit. As Trond suggested, there is no need for client to optimize for parallel layoutcommit. The patch addNFS_INO_LAYOUTCOMMITTINGflag to mark inflight layoutcommit and serialize lalyoutcommit with it. It also fixes thepls_lc_listcorruption that Vitaliy found.Reported-by Vitaliy Gusev <[email protected]>Signed-off-by Peng Tao <[email protected]>--- fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/pnfs.c | 9 +++++++++ include/linux/nfs_fs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +6
-0@@ -5970,6 +5970,7 @@ static void nfs4_layoutcommit_release(void *calldata) {struct nfs4_layoutcommit_data *data = calldata;struct pnfs_layout_segment *lseg, *tmp; +unsigned long *bitlock = &NFS_I (data->args.inode)->flags;pnfs_cleanup_layoutcommit (data);/* Matched by references in pnfs_set_layoutcommit */ @@ -5979,6 +5980,11 @@ static void nfs4_layoutcommit_release(void *calldata) &lseg->pls_flags))put_lseg (lseg); } + +clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); +put_rpccred (data->cred);kfree (data); }fs/nfs/pnfs.c +0
-0@@ -1451,10 +1451,19 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) goto out; }
Quoted 7 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync) · line 1456
Quoted 3 lines
fs/nfs/pnfs.c +3
-0+if (!test_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags) || + (status =wait_on_bit_lock (&nfsi->flags,NFS_INO_LAYOUTCOMMITTING , + nfs_wait_bit_killable,TASK_KILLABLE ))) {You want the sleeping behaviour above to be subject to the 'sync' flag (in the same way we do for regular commit). If !sync, then try to grab the bit lock anyway, and exit on failure.
By the way. Shouldn't pnfs_layoutcommit_inode() also be marking the inode as dirty on failure?
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
SGksIFRyb25kLA0KDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IFRyb25k IE15a2xlYnVzdCBbbWFpbHRvOlRyb25kLk15a2xlYnVzdEBuZXRhcHAuY29tXQ0KPiBTZW50OiBG cmlkYXksIFNlcHRlbWJlciAxNiwgMjAxMSAxOjQ4IEFNDQo+IFRvOiBQZW5nIFRhbw0KPiBDYzog YmhhbGV2eUB0b25pYW4uY29tOyBWaXRhbGl5IEd1c2V2OyBsaW51eC1uZnNAdmdlci5rZXJuZWwu b3JnOyBQZW5nLCBUYW8NCj4gU3ViamV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lZ3VsYXIgY29tbWl0KS4gSWYgIXN5bmMsIHRoZW4gdHJ5IHRvIGdyYWINCj4gPiB0aGUg Yml0IGxvY2sgYW55d2F5LCBhbmQgZXhpdCBvbiBmYWlsdXJlLg0KSSdtIGEgbGl0dGxlIGNvbmZ1 c2VkIGFib3V0IHRoZSAiIXN5bmMiIGhlcmUuIElmIHdlIHJldHVybiBmYWlsdXJlLCB3aGF0IGRv IHdlIGV4cGVjdCBjYWxsZXJzIHRvIGRvPw0KTG9va2luZyBhdCB0aGUgY2FsbGluZyBzdGFjaywg SSBkb24ndCBzZWUgYW55IHVzZXJzIHJldHJ5aW5nIG9uIC1FQUdBSU4uIERvZXMgdGhlICIhc3lu YyIgbmVjZXNzYXJpbHkgbWVhbiBub24tYmxvY2tpbmc/DQoNCj4gDQo+IEJ5IHRoZSB3YXkuIFNo b3VsZG4ndCBwbmZzX2xheW91dGNvbW1pdF9pbm9kZSgpIGFsc28gYmUgbWFya2luZyB0aGUNCj4g aW5vZGUgYXMgZGlydHkgb24gZmFpbHVyZT8NClllYWgsIHJpZ2h0LCB3ZSBzaG91bGQgbWFyayBp bm9kZSBhcyBkaXJ0eSBvbiBmYWlsdXJlLg0KDQpUaGFua3MsDQpUYW8NCgTvv717Lm7vv70r77+9 77+977+977+977+977+977+9KyXvv73vv71sendt77+977+9Yu+/veunsu+/ve+/vXLvv73vv716 WO+/ve+/vRnfsinvv73vv73vv713Kh9qZ++/ve+/ve+/vR7vv73vv73vv73vv73vv73domov77+9 77+977+9eu+/vd6W77+977+9Mu+/vd6Z77+977+977+9Ju+/vSnfoe+/vWHvv73vv71/77+977+9 Hu+/vUfvv73vv73vv71o77+9D++/vWo6K3bvv73vv73vv71377+92aU=
Quoted 67 lines · On Fri, 2011-09-16 at 07:58 -0400, [email protected] wrote:
Hi, Trond,
Quoted 54 lines
-----Original Message-----
From: Trond Myklebust [mailto:[email protected]]
Sent: Friday, September 16, 2011 1:48 AM
To: Peng Tao
Cc: [email protected]; Vitaliy Gusev; [email protected]; Peng, Tao
Subject: Re: [PATCH] nfs4: serialize layoutcommitQuoted 25 lines · Trond Myklebust
Quoted 24 lines · Peng Tao
Current
pnfs_layoutcommit_inodecan not handle parallel layoutcommit. As Trond suggested, there is no need for client to optimize for parallel layoutcommit. The patch addNFS_INO_LAYOUTCOMMITTINGflag to mark inflight layoutcommit and serialize lalyoutcommit with it. It also fixes thepls_lc_listcorruption that Vitaliy found.Reported-by Vitaliy Gusev <[email protected]>Signed-off-by Peng Tao <[email protected]>--- fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/pnfs.c | 9 +++++++++ include/linux/nfs_fs.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +1
-0@@ -5970,6 +5970,7 @@ static void nfs4_layoutcommit_release(void *calldata) {struct nfs4_layoutcommit_data *data = calldata;struct pnfs_layout_segment *lseg, *tmp; +unsigned long *bitlock = &NFS_I (data->args.inode)->flags;Quoted 3 lines
fs/nfs/nfs4proc.c static void nfs4_layoutcommit_release(void
Quoted 3 lines
fs/nfs/nfs4proc.c +0
-0pnfs_cleanup_layoutcommit (data);/* Matched by references in pnfs_set_layoutcommit */ @@ -5979,6 +5980,11 @@ static void nfs4_layoutcommit_release(void*calldata)
Quoted 8 lines
Quoted 8 lines
fs/nfs/nfs4proc.c +5
-0&lseg->pls_flags))put_lseg (lseg); } + +clear_bit_unlock (NFS_INO_LAYOUTCOMMITTING , bitlock); +smp_mb__after_clear_bit (); +wake_up_bit (bitlock,NFS_INO_LAYOUTCOMMITTING ); +Quoted 8 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode,
Quoted 8 lines
fs/nfs/nfs4proc.c +0
-0put_rpccred (data->cred);kfree (data); }fs/nfs/pnfs.c +0
-0@@ -1451,10 +1451,19 @@ pnfs_layoutcommit_inode(struct inode *inode,bool sync)
Quoted 11 lines
Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync)
Quoted 5 lines
fs/nfs/pnfs.c +2
-0goto out; } + if (!test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags) || + (status = wait_on_bit_lock(&nfsi->flags,
NFS_INO_LAYOUTCOMMITTING,Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync) · line 1456
Quoted 1 line
fs/nfs/pnfs.c +1
-0+ nfs_wait_bit_killable, TASK_KILLABLE))) {You want the sleeping behaviour above to be subject to the 'sync' flag (in the same way we do for regular commit). If !sync, then try to grab the bit lock anyway, and exit on failure.
Quoted 7 lines
I'm a little confused about the "!sync" here. If we return failure, what do we expect callers to do? Looking at the calling stack, I don't see any users retrying on
-EAGAIN. Does the "!sync" necessarily mean non-blocking?Quoted 3 lines
By the way. Shouldn't
pnfs_layoutcommit_inode()also be marking the inode as dirty on failure?Yeah, right, we should mark inode as dirty on failure.
The !sync means that we're being called from a context such as kswapd where we really don't want to sleep or block the thread.
In the case where this happens, and the NFS_INO_LAYOUTCOMMITTING bit can't be set, we should exit and mark the inode as dirty so that we can retry at a later time. Please see the 'commit' code, which has the same properties...
Cheers
Trond
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Quoted 76 lines · Trond Myklebust
Quoted 67 lines · On Fri, 2011-09-16 at 07:58 -0400, [email protected] wrote:
Hi, Trond,
Quoted 54 lines
-----Original Message-----
From: Trond Myklebust [mailto:[email protected]]
Sent: Friday, September 16, 2011 1:48 AM
To: Peng Tao
Cc: [email protected]; Vitaliy Gusev; [email protected]; Peng, Tao
Subject: Re: [PATCH] nfs4: serialize layoutcommitQuoted 25 lines · Trond Myklebust
Quoted 24 lines · Peng Tao
Current
pnfs_layoutcommit_inodecan not handle parallel layoutcommit. As Trond suggested, there is no need for client to optimize for parallel layoutcommit. The patch addNFS_INO_LAYOUTCOMMITTINGflag to mark inflight layoutcommit and serialize lalyoutcommit with it. It also fixes thepls_lc_listcorruption that Vitaliy found.Reported-by Vitaliy Gusev <[email protected]>Signed-off-by Peng Tao <[email protected]>---
fs/nfs/nfs4proc.c | 6 ++++++
fs/nfs/pnfs.c | 9 +++++++++
include/linux/nfs_fs.h | 1 +3 files changed, 16 insertions(+), 0 deletions(-)fs/nfs/nfs4proc.c +1
-0@@ -5970,6 +5970,7 @@ static void nfs4_layoutcommit_release(void *calldata) { struct nfs4_layoutcommit_data *data = calldata; struct pnfs_layout_segment *lseg, *tmp; + unsigned long *bitlock = &NFS_I(data->args.inode)->flags;Quoted 3 lines
fs/nfs/nfs4proc.c static void nfs4_layoutcommit_release(void
Quoted 3 lines
fs/nfs/nfs4proc.c +0
-0pnfs_cleanup_layoutcommit(data); /* Matched by references in pnfs_set_layoutcommit */@@ -5979,6 +5980,11 @@ static void nfs4_layoutcommit_release(void*calldata)
Quoted 8 lines
Quoted 8 lines
fs/nfs/nfs4proc.c +5
-0&lseg->pls_flags)) put_lseg(lseg); } + + clear_bit_unlock(NFS_INO_LAYOUTCOMMITTING, bitlock); + smp_mb__after_clear_bit(); + wake_up_bit(bitlock, NFS_INO_LAYOUTCOMMITTING); +Quoted 8 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode,
Quoted 8 lines
fs/nfs/nfs4proc.c +0
-0put_rpccred(data->cred); kfree(data); }fs/nfs/pnfs.c +0
-0@@ -1451,10 +1451,19 @@ pnfs_layoutcommit_inode(struct inode *inode,bool sync)
Quoted 11 lines
Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync)
Quoted 5 lines
fs/nfs/pnfs.c +2
-0goto out; } + if (!test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags) || + (status = wait_on_bit_lock(&nfsi->flags,
NFS_INO_LAYOUTCOMMITTING,Quoted 5 lines
fs/nfs/pnfs.c pnfs_layoutcommit_inode(struct inode *inode, bool sync) · line 1456
Quoted 1 line
fs/nfs/pnfs.c +1
-0+ nfs_wait_bit_killable, TASK_KILLABLE))) {You want the sleeping behaviour above to be subject to the 'sync' flag (in the same way we do for regular commit). If !sync, then try to grab the bit lock anyway, and exit on failure.
Quoted 7 lines
I'm a little confused about the "!sync" here. If we return failure, what do we expect callers to do? Looking at the calling stack, I don't see any users retrying on
-EAGAIN. Does the "!sync" necessarily mean non-blocking?Quoted 3 lines
By the way. Shouldn't
pnfs_layoutcommit_inode()also be marking the inode as dirty on failure?Yeah, right, we should mark inode as dirty on failure.
Quoted 7 lines
The !sync means that we're being called from a context such as kswapd where we really don't want to sleep or block the thread.
In the case where this happens, and the
NFS_INO_LAYOUTCOMMITTINGbit can't be set, we should exit and mark the inode as dirty so that we can retry at a later time. Please see the 'commit' code, which has the same properties...
I see. Thanks for the explanation. I will update the patch.
Best,
Tao