Skip to content

Commit

Permalink
nfsd: Record NFSv4 pre/post-op attributes as non-atomic
Browse files Browse the repository at this point in the history
For the case of NFSv4, specify to the client that the pre/post-op
attributes were not recorded atomically with the main operation.

Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
Trond Myklebust authored and chucklever committed Dec 9, 2020
1 parent 01cbf38 commit 716a8bc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fs/nfs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@ const struct export_operations nfs_export_ops = {
.fh_to_dentry = nfs_fh_to_dentry,
.get_parent = nfs_get_parent,
.flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK|
EXPORT_OP_CLOSE_BEFORE_UNLINK|EXPORT_OP_REMOTE_FS,
EXPORT_OP_CLOSE_BEFORE_UNLINK|EXPORT_OP_REMOTE_FS|
EXPORT_OP_NOATOMIC_ATTR,
};
4 changes: 4 additions & 0 deletions fs/nfsd/nfsfh.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
fhp->fh_export = exp;

switch (rqstp->rq_vers) {
case 4:
if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR)
fhp->fh_no_atomic_attr = true;
break;
case 3:
if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC)
fhp->fh_no_wcc = true;
Expand Down
5 changes: 5 additions & 0 deletions fs/nfsd/nfsfh.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ typedef struct svc_fh {
bool fh_locked; /* inode locked by us */
bool fh_want_write; /* remount protection taken */
bool fh_no_wcc; /* no wcc data needed */
bool fh_no_atomic_attr;
/*
* wcc data is not atomic with
* operation
*/
int fh_flags; /* FH flags */
#ifdef CONFIG_NFSD_V3
bool fh_post_saved; /* post-op attrs saved */
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/xdr4.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ 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;
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;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/exportfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ struct export_operations {
#define EXPORT_OP_NOSUBTREECHK (0x2) /* no subtree checking */
#define EXPORT_OP_CLOSE_BEFORE_UNLINK (0x4) /* close files before unlink */
#define EXPORT_OP_REMOTE_FS (0x8) /* Filesystem is remote */
#define EXPORT_OP_NOATOMIC_ATTR (0x10) /* Filesystem cannot supply
atomic attribute updates
*/
unsigned long flags;
};

Expand Down

0 comments on commit 716a8bc

Please sign in to comment.