Commit 1eb5d98f authored by Jeff Layton's avatar Jeff Layton

nfs: convert to new i_version API

For NFS, we just use the "raw" API since the i_version is mostly
managed by the server. The exception there is when the client
holds a write delegation, but we only need to bump it once
there anyway to handle CB_GETATTR.
Tested-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
parent ee73f9a5
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/iversion.h>
#include <linux/nfs4.h> #include <linux/nfs4.h>
#include <linux/nfs_fs.h> #include <linux/nfs_fs.h>
...@@ -347,7 +348,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct ...@@ -347,7 +348,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
nfs4_stateid_copy(&delegation->stateid, &res->delegation); nfs4_stateid_copy(&delegation->stateid, &res->delegation);
delegation->type = res->delegation_type; delegation->type = res->delegation_type;
delegation->pagemod_limit = res->pagemod_limit; delegation->pagemod_limit = res->pagemod_limit;
delegation->change_attr = inode->i_version; delegation->change_attr = inode_peek_iversion_raw(inode);
delegation->cred = get_rpccred(cred); delegation->cred = get_rpccred(cred);
delegation->inode = inode; delegation->inode = inode;
delegation->flags = 1<<NFS_DELEGATION_REFERENCED; delegation->flags = 1<<NFS_DELEGATION_REFERENCED;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/nfs_fs.h> #include <linux/nfs_fs.h>
#include <linux/nfs_fs_sb.h> #include <linux/nfs_fs_sb.h>
#include <linux/in6.h> #include <linux/in6.h>
#include <linux/iversion.h>
#include "internal.h" #include "internal.h"
#include "fscache.h" #include "fscache.h"
...@@ -211,7 +212,7 @@ static uint16_t nfs_fscache_inode_get_aux(const void *cookie_netfs_data, ...@@ -211,7 +212,7 @@ static uint16_t nfs_fscache_inode_get_aux(const void *cookie_netfs_data,
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
auxdata.change_attr = nfsi->vfs_inode.i_version; auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
if (bufmax > sizeof(auxdata)) if (bufmax > sizeof(auxdata))
bufmax = sizeof(auxdata); bufmax = sizeof(auxdata);
...@@ -243,7 +244,7 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data, ...@@ -243,7 +244,7 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
auxdata.ctime = nfsi->vfs_inode.i_ctime; auxdata.ctime = nfsi->vfs_inode.i_ctime;
if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
auxdata.change_attr = nfsi->vfs_inode.i_version; auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
if (memcmp(data, &auxdata, datalen) != 0) if (memcmp(data, &auxdata, datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;
......
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/iversion.h>
#include "nfs4_fs.h" #include "nfs4_fs.h"
#include "callback.h" #include "callback.h"
...@@ -483,7 +483,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st ...@@ -483,7 +483,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
memset(&inode->i_atime, 0, sizeof(inode->i_atime)); memset(&inode->i_atime, 0, sizeof(inode->i_atime));
memset(&inode->i_mtime, 0, sizeof(inode->i_mtime)); memset(&inode->i_mtime, 0, sizeof(inode->i_mtime));
memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
inode->i_version = 0; inode_set_iversion_raw(inode, 0);
inode->i_size = 0; inode->i_size = 0;
clear_nlink(inode); clear_nlink(inode);
inode->i_uid = make_kuid(&init_user_ns, -2); inode->i_uid = make_kuid(&init_user_ns, -2);
...@@ -508,7 +508,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st ...@@ -508,7 +508,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
else if (nfs_server_capable(inode, NFS_CAP_CTIME)) else if (nfs_server_capable(inode, NFS_CAP_CTIME))
nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR); nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR);
if (fattr->valid & NFS_ATTR_FATTR_CHANGE) if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
inode->i_version = fattr->change_attr; inode_set_iversion_raw(inode, fattr->change_attr);
else else
nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR
| NFS_INO_REVAL_PAGECACHE); | NFS_INO_REVAL_PAGECACHE);
...@@ -1289,8 +1289,8 @@ static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr ...@@ -1289,8 +1289,8 @@ static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr
if ((fattr->valid & NFS_ATTR_FATTR_PRECHANGE) if ((fattr->valid & NFS_ATTR_FATTR_PRECHANGE)
&& (fattr->valid & NFS_ATTR_FATTR_CHANGE) && (fattr->valid & NFS_ATTR_FATTR_CHANGE)
&& inode->i_version == fattr->pre_change_attr) { && !inode_cmp_iversion_raw(inode, fattr->pre_change_attr)) {
inode->i_version = fattr->change_attr; inode_set_iversion_raw(inode, fattr->change_attr);
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA); nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
ret |= NFS_INO_INVALID_ATTR; ret |= NFS_INO_INVALID_ATTR;
...@@ -1348,7 +1348,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat ...@@ -1348,7 +1348,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
if (!nfs_file_has_buffered_writers(nfsi)) { if (!nfs_file_has_buffered_writers(nfsi)) {
/* Verify a few of the more important attributes */ /* Verify a few of the more important attributes */
if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && inode->i_version != fattr->change_attr) if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && inode_cmp_iversion_raw(inode, fattr->change_attr))
invalid |= NFS_INO_INVALID_ATTR | NFS_INO_REVAL_PAGECACHE; invalid |= NFS_INO_INVALID_ATTR | NFS_INO_REVAL_PAGECACHE;
if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&inode->i_mtime, &fattr->mtime)) if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&inode->i_mtime, &fattr->mtime))
...@@ -1642,7 +1642,7 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa ...@@ -1642,7 +1642,7 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa
} }
if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 &&
(fattr->valid & NFS_ATTR_FATTR_PRECHANGE) == 0) { (fattr->valid & NFS_ATTR_FATTR_PRECHANGE) == 0) {
fattr->pre_change_attr = inode->i_version; fattr->pre_change_attr = inode_peek_iversion_raw(inode);
fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; fattr->valid |= NFS_ATTR_FATTR_PRECHANGE;
} }
if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 && if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 &&
...@@ -1778,7 +1778,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -1778,7 +1778,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
/* More cache consistency checks */ /* More cache consistency checks */
if (fattr->valid & NFS_ATTR_FATTR_CHANGE) { if (fattr->valid & NFS_ATTR_FATTR_CHANGE) {
if (inode->i_version != fattr->change_attr) { if (inode_cmp_iversion_raw(inode, fattr->change_attr)) {
dprintk("NFS: change_attr change on server for file %s/%ld\n", dprintk("NFS: change_attr change on server for file %s/%ld\n",
inode->i_sb->s_id, inode->i_ino); inode->i_sb->s_id, inode->i_ino);
/* Could it be a race with writeback? */ /* Could it be a race with writeback? */
...@@ -1790,7 +1790,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -1790,7 +1790,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
nfs_force_lookup_revalidate(inode); nfs_force_lookup_revalidate(inode);
} }
inode->i_version = fattr->change_attr; inode_set_iversion_raw(inode, fattr->change_attr);
} }
} else { } else {
nfsi->cache_validity |= save_cache_validity; nfsi->cache_validity |= save_cache_validity;
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <linux/xattr.h> #include <linux/xattr.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/iversion.h>
#include "nfs4_fs.h" #include "nfs4_fs.h"
#include "delegation.h" #include "delegation.h"
...@@ -1045,16 +1046,16 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo, ...@@ -1045,16 +1046,16 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo,
spin_lock(&dir->i_lock); spin_lock(&dir->i_lock);
nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
if (cinfo->atomic && cinfo->before == dir->i_version) { if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(dir)) {
nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
nfsi->attrtimeo_timestamp = jiffies; nfsi->attrtimeo_timestamp = jiffies;
} else { } else {
nfs_force_lookup_revalidate(dir); nfs_force_lookup_revalidate(dir);
if (cinfo->before != dir->i_version) if (cinfo->before != inode_peek_iversion_raw(dir))
nfsi->cache_validity |= NFS_INO_INVALID_ACCESS | nfsi->cache_validity |= NFS_INO_INVALID_ACCESS |
NFS_INO_INVALID_ACL; NFS_INO_INVALID_ACL;
} }
dir->i_version = cinfo->after; inode_set_iversion_raw(dir, cinfo->after);
nfsi->read_cache_jiffies = timestamp; nfsi->read_cache_jiffies = timestamp;
nfsi->attr_gencount = nfs_inc_attr_generation_counter(); nfsi->attr_gencount = nfs_inc_attr_generation_counter();
nfs_fscache_invalidate(dir); nfs_fscache_invalidate(dir);
...@@ -2454,7 +2455,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) ...@@ -2454,7 +2455,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
data->file_created = true; data->file_created = true;
else if (o_res->cinfo.before != o_res->cinfo.after) else if (o_res->cinfo.before != o_res->cinfo.after)
data->file_created = true; data->file_created = true;
if (data->file_created || dir->i_version != o_res->cinfo.after) if (data->file_created ||
inode_peek_iversion_raw(dir) != o_res->cinfo.after)
update_changeattr(dir, &o_res->cinfo, update_changeattr(dir, &o_res->cinfo,
o_res->f_attr->time_start); o_res->f_attr->time_start);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define _TRACE_NFS_H #define _TRACE_NFS_H
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include <linux/iversion.h>
#define nfs_show_file_type(ftype) \ #define nfs_show_file_type(ftype) \
__print_symbolic(ftype, \ __print_symbolic(ftype, \
...@@ -61,7 +62,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event, ...@@ -61,7 +62,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event,
__entry->dev = inode->i_sb->s_dev; __entry->dev = inode->i_sb->s_dev;
__entry->fileid = nfsi->fileid; __entry->fileid = nfsi->fileid;
__entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
__entry->version = inode->i_version; __entry->version = inode_peek_iversion_raw(inode);
), ),
TP_printk( TP_printk(
...@@ -100,7 +101,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event_done, ...@@ -100,7 +101,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event_done,
__entry->fileid = nfsi->fileid; __entry->fileid = nfsi->fileid;
__entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
__entry->type = nfs_umode_to_dtype(inode->i_mode); __entry->type = nfs_umode_to_dtype(inode->i_mode);
__entry->version = inode->i_version; __entry->version = inode_peek_iversion_raw(inode);
__entry->size = i_size_read(inode); __entry->size = i_size_read(inode);
__entry->nfsi_flags = nfsi->flags; __entry->nfsi_flags = nfsi->flags;
__entry->cache_validity = nfsi->cache_validity; __entry->cache_validity = nfsi->cache_validity;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/iversion.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
...@@ -753,11 +754,8 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) ...@@ -753,11 +754,8 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
*/ */
spin_lock(&mapping->private_lock); spin_lock(&mapping->private_lock);
if (!nfs_have_writebacks(inode) && if (!nfs_have_writebacks(inode) &&
NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE)) { NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE))
spin_lock(&inode->i_lock); inode_inc_iversion_raw(inode);
inode->i_version++;
spin_unlock(&inode->i_lock);
}
if (likely(!PageSwapCache(req->wb_page))) { if (likely(!PageSwapCache(req->wb_page))) {
set_bit(PG_MAPPED, &req->wb_flags); set_bit(PG_MAPPED, &req->wb_flags);
SetPagePrivate(req->wb_page); SetPagePrivate(req->wb_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment