Recover from stateid-type error on SETATTR
Subsystems (2)
PATCH 1/1 Recover from stateid-type error on SETATTR
Client can receives stateid-type error (eg., BAD_STATEID) on SETATTR when delegation stateid was used. When no open state exists, in case of application calling truncate() on the file, client has no state to recover and fails with EIO.
Instead, upon such error, return the bad delegation and then resend the SETATTR with a zero stateid.
Signed-off: Olga Kornievskaia <[email protected]>
--- fs/nfs/delegation.h | 6 ++++++ fs/nfs/nfs4proc.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
fs/nfs/delegation.h +6 -0
@@ -62,6 +62,12 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);int nfs4_have_delegation (struct inode *inode,fmode_t flags);int nfs4_check_delegation (struct inode *inode,fmode_t flags); +static inline int nfs4_have_any_delegation (struct inode *inode) +{ +struct nfs_inode *nfsi =NFS_I (inode); +return rcu_access_pointer (nfsi->delegation) ?1 :0 ; +} +#endif static inline int nfs_have_delegated_attributes (struct inode *inode)
fs/nfs/nfs4proc.c +6 -1
@@ -360,8 +360,13 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struccase -NFS4ERR_DELEG_REVOKED :case -NFS4ERR_ADMIN_REVOKED :case -NFS4ERR_BAD_STATEID : -if (state ==NULL ) +if (state ==NULL ) { +if (nfs4_have_any_delegation (inode)) { +nfs4_inode_return_delegation (inode); + exception->retry =1 ; + }break ; + } ret =nfs4_schedule_stateid_recovery (server, state);if (ret <0 )break ;
Signature · 1 line
1.8.3.1
Hi Olga,
Quoted 19 lines · Olga Kornievskaia
Client can receives stateid-type error (eg.,
BAD_STATEID) on SETATTR when delegation stateid was used. When no open state exists, in case of application callingtruncate()on the file, client has no state to recover and fails with EIO.Instead, upon such error, return the bad delegation and then resend the SETATTR with a zero stateid.
Signed-off: Olga Kornievskaia <[email protected]>
--- fs/nfs/delegation.h | 6 ++++++ fs/nfs/nfs4proc.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)fs/nfs/delegation.h +0
-0
fs/nfs/delegation.h void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); · line 69
Quoted 8 lines
fs/nfs/delegation.h +5
-0@@ -62,6 +62,12 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);int nfs4_have_delegation (struct inode *inode,fmode_t flags);int nfs4_check_delegation (struct inode *inode,fmode_t flags); +static inline int nfs4_have_any_delegation (struct inode *inode) +{ +struct nfs_inode *nfsi =NFS_I (inode); +return rcu_access_pointer (nfsi->delegation) ?1 :0 ; +}
What would this do that isn't already covered bynfs4_have_delegation(inode, FMODE_READ)?
Cheers
Trond
DQo+IE9uIEp1biAxMiwgMjAxNSwgYXQgMjozNyBQTSwgVHJvbmQgTXlrbGVidXN0IDx0cm9uZC5t eWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tPiB3cm90ZToNCj4gDQo+IEhpIE9sZ2EsDQo+IA0KPiBP biBGcmksIEp1biAxMiwgMjAxNSBhdCAyOjMwIFBNLCBPbGdhIEtvcm5pZXZza2FpYSA8a29sZ2FA bmV0YXBwLmNvbT4gd3JvdGU6DQo+PiBDbGllbnQgY2FuIHJlY2VpdmVzIHN0YXRlaWQtdHlwZSBl cnJvciAoZWcuLCBCQURfU1RBVEVJRCkgb24gU0VUQVRUUiB3aGVuDQo+PiBkZWxlZ2F0aW9uIHN0 YXRlaWQgd2FzIHVzZWQuIFdoZW4gbm8gb3BlbiBzdGF0ZSBleGlzdHMsIGluIGNhc2Ugb2YgYXBw bGljYXRpb24NCj4+IGNhbGxpbmcgdHJ1bmNhdGUoKSBvbiB0aGUgZmlsZSwgY2xpZW50IGhhcyBu byBzdGF0ZSB0byByZWNvdmVyIGFuZCBmYWlscyB3aXRoDQo+PiBFSU8uDQo+PiANCj4+IEluc3Rl YWQsIHVwb24gc3VjaCBlcnJvciwgcmV0dXJuIHRoZSBiYWQgZGVsZWdhdGlvbiBhbmQgdGhlbiBy ZXNlbmQgdGhlDQo+PiBTRVRBVFRSIHdpdGggYSB6ZXJvIHN0YXRlaWQu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IHRoaXMgZG8gdGhhdCBp c24ndCBhbHJlYWR5IGNvdmVyZWQgYnkNCj4gbmZzNF9oYXZlX2RlbGVnYXRpb24oaW5vZGUsIEZN T0RFX1JFQUQpPw0KDQpXZSBuZWVkIHRvIHJldHVybiBkZWxlZ2F0aW9uIHJlZ2FyZGxlc3Mgb2Yg d2hldGhlciBpdOKAmXMgcmVhZCBvciB3cml0ZS4gDQoNCj4gDQo+IENoZWVycw0KPiAgVHJvbmQN Cg0K
Hey Trond,
Quoted 25 lines · Trond Myklebust
Hi Olga,
Quoted 22 lines · Olga Kornievskaia
Client can receives stateid-type error (eg.,
BAD_STATEID) on SETATTR when delegation stateid was used. When no open state exists, in case of application callingtruncate()on the file, client has no state to recover and fails with EIO.Instead, upon such error, return the bad delegation and then resend the SETATTR with a zero stateid.
Signed-off: Olga Kornievskaia <[email protected]>
--- fs/nfs/delegation.h | 6 ++++++ fs/nfs/nfs4proc.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-)fs/nfs/delegation.h +0
-0@@ -62,6 +62,12 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);int nfs4_have_delegation (struct inode *inode,fmode_t flags);int nfs4_check_delegation (struct inode *inode,fmode_t flags);
Quoted 8 lines
fs/nfs/delegation.h void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); · line 69
Quoted 5 lines
fs/nfs/delegation.h +5
-0+static inline int nfs4_have_any_delegation (struct inode *inode) +{ +struct nfs_inode *nfsi =NFS_I (inode); +return rcu_access_pointer (nfsi->delegation) ?1 :0 ; +}What would this do that isn't already covered by
nfs4_have_delegation(inode, FMODE_READ)?
It looks like _nfs4_do_settattr() can select between FMODE_READ and FMODE_WRITE, so wouldn't we otherwise need to call nfs4_have_delegation() twice? Or am I missing something?
Anna
Quoted 4 lines
Cheers
Trond
Quoted 37 lines · Olga
Quoted 28 lines · Trond Myklebust
Hi Olga,
Quoted 22 lines · Olga Kornievskaia
Client can receives stateid-type error (eg.,
BAD_STATEID) on SETATTR when delegation stateid was used. When no open state exists, in case of application callingtruncate()on the file, client has no state to recover and fails with EIO.Instead, upon such error, return the bad delegation and then resend the SETATTR with a zero stateid.
Signed-off: Olga Kornievskaia <[email protected]>
---fs/nfs/delegation.h| 6 ++++++fs/nfs/nfs4proc.c| 7 ++++++-2 files changed, 12 insertions(+), 1 deletion(-)fs/nfs/delegation.h +0
-0@@ -62,6 +62,12 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);int nfs4_have_delegation (struct inode *inode,fmode_t flags);int nfs4_check_delegation (struct inode *inode,fmode_t flags);Quoted 8 lines
fs/nfs/delegation.h void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); · line 69
Quoted 5 lines
fs/nfs/delegation.h +5
-0+static inline int nfs4_have_any_delegation (struct inode *inode) +{ +struct nfs_inode *nfsi =NFS_I (inode); +return rcu_access_pointer (nfsi->delegation) ?1 :0 ; +}What would this do that isn't already covered by
nfs4_have_delegation(inode, FMODE_READ)?
Quoted 1 line
We need to return delegation regardless of whether it’s read or write.
Yes, and the test for nfs4_have_delegation(inode, FMODE_READ) is intentionally satisfied when you hold a write delegation, because it guarantees a superset of the caching guarantees that a read delegation would offer.
Cheers
Trond