Skip to contentSkip to conversation

NFSv4.2: Update mode bits after ALLOCATE and DEALLOCATE

PATCH Superseded Anna Schumaker 2 participants 2 messages Aug 30, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Anna Schumaker

author maintainer
#0 lore raw

PATCH 1/1 NFSv4.2: Update mode bits after ALLOCATE and DEALLOCATE

From: Anna Schumaker <[email protected]>

The fallocate call invalidates suid and sgid bits as part of normal operation. We need to mark the mode bits as invalid when using fallocate so these will be updated the next time the user looks at them.

This fixes xfstests generic/683 and generic/684.

Fixes 913eca1aea87 ("NFS: Fallocate should use the nfs4_fattr_bitmap")
---
 fs/nfs/nfs42proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs42proc.c +1 -1
index 068c45b3bc1a..a1b264b1a09f 100644
@@ -70,7 +70,7 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
 	}
 
 	nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, inode,
-			 NFS_INO_INVALID_BLOCKS);
+			 NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_MODE);
 
 	res.falloc_fattr = nfs_alloc_fattr();
 	if (!res.falloc_fattr)
Signature · 1 line
2.37.2
#1 lore raw
Quoted 24 lines · Anna Schumaker

From: Anna Schumaker <[email protected]>

The fallocate call invalidates suid and sgid bits as part of normal operation. We need to mark the mode bits as invalid when using fallocate
so these will be updated the next time the user looks at them.

This fixes xfstests generic/683 and generic/684.

Fixes 913eca1aea87 ("NFS: Fallocate should use the

nfs4_fattr_bitmap")

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

 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs42proc.c +0 -0
index 068c45b3bc1a..a1b264b1a09f 100644
@@ -70,7 +70,7 @@ static int _nfs42_proc_fallocate(struct rpc_message
 *msg, struct file *filep,
         }
Quoted 6 lines


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

Hmm... Could we please set NFS_INO_INVALID_MODE only in the case where we see that either the S_ISUID or S_ISGID bits are set, just like we do in nfs_writeback_done()?

Quoted 3 lines


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

Note also that you really should (conditionally!) call nfs_set_cache_invalid() at some point between the RPC call completing, and the call to nfs_post_op_update_inode_force_wcc(), just in case the server fails to return the attributes.

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