提交 b56ab837 编写于 作者: J Jaegeuk Kim

f2fs: avoid mark_inode_dirty

Let's check inode's dirtiness before calling mark_inode_dirty.
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 a2ee0a30
...@@ -384,7 +384,7 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage, ...@@ -384,7 +384,7 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
if (error) if (error)
return error; return error;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
if (default_acl) { if (default_acl) {
error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl, error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl,
......
...@@ -300,7 +300,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, ...@@ -300,7 +300,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
set_page_dirty(page); set_page_dirty(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(dir); f2fs_mark_inode_dirty_sync(dir);
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
} }
...@@ -452,7 +452,7 @@ void update_parent_metadata(struct inode *dir, struct inode *inode, ...@@ -452,7 +452,7 @@ void update_parent_metadata(struct inode *dir, struct inode *inode,
clear_inode_flag(inode, FI_NEW_INODE); clear_inode_flag(inode, FI_NEW_INODE);
} }
dir->i_mtime = dir->i_ctime = CURRENT_TIME; dir->i_mtime = dir->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(dir); f2fs_mark_inode_dirty_sync(dir);
if (F2FS_I(dir)->i_current_depth != current_depth) if (F2FS_I(dir)->i_current_depth != current_depth)
f2fs_i_depth_write(dir, current_depth); f2fs_i_depth_write(dir, current_depth);
...@@ -704,7 +704,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, ...@@ -704,7 +704,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
set_page_dirty(page); set_page_dirty(page);
dir->i_ctime = dir->i_mtime = CURRENT_TIME; dir->i_ctime = dir->i_mtime = CURRENT_TIME;
mark_inode_dirty_sync(dir); f2fs_mark_inode_dirty_sync(dir);
if (inode) if (inode)
f2fs_drop_nlink(dir, inode); f2fs_drop_nlink(dir, inode);
......
...@@ -172,7 +172,7 @@ static void __drop_largest_extent(struct inode *inode, ...@@ -172,7 +172,7 @@ static void __drop_largest_extent(struct inode *inode,
if (fofs < largest->fofs + largest->len && fofs + len > largest->fofs) { if (fofs < largest->fofs + largest->len && fofs + len > largest->fofs) {
largest->len = 0; largest->len = 0;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
} }
......
...@@ -506,12 +506,13 @@ static inline bool __is_front_mergeable(struct extent_info *cur, ...@@ -506,12 +506,13 @@ static inline bool __is_front_mergeable(struct extent_info *cur,
return __is_extent_mergeable(cur, front); return __is_extent_mergeable(cur, front);
} }
extern void f2fs_mark_inode_dirty_sync(struct inode *);
static inline void __try_update_largest_extent(struct inode *inode, static inline void __try_update_largest_extent(struct inode *inode,
struct extent_tree *et, struct extent_node *en) struct extent_tree *et, struct extent_node *en)
{ {
if (en->ei.len > et->largest.len) { if (en->ei.len > et->largest.len) {
et->largest = en->ei; et->largest = en->ei;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
} }
...@@ -1551,7 +1552,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode, ...@@ -1551,7 +1552,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,
return; return;
case FI_DATA_EXIST: case FI_DATA_EXIST:
case FI_INLINE_DOTS: case FI_INLINE_DOTS:
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
} }
...@@ -1578,7 +1579,7 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode) ...@@ -1578,7 +1579,7 @@ static inline void set_acl_inode(struct inode *inode, umode_t mode)
{ {
F2FS_I(inode)->i_acl_mode = mode; F2FS_I(inode)->i_acl_mode = mode;
set_inode_flag(inode, FI_ACL_MODE); set_inode_flag(inode, FI_ACL_MODE);
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void f2fs_i_links_write(struct inode *inode, bool inc) static inline void f2fs_i_links_write(struct inode *inode, bool inc)
...@@ -1587,7 +1588,7 @@ static inline void f2fs_i_links_write(struct inode *inode, bool inc) ...@@ -1587,7 +1588,7 @@ static inline void f2fs_i_links_write(struct inode *inode, bool inc)
inc_nlink(inode); inc_nlink(inode);
else else
drop_nlink(inode); drop_nlink(inode);
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void f2fs_i_blocks_write(struct inode *inode, static inline void f2fs_i_blocks_write(struct inode *inode,
...@@ -1598,7 +1599,7 @@ static inline void f2fs_i_blocks_write(struct inode *inode, ...@@ -1598,7 +1599,7 @@ static inline void f2fs_i_blocks_write(struct inode *inode,
inode->i_blocks = add ? inode->i_blocks + diff : inode->i_blocks = add ? inode->i_blocks + diff :
inode->i_blocks - diff; inode->i_blocks - diff;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
if (clean || recover) if (clean || recover)
set_inode_flag(inode, FI_AUTO_RECOVER); set_inode_flag(inode, FI_AUTO_RECOVER);
} }
...@@ -1612,7 +1613,7 @@ static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size) ...@@ -1612,7 +1613,7 @@ static inline void f2fs_i_size_write(struct inode *inode, loff_t i_size)
return; return;
i_size_write(inode, i_size); i_size_write(inode, i_size);
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
if (clean || recover) if (clean || recover)
set_inode_flag(inode, FI_AUTO_RECOVER); set_inode_flag(inode, FI_AUTO_RECOVER);
} }
...@@ -1627,19 +1628,19 @@ static inline bool f2fs_skip_inode_update(struct inode *inode) ...@@ -1627,19 +1628,19 @@ static inline bool f2fs_skip_inode_update(struct inode *inode)
static inline void f2fs_i_depth_write(struct inode *inode, unsigned int depth) static inline void f2fs_i_depth_write(struct inode *inode, unsigned int depth)
{ {
F2FS_I(inode)->i_current_depth = depth; F2FS_I(inode)->i_current_depth = depth;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void f2fs_i_xnid_write(struct inode *inode, nid_t xnid) static inline void f2fs_i_xnid_write(struct inode *inode, nid_t xnid)
{ {
F2FS_I(inode)->i_xattr_nid = xnid; F2FS_I(inode)->i_xattr_nid = xnid;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void f2fs_i_pino_write(struct inode *inode, nid_t pino) static inline void f2fs_i_pino_write(struct inode *inode, nid_t pino)
{ {
F2FS_I(inode)->i_pino = pino; F2FS_I(inode)->i_pino = pino;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri) static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri)
...@@ -1767,13 +1768,13 @@ static inline int is_file(struct inode *inode, int type) ...@@ -1767,13 +1768,13 @@ static inline int is_file(struct inode *inode, int type)
static inline void set_file(struct inode *inode, int type) static inline void set_file(struct inode *inode, int type)
{ {
F2FS_I(inode)->i_advise |= type; F2FS_I(inode)->i_advise |= type;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline void clear_file(struct inode *inode, int type) static inline void clear_file(struct inode *inode, int type)
{ {
F2FS_I(inode)->i_advise &= ~type; F2FS_I(inode)->i_advise &= ~type;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static inline int f2fs_readonly(struct super_block *sb) static inline int f2fs_readonly(struct super_block *sb)
...@@ -1920,6 +1921,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -1920,6 +1921,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
/* /*
* super.c * super.c
*/ */
int f2fs_inode_dirtied(struct inode *);
void f2fs_inode_synced(struct inode *); void f2fs_inode_synced(struct inode *);
int f2fs_commit_super(struct f2fs_sb_info *, bool); int f2fs_commit_super(struct f2fs_sb_info *, bool);
int f2fs_sync_fs(struct super_block *, int); int f2fs_sync_fs(struct super_block *, int);
......
...@@ -263,7 +263,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, ...@@ -263,7 +263,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
} }
if (need_inode_block_update(sbi, ino)) { if (need_inode_block_update(sbi, ino)) {
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
f2fs_write_inode(inode, NULL); f2fs_write_inode(inode, NULL);
goto sync_nodes; goto sync_nodes;
} }
...@@ -631,7 +631,7 @@ int f2fs_truncate(struct inode *inode) ...@@ -631,7 +631,7 @@ int f2fs_truncate(struct inode *inode)
return err; return err;
inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
return 0; return 0;
} }
...@@ -721,7 +721,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -721,7 +721,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
} }
} }
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
return err; return err;
} }
...@@ -1276,7 +1276,7 @@ static long f2fs_fallocate(struct file *file, int mode, ...@@ -1276,7 +1276,7 @@ static long f2fs_fallocate(struct file *file, int mode,
if (!ret) { if (!ret) {
inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
} }
......
...@@ -569,7 +569,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page, ...@@ -569,7 +569,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
dir->i_ctime = dir->i_mtime = CURRENT_TIME; dir->i_ctime = dir->i_mtime = CURRENT_TIME;
mark_inode_dirty_sync(dir); f2fs_mark_inode_dirty_sync(dir);
if (inode) if (inode)
f2fs_drop_nlink(dir, inode); f2fs_drop_nlink(dir, inode);
......
...@@ -18,6 +18,13 @@ ...@@ -18,6 +18,13 @@
#include <trace/events/f2fs.h> #include <trace/events/f2fs.h>
void f2fs_mark_inode_dirty_sync(struct inode *inode)
{
if (f2fs_inode_dirtied(inode))
return;
mark_inode_dirty_sync(inode);
}
void f2fs_set_inode_flags(struct inode *inode) void f2fs_set_inode_flags(struct inode *inode)
{ {
unsigned int flags = F2FS_I(inode)->i_flags; unsigned int flags = F2FS_I(inode)->i_flags;
...@@ -35,7 +42,7 @@ void f2fs_set_inode_flags(struct inode *inode) ...@@ -35,7 +42,7 @@ void f2fs_set_inode_flags(struct inode *inode)
new_fl |= S_DIRSYNC; new_fl |= S_DIRSYNC;
inode_set_flags(inode, new_fl, inode_set_flags(inode, new_fl,
S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
} }
static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri) static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
......
...@@ -757,7 +757,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -757,7 +757,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
up_write(&F2FS_I(old_inode)->i_sem); up_write(&F2FS_I(old_inode)->i_sem);
old_inode->i_ctime = CURRENT_TIME; old_inode->i_ctime = CURRENT_TIME;
mark_inode_dirty_sync(old_inode); f2fs_mark_inode_dirty_sync(old_inode);
f2fs_delete_entry(old_entry, old_page, old_dir, NULL); f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
...@@ -909,7 +909,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -909,7 +909,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
f2fs_i_links_write(old_dir, old_nlink > 0); f2fs_i_links_write(old_dir, old_nlink > 0);
up_write(&F2FS_I(old_dir)->i_sem); up_write(&F2FS_I(old_dir)->i_sem);
} }
mark_inode_dirty_sync(old_dir); f2fs_mark_inode_dirty_sync(old_dir);
/* update directory entry info of new dir inode */ /* update directory entry info of new dir inode */
f2fs_set_link(new_dir, new_entry, new_page, old_inode); f2fs_set_link(new_dir, new_entry, new_page, old_inode);
...@@ -924,7 +924,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -924,7 +924,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
f2fs_i_links_write(new_dir, new_nlink > 0); f2fs_i_links_write(new_dir, new_nlink > 0);
up_write(&F2FS_I(new_dir)->i_sem); up_write(&F2FS_I(new_dir)->i_sem);
} }
mark_inode_dirty_sync(new_dir); f2fs_mark_inode_dirty_sync(new_dir);
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
......
...@@ -625,29 +625,14 @@ static int f2fs_drop_inode(struct inode *inode) ...@@ -625,29 +625,14 @@ static int f2fs_drop_inode(struct inode *inode)
return generic_drop_inode(inode); return generic_drop_inode(inode);
} }
/* int f2fs_inode_dirtied(struct inode *inode)
* f2fs_dirty_inode() is called from __mark_inode_dirty()
*
* We should call set_dirty_inode to write the dirty inode through write_inode.
*/
static void f2fs_dirty_inode(struct inode *inode, int flags)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
if (inode->i_ino == F2FS_NODE_INO(sbi) ||
inode->i_ino == F2FS_META_INO(sbi))
return;
if (flags == I_DIRTY_TIME)
return;
if (is_inode_flag_set(inode, FI_AUTO_RECOVER))
clear_inode_flag(inode, FI_AUTO_RECOVER);
spin_lock(&sbi->inode_lock[DIRTY_META]); spin_lock(&sbi->inode_lock[DIRTY_META]);
if (is_inode_flag_set(inode, FI_DIRTY_INODE)) { if (is_inode_flag_set(inode, FI_DIRTY_INODE)) {
spin_unlock(&sbi->inode_lock[DIRTY_META]); spin_unlock(&sbi->inode_lock[DIRTY_META]);
return; return 1;
} }
set_inode_flag(inode, FI_DIRTY_INODE); set_inode_flag(inode, FI_DIRTY_INODE);
...@@ -656,6 +641,8 @@ static void f2fs_dirty_inode(struct inode *inode, int flags) ...@@ -656,6 +641,8 @@ static void f2fs_dirty_inode(struct inode *inode, int flags)
inc_page_count(sbi, F2FS_DIRTY_IMETA); inc_page_count(sbi, F2FS_DIRTY_IMETA);
stat_inc_dirty_inode(sbi, DIRTY_META); stat_inc_dirty_inode(sbi, DIRTY_META);
spin_unlock(&sbi->inode_lock[DIRTY_META]); spin_unlock(&sbi->inode_lock[DIRTY_META]);
return 0;
} }
void f2fs_inode_synced(struct inode *inode) void f2fs_inode_synced(struct inode *inode)
...@@ -675,6 +662,28 @@ void f2fs_inode_synced(struct inode *inode) ...@@ -675,6 +662,28 @@ void f2fs_inode_synced(struct inode *inode)
spin_unlock(&sbi->inode_lock[DIRTY_META]); spin_unlock(&sbi->inode_lock[DIRTY_META]);
} }
/*
* f2fs_dirty_inode() is called from __mark_inode_dirty()
*
* We should call set_dirty_inode to write the dirty inode through write_inode.
*/
static void f2fs_dirty_inode(struct inode *inode, int flags)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
if (inode->i_ino == F2FS_NODE_INO(sbi) ||
inode->i_ino == F2FS_META_INO(sbi))
return;
if (flags == I_DIRTY_TIME)
return;
if (is_inode_flag_set(inode, FI_AUTO_RECOVER))
clear_inode_flag(inode, FI_AUTO_RECOVER);
f2fs_inode_dirtied(inode);
}
static void f2fs_i_callback(struct rcu_head *head) static void f2fs_i_callback(struct rcu_head *head)
{ {
struct inode *inode = container_of(head, struct inode, i_rcu); struct inode *inode = container_of(head, struct inode, i_rcu);
......
...@@ -106,7 +106,7 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler, ...@@ -106,7 +106,7 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
return -EINVAL; return -EINVAL;
F2FS_I(inode)->i_advise |= *(char *)value; F2FS_I(inode)->i_advise |= *(char *)value;
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
return 0; return 0;
} }
...@@ -547,7 +547,7 @@ static int __f2fs_setxattr(struct inode *inode, int index, ...@@ -547,7 +547,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
if (index == F2FS_XATTR_INDEX_ENCRYPTION && if (index == F2FS_XATTR_INDEX_ENCRYPTION &&
!strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT)) !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT))
f2fs_set_encrypted_inode(inode); f2fs_set_encrypted_inode(inode);
mark_inode_dirty_sync(inode); f2fs_mark_inode_dirty_sync(inode);
exit: exit:
kzfree(base_addr); kzfree(base_addr);
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册