f2fs: introduce f2fs_i_size_write with mark_inode_dirty_sync

This patch introduces f2fs_i_size_write() to call mark_inode_dirty_sync() with
i_size_write().

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2016-05-20 09:22:03 -07:00
parent 91942321e4
commit fc9581c809
7 changed files with 23 additions and 18 deletions

View File

@ -564,7 +564,7 @@ struct page *get_new_data_page(struct inode *inode,
got_it:
if (new_i_size && i_size_read(inode) <
((loff_t)(index + 1) << PAGE_SHIFT)) {
i_size_write(inode, ((loff_t)(index + 1) << PAGE_SHIFT));
f2fs_i_size_write(inode, ((loff_t)(index + 1) << PAGE_SHIFT));
/* Only the directory inode sets new_i_size */
set_inode_flag(inode, FI_UPDATE_DIR);
}
@ -605,7 +605,7 @@ alloc:
fofs = start_bidx_of_node(ofs_of_node(dn->node_page), dn->inode) +
dn->ofs_in_node;
if (i_size_read(dn->inode) < ((loff_t)(fofs + 1) << PAGE_SHIFT))
i_size_write(dn->inode,
f2fs_i_size_write(dn->inode,
((loff_t)(fofs + 1) << PAGE_SHIFT));
return 0;
}
@ -1711,10 +1711,8 @@ static int f2fs_write_end(struct file *file,
set_page_dirty(page);
if (pos + copied > i_size_read(inode)) {
i_size_write(inode, pos + copied);
mark_inode_dirty(inode);
}
if (pos + copied > i_size_read(inode))
f2fs_i_size_write(inode, pos + copied);
f2fs_put_page(page, 1);
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);

View File

@ -686,7 +686,7 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode, struct page *page)
drop_nlink(inode);
if (S_ISDIR(inode->i_mode)) {
drop_nlink(inode);
i_size_write(inode, 0);
f2fs_i_size_write(inode, 0);
}
up_write(&F2FS_I(inode)->i_sem);
update_inode_page(inode);

View File

@ -1556,6 +1556,15 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode)
set_inode_flag(inode, FI_ACL_MODE);
}
static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size)
{
if (i_size_read(inode) == i_size)
return;
i_size_write(inode, i_size);
mark_inode_dirty_sync(inode);
}
static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)
{
if (ri->i_inline & F2FS_INLINE_XATTR)

View File

@ -988,7 +988,7 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
ret = truncate_blocks(inode, new_size, true);
if (!ret)
i_size_write(inode, new_size);
f2fs_i_size_write(inode, new_size);
return ret;
}
@ -1125,8 +1125,7 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
out:
if (!(mode & FALLOC_FL_KEEP_SIZE) && i_size_read(inode) < new_size) {
i_size_write(inode, new_size);
mark_inode_dirty(inode);
f2fs_i_size_write(inode, new_size);
update_inode_page(inode);
}
@ -1186,7 +1185,7 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
truncate_pagecache(inode, offset);
if (!ret)
i_size_write(inode, new_size);
f2fs_i_size_write(inode, new_size);
return ret;
}
@ -1235,8 +1234,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
}
if (!(mode & FALLOC_FL_KEEP_SIZE) && i_size_read(inode) < new_size) {
i_size_write(inode, new_size);
mark_inode_dirty(inode);
f2fs_i_size_write(inode, new_size);
update_inode_page(inode);
}

View File

@ -340,7 +340,7 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
/* update i_size to MAX_INLINE_DATA */
if (i_size_read(inode) < MAX_INLINE_DATA) {
i_size_write(inode, MAX_INLINE_DATA);
f2fs_i_size_write(inode, MAX_INLINE_DATA);
set_inode_flag(inode, FI_UPDATE_DIR);
}
return 0;
@ -402,7 +402,7 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
F2FS_I(dir)->i_current_depth = 1;
if (i_size_read(dir) < PAGE_SIZE) {
i_size_write(dir, PAGE_SIZE);
f2fs_i_size_write(dir, PAGE_SIZE);
set_inode_flag(dir, FI_UPDATE_DIR);
}
@ -493,7 +493,7 @@ recover:
lock_page(ipage);
memcpy(inline_dentry, backup_dentry, MAX_INLINE_DATA);
F2FS_I(dir)->i_current_depth = 0;
i_size_write(dir, MAX_INLINE_DATA);
f2fs_i_size_write(dir, MAX_INLINE_DATA);
update_inode(dir, ipage);
f2fs_put_page(ipage, 1);

View File

@ -175,7 +175,7 @@ static void recover_inode(struct inode *inode, struct page *page)
char *name;
inode->i_mode = le16_to_cpu(raw->i_mode);
i_size_write(inode, le64_to_cpu(raw->i_size));
f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
inode->i_atime.tv_sec = le64_to_cpu(raw->i_mtime);
inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
inode->i_mtime.tv_sec = le64_to_cpu(raw->i_mtime);

View File

@ -568,7 +568,7 @@ static int f2fs_drop_inode(struct inode *inode)
f2fs_destroy_extent_node(inode);
sb_start_intwrite(inode->i_sb);
i_size_write(inode, 0);
f2fs_i_size_write(inode, 0);
if (F2FS_HAS_BLOCKS(inode))
f2fs_truncate(inode, true);