Skip to content

Commit 518f375

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: don't provide pre/post-op attrs if fh_getattr fails
nfsd calls fh_getattr to get the latest inode attrs for pre/post-op info. In the event that fh_getattr fails, it resorts to scraping cached values out of the inode directly. Since these attributes are optional, we can just skip providing them altogether when this happens. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Neil Brown <[email protected]>
1 parent df56b38 commit 518f375

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

fs/nfsd/nfsfh.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -623,16 +623,9 @@ void fh_fill_pre_attrs(struct svc_fh *fhp)
623623

624624
inode = d_inode(fhp->fh_dentry);
625625
err = fh_getattr(fhp, &stat);
626-
if (err) {
627-
/* Grab the times from inode anyway */
628-
stat.mtime = inode->i_mtime;
629-
stat.ctime = inode->i_ctime;
630-
stat.size = inode->i_size;
631-
if (v4 && IS_I_VERSION(inode)) {
632-
stat.change_cookie = inode_query_iversion(inode);
633-
stat.result_mask |= STATX_CHANGE_COOKIE;
634-
}
635-
}
626+
if (err)
627+
return;
628+
636629
if (v4)
637630
fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);
638631

@@ -660,15 +653,10 @@ void fh_fill_post_attrs(struct svc_fh *fhp)
660653
printk("nfsd: inode locked twice during operation.\n");
661654

662655
err = fh_getattr(fhp, &fhp->fh_post_attr);
663-
if (err) {
664-
fhp->fh_post_saved = false;
665-
fhp->fh_post_attr.ctime = inode->i_ctime;
666-
if (v4 && IS_I_VERSION(inode)) {
667-
fhp->fh_post_attr.change_cookie = inode_query_iversion(inode);
668-
fhp->fh_post_attr.result_mask |= STATX_CHANGE_COOKIE;
669-
}
670-
} else
671-
fhp->fh_post_saved = true;
656+
if (err)
657+
return;
658+
659+
fhp->fh_post_saved = true;
672660
if (v4)
673661
fhp->fh_post_change =
674662
nfsd4_change_attribute(&fhp->fh_post_attr, inode);

0 commit comments

Comments
 (0)