Commit beb2a5ec386e5ce6891ebd1c06b913da04354b40

Authored by Trond Myklebust
1 parent 969b7f2522

NFSv4: Ensure change attribute returned by GETATTR callback conforms to spec

According to RFC3530 we're supposed to cache the change attribute
 at the time the client receives a write delegation.
 If the inode is clean, a CB_GETATTR callback by the server to the
 client is supposed to return the cached change attribute.
 If, OTOH, the inode is dirty, the client should bump the cached
 change attribute by 1.

 Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 3 changed files with 5 additions and 1 deletions Side-by-side Diff

fs/nfs/callback_proc.c
... ... @@ -35,7 +35,9 @@
35 35 if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0)
36 36 goto out_iput;
37 37 res->size = i_size_read(inode);
38   - res->change_attr = NFS_CHANGE_ATTR(inode);
  38 + res->change_attr = delegation->change_attr;
  39 + if (nfsi->npages != 0)
  40 + res->change_attr++;
39 41 res->ctime = inode->i_ctime;
40 42 res->mtime = inode->i_mtime;
41 43 res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
... ... @@ -131,6 +131,7 @@
131 131 sizeof(delegation->stateid.data));
132 132 delegation->type = res->delegation_type;
133 133 delegation->maxsize = res->maxsize;
  134 + delegation->change_attr = nfsi->change_attr;
134 135 delegation->cred = get_rpccred(cred);
135 136 delegation->inode = inode;
136 137  
... ... @@ -21,6 +21,7 @@
21 21 #define NFS_DELEGATION_NEED_RECLAIM 1
22 22 long flags;
23 23 loff_t maxsize;
  24 + __u64 change_attr;
24 25 };
25 26  
26 27 int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);