Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nfs: update inode ctime after removexattr operation

xfstest generic/728 fails with delegated timestamps. The client does a
removexattr and then a stat to test the ctime, which doesn't change. The
stat() doesn't trigger a GETATTR because of the delegated timestamps, so
it relies on the cached ctime, which is wrong.

The setxattr compound has a trailing GETATTR, which ensures that its
ctime gets updated. Follow the same strategy with removexattr.

Fixes: 3e1f02123fba ("NFSv4.2: add client side XDR handling for extended attributes")
Reported-by: Olga Kornievskaia <aglo@umich.edu>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Jeff Layton and committed by
Trond Myklebust
9c332d7f 16d99dce

+27 -4
+16 -2
fs/nfs/nfs42proc.c
··· 1372 1372 static int _nfs42_proc_removexattr(struct inode *inode, const char *name) 1373 1373 { 1374 1374 struct nfs_server *server = NFS_SERVER(inode); 1375 + __u32 bitmask[NFS_BITMASK_SZ]; 1375 1376 struct nfs42_removexattrargs args = { 1376 1377 .fh = NFS_FH(inode), 1378 + .bitmask = bitmask, 1377 1379 .xattr_name = name, 1378 1380 }; 1379 - struct nfs42_removexattrres res; 1381 + struct nfs42_removexattrres res = { 1382 + .server = server, 1383 + }; 1380 1384 struct rpc_message msg = { 1381 1385 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVEXATTR], 1382 1386 .rpc_argp = &args, ··· 1389 1385 int ret; 1390 1386 unsigned long timestamp = jiffies; 1391 1387 1388 + res.fattr = nfs_alloc_fattr(); 1389 + if (!res.fattr) 1390 + return -ENOMEM; 1391 + 1392 + nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, 1393 + inode, NFS_INO_INVALID_CHANGE); 1394 + 1392 1395 ret = nfs4_call_sync(server->client, server, &msg, &args.seq_args, 1393 1396 &res.seq_res, 1); 1394 1397 trace_nfs4_removexattr(inode, name, ret); 1395 - if (!ret) 1398 + if (!ret) { 1396 1399 nfs4_update_changeattr(inode, &res.cinfo, timestamp, 0); 1400 + ret = nfs_post_op_update_inode(inode, res.fattr); 1401 + } 1397 1402 1403 + kfree(res.fattr); 1398 1404 return ret; 1399 1405 } 1400 1406
+8 -2
fs/nfs/nfs42xdr.c
··· 263 263 #define NFS4_enc_removexattr_sz (compound_encode_hdr_maxsz + \ 264 264 encode_sequence_maxsz + \ 265 265 encode_putfh_maxsz + \ 266 - encode_removexattr_maxsz) 266 + encode_removexattr_maxsz + \ 267 + encode_getattr_maxsz) 267 268 #define NFS4_dec_removexattr_sz (compound_decode_hdr_maxsz + \ 268 269 decode_sequence_maxsz + \ 269 270 decode_putfh_maxsz + \ 270 - decode_removexattr_maxsz) 271 + decode_removexattr_maxsz + \ 272 + decode_getattr_maxsz) 271 273 272 274 /* 273 275 * These values specify the maximum amount of data that is not ··· 871 869 encode_sequence(xdr, &args->seq_args, &hdr); 872 870 encode_putfh(xdr, args->fh, &hdr); 873 871 encode_removexattr(xdr, args->xattr_name, &hdr); 872 + encode_getfattr(xdr, args->bitmask, &hdr); 874 873 encode_nops(&hdr); 875 874 } 876 875 ··· 1821 1818 goto out; 1822 1819 1823 1820 status = decode_removexattr(xdr, &res->cinfo); 1821 + if (status) 1822 + goto out; 1823 + status = decode_getfattr(xdr, res->fattr, res->server); 1824 1824 out: 1825 1825 return status; 1826 1826 }
+3
include/linux/nfs_xdr.h
··· 1611 1611 struct nfs42_removexattrargs { 1612 1612 struct nfs4_sequence_args seq_args; 1613 1613 struct nfs_fh *fh; 1614 + const u32 *bitmask; 1614 1615 const char *xattr_name; 1615 1616 }; 1616 1617 1617 1618 struct nfs42_removexattrres { 1618 1619 struct nfs4_sequence_res seq_res; 1619 1620 struct nfs4_change_info cinfo; 1621 + struct nfs_fattr *fattr; 1622 + const struct nfs_server *server; 1620 1623 }; 1621 1624 1622 1625 #endif /* CONFIG_NFS_V4_2 */