summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/dir.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-06-20 21:37:02 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2014-07-09 14:04:24 -0700
commitb97a9b5da891ab6aff5a6a19c569c9c4c5563d48 (patch)
treec8e3fe4ddbba29eed50b9bf461cb088b21a13d00 /fs/f2fs/dir.c
parent50732df02eefb39ab414ef655979c2c9b64ad21c (diff)
downloadlinux-b97a9b5da891ab6aff5a6a19c569c9c4c5563d48.tar.bz2
f2fs: introduce f2fs_do_tmpfile for code consistency
This patch adds f2fs_do_tmpfile to eliminate the redundant init_inode_metadata flow. Throught this, we can provide the consistent lock usage, e.g., fi->i_sem, and this will enable better debugging stuffs. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/dir.c')
-rw-r--r--fs/f2fs/dir.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 3677f4124541..fb7e01ed47dc 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -337,8 +337,7 @@ static struct page *init_inode_metadata(struct inode *inode,
struct page *page;
int err;
- if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE) &&
- inode->i_nlink) {
+ if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) {
page = new_inode_page(inode, name);
if (IS_ERR(page))
return page;
@@ -364,7 +363,8 @@ static struct page *init_inode_metadata(struct inode *inode,
set_cold_node(inode, page);
}
- init_dent_inode(name, page);
+ if (name)
+ init_dent_inode(name, page);
/*
* This file should be checkpointed during fsync.
@@ -537,6 +537,27 @@ fail:
return err;
}
+int f2fs_do_tmpfile(struct inode *inode, struct inode *dir)
+{
+ struct page *page;
+ int err = 0;
+
+ down_write(&F2FS_I(inode)->i_sem);
+ page = init_inode_metadata(inode, dir, NULL);
+ if (IS_ERR(page)) {
+ err = PTR_ERR(page);
+ goto fail;
+ }
+ /* we don't need to mark_inode_dirty now */
+ update_inode(inode, page);
+ f2fs_put_page(page, 1);
+
+ clear_inode_flag(F2FS_I(inode), FI_NEW_INODE);
+fail:
+ up_write(&F2FS_I(inode)->i_sem);
+ return err;
+}
+
/*
* It only removes the dentry from the dentry page,corresponding name
* entry in name page does not need to be touched during deletion.