Skip to content

Commit ee73f9a

Browse files
committed
ext4: convert to new i_version API
Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Theodore Ts'o <tytso@mit.edu>
1 parent e1d747d commit ee73f9a

7 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎fs/ext4/dir.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/fs.h>
2626
#include <linux/buffer_head.h>
2727
#include <linux/slab.h>
28+
#include <linux/iversion.h>
2829
#include "ext4.h"
2930
#include "xattr.h"
3031

@@ -208,7 +209,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
208209
* readdir(2), then we might be pointing to an invalid
209210
* dirent right now. Scan from the start of the block
210211
* to make sure. */
211-
if (file->f_version != inode->i_version) {
212+
if (inode_cmp_iversion(inode, file->f_version)) {
212213
for (i = 0; i < sb->s_blocksize && i < offset; ) {
213214
de = (struct ext4_dir_entry_2 *)
214215
(bh->b_data + i);
@@ -227,7 +228,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
227228
offset = i;
228229
ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1))
229230
| offset;
230-
file->f_version = inode->i_version;
231+
file->f_version = inode_query_iversion(inode);
231232
}
232233

233234
while (ctx->pos < inode->i_size
@@ -568,10 +569,10 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx)
568569
* cached entries.
569570
*/
570571
if ((!info->curr_node) ||
571-
(file->f_version != inode->i_version)) {
572+
inode_cmp_iversion(inode, file->f_version)) {
572573
info->curr_node = NULL;
573574
free_rb_tree_fname(&info->root);
574-
file->f_version = inode->i_version;
575+
file->f_version = inode_query_iversion(inode);
575576
ret = ext4_htree_fill_tree(file, info->curr_hash,
576577
info->curr_minor_hash,
577578
&info->next_hash);

‎fs/ext4/inline.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <linux/iomap.h>
1616
#include <linux/fiemap.h>
17+
#include <linux/iversion.h>
1718

1819
#include "ext4_jbd2.h"
1920
#include "ext4.h"
@@ -1042,7 +1043,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
10421043
*/
10431044
dir->i_mtime = dir->i_ctime = current_time(dir);
10441045
ext4_update_dx_flag(dir);
1045-
dir->i_version++;
1046+
inode_inc_iversion(dir);
10461047
return 1;
10471048
}
10481049

@@ -1494,7 +1495,7 @@ int ext4_read_inline_dir(struct file *file,
14941495
* dirent right now. Scan from the start of the inline
14951496
* dir to make sure.
14961497
*/
1497-
if (file->f_version != inode->i_version) {
1498+
if (inode_cmp_iversion(inode, file->f_version)) {
14981499
for (i = 0; i < extra_size && i < offset;) {
14991500
/*
15001501
* "." is with offset 0 and
@@ -1526,7 +1527,7 @@ int ext4_read_inline_dir(struct file *file,
15261527
}
15271528
offset = i;
15281529
ctx->pos = offset;
1529-
file->f_version = inode->i_version;
1530+
file->f_version = inode_query_iversion(inode);
15301531
}
15311532

15321533
while (ctx->pos < extra_size) {

‎fs/ext4/inode.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4874,12 +4874,14 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
48744874
EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
48754875

48764876
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
4877-
inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
4877+
u64 ivers = le32_to_cpu(raw_inode->i_disk_version);
4878+
48784879
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
48794880
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
4880-
inode->i_version |=
4881+
ivers |=
48814882
(__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
48824883
}
4884+
inode_set_iversion_queried(inode, ivers);
48834885
}
48844886

48854887
ret = 0;
@@ -5165,11 +5167,13 @@ static int ext4_do_update_inode(handle_t *handle,
51655167
}
51665168

51675169
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
5168-
raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
5170+
u64 ivers = inode_peek_iversion(inode);
5171+
5172+
raw_inode->i_disk_version = cpu_to_le32(ivers);
51695173
if (ei->i_extra_isize) {
51705174
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
51715175
raw_inode->i_version_hi =
5172-
cpu_to_le32(inode->i_version >> 32);
5176+
cpu_to_le32(ivers >> 32);
51735177
raw_inode->i_extra_isize =
51745178
cpu_to_le16(ei->i_extra_isize);
51755179
}

‎fs/ext4/ioctl.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/uuid.h>
2020
#include <linux/uaccess.h>
2121
#include <linux/delay.h>
22+
#include <linux/iversion.h>
2223
#include "ext4_jbd2.h"
2324
#include "ext4.h"
2425
#include <linux/fsmap.h>
@@ -144,7 +145,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
144145
i_gid_write(inode_bl, 0);
145146
inode_bl->i_flags = 0;
146147
ei_bl->i_flags = 0;
147-
inode_bl->i_version = 1;
148+
inode_set_iversion(inode_bl, 1);
148149
i_size_write(inode_bl, 0);
149150
inode_bl->i_mode = S_IFREG;
150151
if (ext4_has_feature_extents(sb)) {

‎fs/ext4/namei.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,7 +2956,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
29562956
"empty directory '%.*s' has too many links (%u)",
29572957
dentry->d_name.len, dentry->d_name.name,
29582958
inode->i_nlink);
2959-
inode->i_version++;
2959+
inode_inc_iversion(inode);
29602960
clear_nlink(inode);
29612961
/* There's no need to set i_disksize: the fact that i_nlink is
29622962
* 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,
33623362
ent->de->inode = cpu_to_le32(ino);
33633363
if (ext4_has_feature_filetype(ent->dir->i_sb))
33643364
ent->de->file_type = file_type;
3365-
ent->dir->i_version++;
3365+
inode_inc_iversion(ent->dir);
33663366
ent->dir->i_ctime = ent->dir->i_mtime =
33673367
current_time(ent->dir);
33683368
ext4_mark_inode_dirty(handle, ent->dir);

‎fs/ext4/super.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/dax.h>
4141
#include <linux/cleancache.h>
4242
#include <linux/uaccess.h>
43+
#include <linux/iversion.h>
4344

4445
#include <linux/kthread.h>
4546
#include <linux/freezer.h>
@@ -967,7 +968,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
967968
if (!ei)
968969
return NULL;
969970

970-
ei->vfs_inode.i_version = 1;
971+
inode_set_iversion(&ei->vfs_inode, 1);
971972
spin_lock_init(&ei->i_raw_lock);
972973
INIT_LIST_HEAD(&ei->i_prealloc_list);
973974
spin_lock_init(&ei->i_prealloc_lock);

‎fs/ext4/xattr.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <linux/slab.h>
5757
#include <linux/mbcache.h>
5858
#include <linux/quotaops.h>
59+
#include <linux/iversion.h>
5960
#include "ext4_jbd2.h"
6061
#include "ext4.h"
6162
#include "xattr.h"
@@ -294,13 +295,13 @@ ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size)
294295
static u64 ext4_xattr_inode_get_ref(struct inode *ea_inode)
295296
{
296297
return ((u64)ea_inode->i_ctime.tv_sec << 32) |
297-
((u32)ea_inode->i_version);
298+
(u32) inode_peek_iversion_raw(ea_inode);
298299
}
299300

300301
static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
301302
{
302303
ea_inode->i_ctime.tv_sec = (u32)(ref_count >> 32);
303-
ea_inode->i_version = (u32)ref_count;
304+
inode_set_iversion_raw(ea_inode, ref_count & 0xffffffff);
304305
}
305306

306307
static u32 ext4_xattr_inode_get_hash(struct inode *ea_inode)

0 commit comments

Comments
 (0)