Skip to content

Commit

Permalink
NFS: Cleanup usage of nfs_inode in fscache interface
Browse files Browse the repository at this point in the history
A number of places in the fscache interface used nfs_inode when inode could
be used, simplifying the code.

Signed-off-by: Dave Wysochanski <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
DaveWysochanskiRH authored and Trond Myklebust committed Mar 13, 2022
1 parent b4be2c5 commit 45f3a70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 4 additions & 6 deletions fs/nfs/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ void nfs_fscache_init_inode(struct inode *inode)
if (!(nfss->fscache && S_ISREG(inode->i_mode)))
return;

nfs_fscache_update_auxdata(&auxdata, nfsi);
nfs_fscache_update_auxdata(&auxdata, inode);

nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
0,
nfsi->fh.data, /* index_key */
nfsi->fh.size,
&auxdata, /* aux_data */
sizeof(auxdata),
i_size_read(&nfsi->vfs_inode));
i_size_read(inode));
}

/*
Expand Down Expand Up @@ -220,7 +220,6 @@ void nfs_fscache_clear_inode(struct inode *inode)
void nfs_fscache_open_file(struct inode *inode, struct file *filp)
{
struct nfs_fscache_inode_auxdata auxdata;
struct nfs_inode *nfsi = NFS_I(inode);
struct fscache_cookie *cookie = nfs_i_fscache(inode);
bool open_for_write = inode_is_open_for_write(inode);

Expand All @@ -230,7 +229,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
fscache_use_cookie(cookie, open_for_write);
if (open_for_write) {
dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
nfs_fscache_update_auxdata(&auxdata, nfsi);
nfs_fscache_update_auxdata(&auxdata, inode);
fscache_invalidate(cookie, &auxdata, i_size_read(inode),
FSCACHE_INVAL_DIO_WRITE);
}
Expand All @@ -240,11 +239,10 @@ EXPORT_SYMBOL_GPL(nfs_fscache_open_file);
void nfs_fscache_release_file(struct inode *inode, struct file *filp)
{
struct nfs_fscache_inode_auxdata auxdata;
struct nfs_inode *nfsi = NFS_I(inode);
struct fscache_cookie *cookie = nfs_i_fscache(inode);

if (fscache_cookie_valid(cookie)) {
nfs_fscache_update_auxdata(&auxdata, nfsi);
nfs_fscache_update_auxdata(&auxdata, inode);
fscache_unuse_cookie(cookie, &auxdata, NULL);
}
}
Expand Down
18 changes: 9 additions & 9 deletions fs/nfs/fscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ static inline void nfs_readpage_to_fscache(struct inode *inode,
}

static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata,
struct nfs_inode *nfsi)
struct inode *inode)
{
memset(auxdata, 0, sizeof(*auxdata));
auxdata->mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec;
auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
auxdata->ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec;
auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
auxdata->mtime_sec = inode->i_mtime.tv_sec;
auxdata->mtime_nsec = inode->i_mtime.tv_nsec;
auxdata->ctime_sec = inode->i_ctime.tv_sec;
auxdata->ctime_nsec = inode->i_ctime.tv_nsec;

if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
auxdata->change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
if (NFS_SERVER(inode)->nfs_client->rpc_ops->version == 4)
auxdata->change_attr = inode_peek_iversion_raw(inode);
}

/*
Expand All @@ -107,9 +107,9 @@ static inline void nfs_fscache_invalidate(struct inode *inode, int flags)
struct nfs_inode *nfsi = NFS_I(inode);

if (nfsi->fscache) {
nfs_fscache_update_auxdata(&auxdata, nfsi);
nfs_fscache_update_auxdata(&auxdata, inode);
fscache_invalidate(nfsi->fscache, &auxdata,
i_size_read(&nfsi->vfs_inode), flags);
i_size_read(inode), flags);
}
}

Expand Down

0 comments on commit 45f3a70

Please sign in to comment.