More patch description fixups. Standardize case.
[ext4-patch-queue.git] / inode-version-vfs.patch
blob95ab2b95c18ebe57710079c4a8914f244205a5d9
1 vfs: Add 64 bit i_version support
3 From: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
5 The i_version field of the inode is changed to be a 64-bit counter that
6 is set on every inode creation and that is incremented every time the
7 inode data is modified (similarly to the "ctime" time-stamp).
8 The aim is to fulfill a NFSv4 requirement for rfc3530.
9 This first part concerns the vfs, it converts the 32-bit i_version in
10 the generic inode to a 64-bit, a flag is added in the super block in
11 order to check if the feature is enabled and the i_version is
12 incremented in the vfs.
14 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
15 Signed-off-by: Jean Noel Cordenner <jean-noel.cordenner@bull.net>
16 Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
17 ---
19 fs/afs/dir.c | 9 +++++----
20 fs/afs/inode.c | 3 ++-
21 fs/inode.c | 22 ++++++++++++++++++++++
22 include/linux/fs.h | 5 ++++-
23 4 files changed, 33 insertions(+), 6 deletions(-)
26 diff --git a/fs/afs/dir.c b/fs/afs/dir.c
27 index 33fe39a..0cc3597 100644
28 --- a/fs/afs/dir.c
29 +++ b/fs/afs/dir.c
30 @@ -546,11 +546,11 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
31 dentry->d_op = &afs_fs_dentry_operations;
33 d_add(dentry, inode);
34 - _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }",
35 + _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }",
36 fid.vnode,
37 fid.unique,
38 dentry->d_inode->i_ino,
39 - dentry->d_inode->i_version);
40 + (unsigned long long)dentry->d_inode->i_version);
42 return NULL;
44 @@ -630,9 +630,10 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
45 * been deleted and replaced, and the original vnode ID has
46 * been reused */
47 if (fid.unique != vnode->fid.unique) {
48 - _debug("%s: file deleted (uq %u -> %u I:%lu)",
49 + _debug("%s: file deleted (uq %u -> %u I:%llu)",
50 dentry->d_name.name, fid.unique,
51 - vnode->fid.unique, dentry->d_inode->i_version);
52 + vnode->fid.unique,
53 + (unsigned long long)dentry->d_inode->i_version);
54 spin_lock(&vnode->lock);
55 set_bit(AFS_VNODE_DELETED, &vnode->flags);
56 spin_unlock(&vnode->lock);
57 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
58 index d196840..84750c8 100644
59 --- a/fs/afs/inode.c
60 +++ b/fs/afs/inode.c
61 @@ -301,7 +301,8 @@ int afs_getattr(struct vfsmount *mnt, struct dentry *dentry,
63 inode = dentry->d_inode;
65 - _enter("{ ino=%lu v=%lu }", inode->i_ino, inode->i_version);
66 + _enter("{ ino=%lu v=%llu }", inode->i_ino,
67 + (unsigned long long)inode->i_version);
69 generic_fillattr(inode, stat);
70 return 0;
71 diff --git a/fs/inode.c b/fs/inode.c
72 index ed35383..b48324a 100644
73 --- a/fs/inode.c
74 +++ b/fs/inode.c
75 @@ -1243,6 +1243,23 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
76 EXPORT_SYMBOL(touch_atime);
78 /**
79 + * inode_inc_iversion - increments i_version
80 + * @inode: inode that need to be updated
81 + *
82 + * Every time the inode is modified, the i_version field
83 + * will be incremented.
84 + * The filesystem has to be mounted with i_version flag
85 + *
86 + */
88 +void inode_inc_iversion(struct inode *inode)
90 + spin_lock(&inode->i_lock);
91 + inode->i_version++;
92 + spin_unlock(&inode->i_lock);
95 +/**
96 * file_update_time - update mtime and ctime time
97 * @file: file accessed
99 @@ -1276,6 +1293,11 @@ void file_update_time(struct file *file)
100 sync_it = 1;
103 + if (IS_I_VERSION(inode)) {
104 + inode_inc_iversion(inode);
105 + sync_it = 1;
108 if (sync_it)
109 mark_inode_dirty_sync(inode);
111 diff --git a/include/linux/fs.h b/include/linux/fs.h
112 index b3ec4a4..94cf5d8 100644
113 --- a/include/linux/fs.h
114 +++ b/include/linux/fs.h
115 @@ -124,6 +124,7 @@ extern int dir_notify_enable;
116 #define MS_SHARED (1<<20) /* change to shared */
117 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
118 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
119 +#define MS_I_VERSION (1<<23) /* Update inode I_version field */
120 #define MS_ACTIVE (1<<30)
121 #define MS_NOUSER (1<<31)
123 @@ -173,6 +174,7 @@ extern int dir_notify_enable;
124 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
125 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
126 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
127 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
129 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
130 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
131 @@ -599,7 +601,7 @@ struct inode {
132 uid_t i_uid;
133 gid_t i_gid;
134 dev_t i_rdev;
135 - unsigned long i_version;
136 + u64 i_version;
137 loff_t i_size;
138 #ifdef __NEED_I_SIZE_ORDERED
139 seqcount_t i_size_seqcount;
140 @@ -1394,6 +1396,7 @@ static inline void inode_dec_link_count(struct inode *inode)
141 mark_inode_dirty(inode);
144 +extern void inode_inc_iversion(struct inode *inode);
145 extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
146 static inline void file_accessed(struct file *file)