Skip to contentSkip to conversation

nfs42: client needs to update file mode after ALLOCATE op

PATCH Superseded Dai Ngo 2 participants 2 messages Aug 24, 2023

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Dai Ngo

author reviewer
#0 lore raw

PATCH 1/1 nfs42: client needs to update file mode after ALLOCATE op

The Linux NFS server strips the SUID and SGID from the file mode on ALLOCATE op. The GETATTR op in the ALLOCATE compound needs to request the file mode from the server to update its file mode in case the SUID/SGUI bit were stripped.

---
 fs/nfs/nfs42proc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfs/nfs42proc.c +6 -1
index 63802d195556..ba2b83bfb37c 100644
@@ -57,6 +57,9 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
 		.falloc_server	= server,
 	};
 	int status;
+	struct super_block *sb = inode->i_sb;
+	u64 fattr_supported = NFS_SB(sb)->fattr_valid;
+	unsigned long mask = NFS_INO_INVALID_BLOCKS;
 
 	msg->rpc_argp = &args;
 	msg->rpc_resp = &res;
@@ -69,8 +72,10 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
 		return status;
 	}
 
+	if (fattr_supported & NFS_ATTR_FATTR_MODE)
+		mask |= NFS_INO_INVALID_MODE;
 	nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, inode,
-			 NFS_INO_INVALID_BLOCKS);
+				mask);
 
 	res.falloc_fattr = nfs_alloc_fattr();
 	if (!res.falloc_fattr)
Signature · 1 line
2.39.3
#1 lore raw
Quoted 29 lines · Dai Ngo

The Linux NFS server strips the SUID and SGID from the file mode on ALLOCATE op. The GETATTR op in the ALLOCATE compound needs to request the file mode from the server to update its file mode in case the SUID/SGUI bit were stripped.

---
 fs/nfs/nfs42proc.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfs/nfs42proc.c +3 -0
index 63802d195556..ba2b83bfb37c 100644
@@ -57,6 +57,9 @@ static int _nfs42_proc_fallocate(struct rpc_message
 *msg, struct file *filep,
                 .falloc_server  = server,
         };
         int status;
+       struct super_block *sb = inode->i_sb;
+       u64 fattr_supported = NFS_SB(sb)->fattr_valid;
+       unsigned long mask = NFS_INO_INVALID_BLOCKS;


        msg->rpc_argp = &args;
        msg->rpc_resp = &res;

fs/nfs/nfs42proc.c +0 -0
@@ -69,8 +72,10 @@ static int _nfs42_proc_fallocate(struct
 rpc_message *msg, struct file *filep,
                 return status;
         }
Quoted 3 lines


+       if (fattr_supported & NFS_ATTR_FATTR_MODE) +               mask |= NFS_INO_INVALID_MODE;

nfs4_bitmask_set() will take care of masking out bits that are not supported, so the condition above is redundant.

Quoted 7 lines

        nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, inode,
-                        NFS_INO_INVALID_BLOCKS);
+                               mask);

        res.falloc_fattr = nfs_alloc_fattr();
        if (!res.falloc_fattr)

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]