nfsd: remove unsafe BUG_ON from set_change_info
Subsystems (2)
Jeff Layton
maintainerPATCH 1/1 nfsd: remove unsafe BUG_ON from set_change_info
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the change_info4. At that time, the BUG_ON in set_change_info made some sense, since having it unset meant a coding error.
More recently, it calls vfs_getattr to get this information, which can fail. If that fails, fh_pre_saved can end up not being set. While this situation is unfortunate, we don't need to crash the box.
Move set_change_info to nfs4proc.c since all of the callers are there. Revise the condition for setting "atomic" to also check for fh_pre_saved. Drop the BUG_ON and make it a WARN_ON, and just have it zero out both change_attr4s when this occurs.
--- fs/nfsd/nfs4proc.c | 30 ++++++++++++++++++++++++++++++ fs/nfsd/xdr4.h | 11 ----------- 2 files changed, 30 insertions(+), 11 deletions(-)
fs/nfsd/nfs4proc.c +30 -0
@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just +* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after +* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) { + cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static __be32 do_open_lookup (struct svc_rqst *rqstp,struct nfsd4_compound_state *cstate,struct nfsd4_open *open,struct svc_fh **resfh) {
fs/nfsd/xdr4.h +0 -11
@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr);
---
base-commit: 070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217b
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 12 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.
I'm always happy to get rid of a BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.
Can you elaborate on why the vfs_getattr() might fail? Eg, how was it failing in 2223560 ?
Quoted 7 lines
Move
set_change_infotonfs4proc.csince all of the callers are there. Revise the condition for setting "atomic" to also check forfh_pre_saved. Drop theBUG_ONand make it aWARN_ON, and just have it zero out bothchange_attr4swhen this occurs.
checkpatch now wants
Reported-by:
Closes:
in that order.
Quoted 22 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/nfsd/nfs4proc.c| 30 ++++++++++++++++++++++++++++++fs/nfsd/xdr4.h| 11 -----------2 files changed, 30 insertions(+), 11 deletions(-)fs/nfsd/nfs4proc.c +8
-0@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 400
Quoted 10 lines
fs/nfsd/nfs4proc.c +10
-0+* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after
"From the server"? Is it only likely to fail if the exported filesystem is an NFS mount? Or did you mean "from the filesystem" ?
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 403
Quoted 3 lines
fs/nfsd/nfs4proc.c +3
-0+* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) {
Maybe you should clear ->atomic as well in this case.
Quoted 39 lines
fs/nfsd/nfs4proc.c +9
-0+ cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static
__be32
do_open_lookup(structsvc_rqst*rqstp, structnfsd4_compound_state*cstate, structnfsd4_open*open, structsvc_fh**resfh) {fs/nfsd/xdr4.h +0
-12@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr); ---base-commit:
070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217b
Quoted 4 lines
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
--
Chuck Lever
Jeff Layton
maintainerQuoted 12 lines · Chuck Lever III
Quoted 11 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.
Quoted 8 lines
I'm always happy to get rid of a
BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.Can you elaborate on why the
vfs_getattr()might fail? Eg, how was it failing in 2223560 ?
I'm fine with dropping the WARN_ON. You are correct that there is probably little the admin can do about it.
vfs_getattr can fail for all sorts of reasons. It really depends on the underlying filesystem. In 2223560, I don't know for sure, but just prior to the oops, there were these messages in the log:
[51935.482019] XFS (vda3): Filesystem has been shut down due to log error (0x2). [51935.482020] XFS (vda3): Please unmount the filesystem and rectify the problem(s). [51935.482550] vda3: writeback error on inode 25320400, offset 2097152, sector 58684120
My assumption was that the fs being shut down caused some VFS operations to start returning errors (including getattr) and that is why fh_pre_saved ultimately didn't get set.
Quoted 9 lines
Quoted 8 lines
Move
set_change_infotonfs4proc.csince all of the callers are there. Revise the condition for setting "atomic" to also check forfh_pre_saved. Drop theBUG_ONand make it aWARN_ON, and just have it zero out bothchange_attr4swhen this occurs.
Quoted 7 lines
checkpatch now wants
Reported-by:
Closes:in that order.
Mmmmkay. So I assume the URL should go in the Closes: field then?
I'll take out the WARN_ON_ONCE and resend, once others have had a chance to comment.
Thanks!
Quoted 93 lines
Quoted 23 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/nfsd/nfs4proc.c| 30 ++++++++++++++++++++++++++++++fs/nfsd/xdr4.h| 11 -----------2 files changed, 30 insertions(+), 11 deletions(-)fs/nfsd/nfs4proc.c +8
-0@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 400
Quoted 10 lines
fs/nfsd/nfs4proc.c +10
-0+* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after "From the server"? Is it only likely to fail if the exported filesystem is an NFS mount? Or did you mean "from the filesystem" ?
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 403
Quoted 3 lines
fs/nfsd/nfs4proc.c +3
-0+* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) {Maybe you should clear ->atomic as well in this case.
Quoted 39 lines
fs/nfsd/nfs4proc.c +9
-0+ cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static
__be32
do_open_lookup(structsvc_rqst*rqstp, structnfsd4_compound_state*cstate, structnfsd4_open*open, structsvc_fh**resfh) {fs/nfsd/xdr4.h +0
-12@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr); ---base-commit:
070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217bQuoted 4 lines
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>--
Chuck Lever
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 33 lines · Jeff Layton
Quoted 12 lines · Chuck Lever III
Quoted 11 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.Quoted 8 lines
I'm always happy to get rid of a
BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.Can you elaborate on why the
vfs_getattr()might fail? Eg, how was it failing in 2223560 ?I'm fine with dropping the
WARN_ON. You are correct that there is probably little the admin can do about it.
vfs_getattrcan fail for all sorts of reasons. It really depends on the underlying filesystem. In 2223560, I don't know for sure, but just prior to the oops, there were these messages in the log:
Quoted 7 lines
[51935.482019] XFS (vda3): Filesystem has been shut down due to log error (0x2). [51935.482020] XFS (vda3): Please unmount the filesystem and rectify the problem(s). [51935.482550] vda3: writeback error on inode 25320400, offset 2097152, sector 58684120My assumption was that the fs being shut down caused some VFS operations to start returning errors (including getattr) and that is why
fh_pre_savedultimately didn't get set.
I'm wondering if the operation should just fail in this case rather than return a cobbled-up changeinfo4. Maybe for another day.
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Move
set_change_infotonfs4proc.csince all of the callers are there. Revise the condition for setting "atomic" to also check forfh_pre_saved. Drop theBUG_ONand make it aWARN_ON, and just have it zero out bothchange_attr4swhen this occurs.checkpatch now wants
Quoted 8 lines
Quoted 5 lines
Reported-by:
Closes:in that order.
Mmmmkay. So I assume the URL should go in the Closes: field then?
Yes, a bug link goes in the Closes: field.
Quoted 2 lines
I'll take out the
WARN_ON_ONCEand resend, once others have had a chance to comment.
Don't miss the other comments below.
Quoted 86 lines
Thanks!
Quoted 84 lines
Quoted 23 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/nfsd/nfs4proc.c| 30 ++++++++++++++++++++++++++++++fs/nfsd/xdr4.h| 11 -----------2 files changed, 30 insertions(+), 11 deletions(-)fs/nfsd/nfs4proc.c +8
-0@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 400
Quoted 10 lines
fs/nfsd/nfs4proc.c +10
-0+* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after "From the server"? Is it only likely to fail if the exported filesystem is an NFS mount? Or did you mean "from the filesystem" ?
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 403
Quoted 3 lines
fs/nfsd/nfs4proc.c +3
-0+* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) {Maybe you should clear ->atomic as well in this case.
Quoted 39 lines
fs/nfsd/nfs4proc.c +9
-0+ cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static
__be32
do_open_lookup(structsvc_rqst*rqstp, structnfsd4_compound_state*cstate, structnfsd4_open*open, structsvc_fh**resfh) {fs/nfsd/xdr4.h +0
-12@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr); ---base-commit:
070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217b
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>--
Chuck LeverSignature · 1 line
Jeff Layton <[email protected]>
--
Chuck Lever
Jeff Layton
maintainerQuoted 64 lines · Chuck Lever III
Quoted 32 lines · Jeff Layton
Quoted 12 lines · Chuck Lever III
Quoted 11 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.Quoted 8 lines
I'm always happy to get rid of a
BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.Can you elaborate on why the
vfs_getattr()might fail? Eg, how was it failing in 2223560 ?I'm fine with dropping the
WARN_ON. You are correct that there is probably little the admin can do about it.
vfs_getattrcan fail for all sorts of reasons. It really depends on the underlying filesystem. In 2223560, I don't know for sure, but just prior to the oops, there were these messages in the log:Quoted 7 lines
[51935.482019] XFS (vda3): Filesystem has been shut down due to log error (0x2). [51935.482020] XFS (vda3): Please unmount the filesystem and rectify the problem(s). [51935.482550] vda3: writeback error on inode 25320400, offset 2097152, sector 58684120My assumption was that the fs being shut down caused some VFS operations to start returning errors (including getattr) and that is why
fh_pre_savedultimately didn't get set.I'm wondering if the operation should just fail in this case rather than return a cobbled-up changeinfo4. Maybe for another day.
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Move
set_change_infotonfs4proc.csince all of the callers are there. Revise the condition for setting "atomic" to also check forfh_pre_saved. Drop theBUG_ONand make it aWARN_ON, and just have it zero out bothchange_attr4swhen this occurs.checkpatch now wants
Quoted 8 lines
Quoted 5 lines
Reported-by:
Closes:in that order.
Mmmmkay. So I assume the URL should go in the Closes: field then?
Quoted 48 lines
Yes, a bug link goes in the Closes: field.
Quoted 2 lines
I'll take out the
WARN_ON_ONCEand resend, once others have had a chance to comment.Don't miss the other comments below.
Quoted 39 lines
Thanks!
Quoted 37 lines
Quoted 23 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/nfsd/nfs4proc.c| 30 ++++++++++++++++++++++++++++++fs/nfsd/xdr4.h| 11 -----------2 files changed, 30 insertions(+), 11 deletions(-)fs/nfsd/nfs4proc.c +8
-0@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 400
Quoted 10 lines
fs/nfsd/nfs4proc.c +10
-0+* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after "From the server"? Is it only likely to fail if the exported filesystem is an NFS mount? Or did you mean "from the filesystem" ?
Yep, will fix.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 403
Quoted 4 lines
fs/nfsd/nfs4proc.c +3
-0+* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) {Maybe you should clear ->atomic as well in this case.
It should already be clear since fh_pre_saved isn't set.
Quoted 57 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
fs/nfsd/nfs4proc.c +9
-0+ cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static
__be32
do_open_lookup(structsvc_rqst*rqstp, structnfsd4_compound_state*cstate, structnfsd4_open*open, structsvc_fh**resfh) {fs/nfsd/xdr4.h +0
-12@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr); ---base-commit:
070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217bQuoted 12 lines
Quoted 9 lines
Quoted 4 lines
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>--
Chuck LeverSignature · 1 line
Jeff Layton <[email protected]>--
Chuck Lever
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerQuoted 36 lines · Chuck Lever III
Quoted 36 lines · Jeff Layton
Quoted 12 lines · Chuck Lever III
Quoted 11 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.Quoted 8 lines
I'm always happy to get rid of a
BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.Can you elaborate on why the
vfs_getattr()might fail? Eg, how was it failing in 2223560 ?I'm fine with dropping the
WARN_ON. You are correct that there is probably little the admin can do about it.
vfs_getattrcan fail for all sorts of reasons. It really depends on the underlying filesystem. In 2223560, I don't know for sure, but just prior to the oops, there were these messages in the log:[51935.482019] XFS (vda3): Filesystem has been shut down due to log error (0x2). [51935.482020] XFS (vda3): Please unmount the filesystem and rectify the problem(s). [51935.482550] vda3: writeback error on inode 25320400, offset 2097152, sector 58684120
Quoted 8 lines
Quoted 3 lines
My assumption was that the fs being shut down caused some VFS operations to start returning errors (including getattr) and that is why
fh_pre_savedultimately didn't get set.I'm wondering if the operation should just fail in this case rather than return a cobbled-up changeinfo4. Maybe for another day.
If we issue a create or rename or something and it did happen, then we don't want to return an error just because we couldn't collect the info on it.
We probably could abort the operation if collecting the pre-change info fails though.
Quoted 133 lines
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Move
set_change_infotonfs4proc.csince all of the callers are there. Revise the condition for setting "atomic" to also check forfh_pre_saved. Drop theBUG_ONand make it aWARN_ON, and just have it zero out bothchange_attr4swhen this occurs.checkpatch now wants
Quoted 8 lines
Quoted 5 lines
Reported-by:
Closes:in that order.
Mmmmkay. So I assume the URL should go in the Closes: field then?
Yes, a bug link goes in the Closes: field.
Quoted 2 lines
I'll take out the
WARN_ON_ONCEand resend, once others have had a chance to comment.Don't miss the other comments below.
Quoted 86 lines
Thanks!
Quoted 84 lines
Quoted 23 lines
Signed-off-by Jeff Layton <[email protected]>---
fs/nfsd/nfs4proc.c| 30 ++++++++++++++++++++++++++++++fs/nfsd/xdr4.h| 11 -----------2 files changed, 30 insertions(+), 11 deletions(-)fs/nfsd/nfs4proc.c +8
-0@@ -380,6 +380,36 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,return status; } +/** +* set_change_info - set up the change_info4 for a reply +* @cinfo: pointer to nfsd4_change_info to be populated +* @fhp: pointer to svc_fh to use as source +* +* Many operations in NFSv4 require change_info4 in the reply. This function +* populates that from the info that we (should!) have already collected. In +* the event that we didn't get any pre-attrs, throw a warning and just fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 400
Quoted 10 lines
fs/nfsd/nfs4proc.c +10
-0+* zero out both change_attr4 fields. +*/ +static void +set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) +{ + cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); + +/* +* In the event that we couldn't fetch attributes from the +* server for some reason, just zero out the before and after "From the server"? Is it only likely to fail if the exported filesystem is an NFS mount? Or did you mean "from the filesystem" ?
fs/nfsd/nfs4proc.c nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 403
Quoted 3 lines
fs/nfsd/nfs4proc.c +3
-0+* change values, after throwing a warning. +*/ +if (WARN_ON_ONCE (!fhp->fh_pre_saved)) {Maybe you should clear ->atomic as well in this case.
Quoted 39 lines
fs/nfsd/nfs4proc.c +9
-0+ cinfo->before_change =0 ; + cinfo->after_change =0 ; +return ; + } + + cinfo->before_change = fhp->fh_pre_change; + cinfo->after_change = fhp->fh_post_change; +} +static
__be32
do_open_lookup(structsvc_rqst*rqstp, structnfsd4_compound_state*cstate, structnfsd4_open*open, structsvc_fh**resfh) {fs/nfsd/xdr4.h +0
-12@@ -775,17 +775,6 @@ void warn_on_nonidempotent_op(struct nfsd4_op *op);#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) -static inline void -set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) -{ -BUG_ON (!fhp->fh_pre_saved); - cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); - - cinfo->before_change = fhp->fh_pre_change; - cinfo->after_change = fhp->fh_post_change; -} - -bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);bool nfs4svc_decode_compoundargs (struct svc_rqst *rqstp,struct xdr_stream *xdr);bool nfs4svc_encode_compoundres (struct svc_rqst *rqstp,struct xdr_stream *xdr); ---base-commit:
070f391ca4d48e1750ee6108eb44f751a9e9448e
change-id: 20230720-bz2223560-9c4690a8217bQuoted 12 lines
Quoted 9 lines
Quoted 4 lines
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>--
Chuck LeverSignature · 1 line
Jeff Layton <[email protected]>--
Chuck Lever
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerQuoted 36 lines · Chuck Lever III
Quoted 36 lines · Jeff Layton
Quoted 12 lines · Chuck Lever III
Quoted 11 lines · Jeff Layton
At one time, nfsd would scrape inode information directly out of struct inode in order to populate the
change_info4. At that time, theBUG_ONinset_change_infomade some sense, since having it unset meant a coding error.More recently, it calls
vfs_getattrto get this information, which can fail. If that fails,fh_pre_savedcan end up not being set. While this situation is unfortunate, we don't need to crash the box.Quoted 8 lines
I'm always happy to get rid of a
BUG_ON(). But I'm not sure even a warning is necessary in this case. It's not likely that it's a software bug or something that the server administrator can do something about.Can you elaborate on why the
vfs_getattr()might fail? Eg, how was it failing in 2223560 ?I'm fine with dropping the
WARN_ON. You are correct that there is probably little the admin can do about it.
vfs_getattrcan fail for all sorts of reasons. It really depends on the underlying filesystem. In 2223560, I don't know for sure, but just prior to the oops, there were these messages in the log:[51935.482019] XFS (vda3): Filesystem has been shut down due to log error (0x2). [51935.482020] XFS (vda3): Please unmount the filesystem and rectify the problem(s). [51935.482550] vda3: writeback error on inode 25320400, offset 2097152, sector 58684120
Quoted 8 lines
Quoted 3 lines
My assumption was that the fs being shut down caused some VFS operations to start returning errors (including getattr) and that is why
fh_pre_savedultimately didn't get set.I'm wondering if the operation should just fail in this case rather than return a cobbled-up changeinfo4. Maybe for another day.
Actually, this doesn't look too hard to do. We should be able to just unwind and return an error in all cases if collecting pre_op_attrs fails.
The trickier bit is what to do if collecting post_op_attrs fails after collecting pre-op attrs and the operation itself succeeded. What should go into the after_change value? 0? Should we just copy the before_change value?
Signature · 1 line
Jeff Layton <[email protected]>