ext4: convert to new i_version API
authorJeff Layton <jlayton@redhat.com>
Tue, 9 Jan 2018 13:21:39 +0000 (08:21 -0500)
committerJeff Layton <jlayton@redhat.com>
Mon, 29 Jan 2018 11:42:21 +0000 (06:42 -0500)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/dir.c
fs/ext4/inline.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/namei.c
fs/ext4/super.c
fs/ext4/xattr.c

index d5babc9f222bf38fdfd782fac8fd825b1bae4bf5..afda0a0499cedfa609f43dceaa53668003141a79 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/slab.h>
+#include <linux/iversion.h>
 #include "ext4.h"
 #include "xattr.h"
 
@@ -208,7 +209,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
                 * readdir(2), then we might be pointing to an invalid
                 * dirent right now.  Scan from the start of the block
                 * to make sure. */
-               if (file->f_version != inode->i_version) {
+               if (inode_cmp_iversion(inode, file->f_version)) {
                        for (i = 0; i < sb->s_blocksize && i < offset; ) {
                                de = (struct ext4_dir_entry_2 *)
                                        (bh->b_data + i);
@@ -227,7 +228,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
                        offset = i;
                        ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1))
                                | offset;
-                       file->f_version = inode->i_version;
+                       file->f_version = inode_query_iversion(inode);
                }
 
                while (ctx->pos < inode->i_size
@@ -568,10 +569,10 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx)
                 * cached entries.
                 */
                if ((!info->curr_node) ||
-                   (file->f_version != inode->i_version)) {
+                   inode_cmp_iversion(inode, file->f_version)) {
                        info->curr_node = NULL;
                        free_rb_tree_fname(&info->root);
-                       file->f_version = inode->i_version;
+                       file->f_version = inode_query_iversion(inode);
                        ret = ext4_htree_fill_tree(file, info->curr_hash,
                                                   info->curr_minor_hash,
                                                   &info->next_hash);
index 1367553c43bb3134bed3596a66951ceab0d86628..a8b987b7117356cfee659fe57b9b9379a4fc3751 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/iomap.h>
 #include <linux/fiemap.h>
+#include <linux/iversion.h>
 
 #include "ext4_jbd2.h"
 #include "ext4.h"
@@ -1042,7 +1043,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
         */
        dir->i_mtime = dir->i_ctime = current_time(dir);
        ext4_update_dx_flag(dir);
-       dir->i_version++;
+       inode_inc_iversion(dir);
        return 1;
 }
 
@@ -1494,7 +1495,7 @@ int ext4_read_inline_dir(struct file *file,
         * dirent right now.  Scan from the start of the inline
         * dir to make sure.
         */
-       if (file->f_version != inode->i_version) {
+       if (inode_cmp_iversion(inode, file->f_version)) {
                for (i = 0; i < extra_size && i < offset;) {
                        /*
                         * "." is with offset 0 and
@@ -1526,7 +1527,7 @@ int ext4_read_inline_dir(struct file *file,
                }
                offset = i;
                ctx->pos = offset;
-               file->f_version = inode->i_version;
+               file->f_version = inode_query_iversion(inode);
        }
 
        while (ctx->pos < extra_size) {
index fa5d8bc52d2df527a78c4369780f5b15a9edf580..1b0d54b372f2345211201d8b515102d830a84240 100644 (file)
@@ -4874,12 +4874,14 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
        EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
 
        if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
-               inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
+               u64 ivers = le32_to_cpu(raw_inode->i_disk_version);
+
                if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
                        if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
-                               inode->i_version |=
+                               ivers |=
                    (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
                }
+               inode_set_iversion_queried(inode, ivers);
        }
 
        ret = 0;
@@ -5165,11 +5167,13 @@ static int ext4_do_update_inode(handle_t *handle,
        }
 
        if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
-               raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
+               u64 ivers = inode_peek_iversion(inode);
+
+               raw_inode->i_disk_version = cpu_to_le32(ivers);
                if (ei->i_extra_isize) {
                        if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
                                raw_inode->i_version_hi =
-                                       cpu_to_le32(inode->i_version >> 32);
+                                       cpu_to_le32(ivers >> 32);
                        raw_inode->i_extra_isize =
                                cpu_to_le16(ei->i_extra_isize);
                }
index 1eec25014f62ff0367807f6644a9e29e2662c48b..7e99ad02f1baaca241a2d04c5b01d6d9eba7a12f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/uuid.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
+#include <linux/iversion.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include <linux/fsmap.h>
@@ -144,7 +145,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
                i_gid_write(inode_bl, 0);
                inode_bl->i_flags = 0;
                ei_bl->i_flags = 0;
-               inode_bl->i_version = 1;
+               inode_set_iversion(inode_bl, 1);
                i_size_write(inode_bl, 0);
                inode_bl->i_mode = S_IFREG;
                if (ext4_has_feature_extents(sb)) {
index bcf0dff517be2ca111551fdace3eca3063266819..55f6e38de5baa3c9bacf7b5000118266ac071349 100644 (file)
@@ -2956,7 +2956,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
                             "empty directory '%.*s' has too many links (%u)",
                             dentry->d_name.len, dentry->d_name.name,
                             inode->i_nlink);
-       inode->i_version++;
+       inode_inc_iversion(inode);
        clear_nlink(inode);
        /* There's no need to set i_disksize: the fact that i_nlink is
         * zero will ensure that the right thing happens during any
@@ -3362,7 +3362,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
        ent->de->inode = cpu_to_le32(ino);
        if (ext4_has_feature_filetype(ent->dir->i_sb))
                ent->de->file_type = file_type;
-       ent->dir->i_version++;
+       inode_inc_iversion(ent->dir);
        ent->dir->i_ctime = ent->dir->i_mtime =
                current_time(ent->dir);
        ext4_mark_inode_dirty(handle, ent->dir);
index 7c46693a14d763d53b84eec9602f4a854918bb4d..5de959fb0244291b2b29874a242c049fd8e6bcf0 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/dax.h>
 #include <linux/cleancache.h>
 #include <linux/uaccess.h>
+#include <linux/iversion.h>
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
@@ -967,7 +968,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
        if (!ei)
                return NULL;
 
-       ei->vfs_inode.i_version = 1;
+       inode_set_iversion(&ei->vfs_inode, 1);
        spin_lock_init(&ei->i_raw_lock);
        INIT_LIST_HEAD(&ei->i_prealloc_list);
        spin_lock_init(&ei->i_prealloc_lock);
index 218a7ba57819411cd9dd12271a0005e963157dbb..63656dbafdc4519f40bfb885aec78b65d66cc967 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/slab.h>
 #include <linux/mbcache.h>
 #include <linux/quotaops.h>
+#include <linux/iversion.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include "xattr.h"
@@ -294,13 +295,13 @@ ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size)
 static u64 ext4_xattr_inode_get_ref(struct inode *ea_inode)
 {
        return ((u64)ea_inode->i_ctime.tv_sec << 32) |
-              ((u32)ea_inode->i_version);
+               (u32) inode_peek_iversion_raw(ea_inode);
 }
 
 static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
 {
        ea_inode->i_ctime.tv_sec = (u32)(ref_count >> 32);
-       ea_inode->i_version = (u32)ref_count;
+       inode_set_iversion_raw(ea_inode, ref_count & 0xffffffff);
 }
 
 static u32 ext4_xattr_inode_get_hash(struct inode *ea_inode)