Skip to content

Commit 50eaa65

Browse files
DaveWysochanskiRHdhowells
authored andcommitted
NFSv4: Fix fscache cookie aux_data to ensure change_attr is included
Commit 402cb8d ("fscache: Attach the index key and aux data to the cookie") added the aux_data and aux_data_len to parameters to fscache_acquire_cookie(), and updated the callers in the NFS client. In the process it modified the aux_data to include the change_attr, but missed adding change_attr to a couple places where aux_data was used. Specifically, when opening a file and the change_attr is not added, the following attempt to lookup an object will fail inside cachefiles_check_object_xattr() = -116 due to nfs_fscache_inode_check_aux() failing memcmp on auxdata and returning FSCACHE_CHECKAUX_OBSOLETE. Fix this by adding nfs_fscache_update_auxdata() to set the auxdata from all relevant fields in the inode, including the change_attr. Fixes: 402cb8d ("fscache: Attach the index key and aux data to the cookie") Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 1575161 commit 50eaa65

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

‎fs/nfs/fscache.c‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
225225
}
226226
}
227227

228+
static void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata,
229+
struct nfs_inode *nfsi)
230+
{
231+
memset(auxdata, 0, sizeof(*auxdata));
232+
auxdata->mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec;
233+
auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
234+
auxdata->ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec;
235+
auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
236+
237+
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
238+
auxdata->change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
239+
}
240+
228241
/*
229242
* Initialise the per-inode cache cookie pointer for an NFS inode.
230243
*/
@@ -238,14 +251,7 @@ void nfs_fscache_init_inode(struct inode *inode)
238251
if (!(nfss->fscache && S_ISREG(inode->i_mode)))
239252
return;
240253

241-
memset(&auxdata, 0, sizeof(auxdata));
242-
auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec;
243-
auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
244-
auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec;
245-
auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
246-
247-
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
248-
auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
254+
nfs_fscache_update_auxdata(&auxdata, nfsi);
249255

250256
nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
251257
&nfs_fscache_inode_object_def,
@@ -265,11 +271,7 @@ void nfs_fscache_clear_inode(struct inode *inode)
265271

266272
dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
267273

268-
memset(&auxdata, 0, sizeof(auxdata));
269-
auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec;
270-
auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
271-
auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec;
272-
auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
274+
nfs_fscache_update_auxdata(&auxdata, nfsi);
273275
fscache_relinquish_cookie(cookie, &auxdata, false);
274276
nfsi->fscache = NULL;
275277
}
@@ -309,11 +311,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
309311
if (!fscache_cookie_valid(cookie))
310312
return;
311313

312-
memset(&auxdata, 0, sizeof(auxdata));
313-
auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec;
314-
auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
315-
auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec;
316-
auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
314+
nfs_fscache_update_auxdata(&auxdata, nfsi);
317315

318316
if (inode_is_open_for_write(inode)) {
319317
dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);

0 commit comments

Comments
 (0)