1 From c05cefcc72416a37eba5a2b35f0704ed758a9145 Mon Sep 17 00:00:00 2001
2 From: Chuck Lever <chuck.lever@oracle.com>
3 Date: Sun, 5 Nov 2017 15:45:22 -0500
4 Subject: nfs: Fix ugly referral attributes
6 From: Chuck Lever <chuck.lever@oracle.com>
8 commit c05cefcc72416a37eba5a2b35f0704ed758a9145 upstream.
10 Before traversing a referral and performing a mount, the mounted-on
11 directory looks strange:
13 dr-xr-xr-x. 2 4294967294 4294967294 0 Dec 31 1969 dir.0
15 nfs4_get_referral is wiping out any cached attributes with what was
16 returned via GETATTR(fs_locations), but the bit mask for that
17 operation does not request any file attributes.
19 Retrieve owner and timestamp information so that the memcpy in
20 nfs4_get_referral fills in more attributes.
23 - Don't request attributes that the client unconditionally replaces
24 - Request only MOUNTED_ON_FILEID or FILEID attribute, not both
25 - encode_fs_locations() doesn't use the third bitmask word
27 Fixes: 6b97fd3da1ea ("NFSv4: Follow a referral")
28 Suggested-by: Pradeep Thomas <pradeepthomas@gmail.com>
29 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
30 Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 fs/nfs/nfs4proc.c | 18 ++++++++----------
35 1 file changed, 8 insertions(+), 10 deletions(-)
37 --- a/fs/nfs/nfs4proc.c
38 +++ b/fs/nfs/nfs4proc.c
39 @@ -242,15 +242,12 @@ const u32 nfs4_fsinfo_bitmap[3] = { FATT
42 const u32 nfs4_fs_locations_bitmap[3] = {
44 - | FATTR4_WORD0_CHANGE
49 | FATTR4_WORD0_FS_LOCATIONS,
51 - | FATTR4_WORD1_NUMLINKS
52 - | FATTR4_WORD1_OWNER
54 | FATTR4_WORD1_OWNER_GROUP
56 | FATTR4_WORD1_SPACE_USED
57 @@ -6351,9 +6348,7 @@ static int _nfs4_proc_fs_locations(struc
60 struct nfs_server *server = NFS_SERVER(dir);
62 - [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
65 struct nfs4_fs_locations_arg args = {
66 .dir_fh = NFS_FH(dir),
68 @@ -6372,12 +6367,15 @@ static int _nfs4_proc_fs_locations(struc
70 dprintk("%s: start\n", __func__);
72 + bitmask[0] = nfs4_fattr_bitmap[0] | FATTR4_WORD0_FS_LOCATIONS;
73 + bitmask[1] = nfs4_fattr_bitmap[1];
75 /* Ask for the fileid of the absent filesystem if mounted_on_fileid
77 if (NFS_SERVER(dir)->attr_bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
78 - bitmask[1] |= FATTR4_WORD1_MOUNTED_ON_FILEID;
79 + bitmask[0] &= ~FATTR4_WORD0_FILEID;
81 - bitmask[0] |= FATTR4_WORD0_FILEID;
82 + bitmask[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
84 nfs_fattr_init(&fs_locations->fattr);
85 fs_locations->server = server;