f2fs: remove nid_free from f2fs_new_inode
Subsystems (2)
PATCH 4/5 f2fs: remove nid_free from f2fs_new_inode
From: Namjae Jeon <[email protected]>
we can remove nid_free from new inode allocation part. Since, nid_free is used to check if we need to free alloced nid in case of failure.
Instead we can directly call alloc_nid_failed from that point, as there is no dependency in that path.
--- fs/f2fs/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/f2fs/namei.c +1 -4
@@ -24,7 +24,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)struct f2fs_sb_info *sbi =F2FS_SB (sb);nid_t ino;struct inode *inode; -bool nid_free = false;int err; inode =new_inode (sb);
@@ -58,7 +57,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) err =insert_inode_locked (inode);if (err) { err = -EINVAL ; - nid_free = true; +alloc_nid_failed (sbi, ino); goto out; }
@@ -70,8 +69,6 @@ out:unlock_new_inode (inode); fail:iput (inode); -if (nid_free) -alloc_nid_failed (sbi, ino);return ERR_PTR (err); }
Signature · 1 line
1.7.9.5
2013-03-17 (일), 17:27 +0900, Namjae Jeon:
Quoted 36 lines
From: Namjae Jeon <[email protected]>
we can remove
nid_freefrom new inode allocation part. Since,nid_freeis used to check if we need to free alloced nid in case of failure.
Instead we can directly callalloc_nid_failedfrom that point, as there is no dependency in that path.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Amit Sahrawat <[email protected]>--- fs/f2fs/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/f2fs/namei.c +1
-2@@ -24,7 +24,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)struct f2fs_sb_info *sbi =F2FS_SB (sb);nid_t ino;struct inode *inode; -bool nid_free = false;int err; inode =new_inode (sb);@@ -58,7 +57,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) err =insert_inode_locked (inode);if (err) { err = -EINVAL ; - nid_free = true; +alloc_nid_failed (sbi, ino); goto out; }
fs/f2fs/namei.c out: · line 74
Quoted 5 lines
fs/f2fs/namei.c +0
-2@@ -70,8 +69,6 @@ out:unlock_new_inode (inode); fail:iput (inode); -if (nid_free) -alloc_nid_failed (sbi, ino);
We should call alloc_nid_failed() after iput() is completed. Otherwise, another f2fs_new_inode() is able to get this just-released nid before iput(). In such a case, insert_inode_locked() can return -EBUSY or iput() can free this newly allocated inode due to the i_lock race.
Thanks,
Quoted 3 lines
fs/f2fs/namei.c +0
-0return ERR_PTR (err); }
Signature · 2 lines
Jaegeuk Kim Samsung
2013/3/18, Jaegeuk Kim <[email protected]>:
Quoted 38 lines
2013-03-17 (일), 17:27 +0900, Namjae Jeon:
Quoted 37 lines
From: Namjae Jeon <[email protected]>
we can remove
nid_freefrom new inode allocation part. Since,nid_freeis used to check if we need to free alloced nid in case of failure.
Instead we can directly callalloc_nid_failedfrom that point, as there is no dependency in that path.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Amit Sahrawat <[email protected]>--- fs/f2fs/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)fs/f2fs/namei.c +0
-1@@ -24,7 +24,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)struct f2fs_sb_info *sbi =F2FS_SB (sb);nid_t ino;struct inode *inode; -bool nid_free = false;int err;fs/f2fs/namei.c +1
-1inode =new_inode (sb);@@ -58,7 +57,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) err =insert_inode_locked (inode);if (err) { err = -EINVAL ; - nid_free = true; +alloc_nid_failed (sbi, ino); goto out; }
Quoted 13 lines
fs/f2fs/namei.c out: · line 74
Quoted 6 lines
fs/f2fs/namei.c +0
-2@@ -70,8 +69,6 @@ out:unlock_new_inode (inode); fail:iput (inode); -if (nid_free) -alloc_nid_failed (sbi, ino);We should call
alloc_nid_failed()afteriput()is completed. Otherwise, anotherf2fs_new_inode()is able to get this just-released nid beforeiput(). In such a case,insert_inode_locked()can return-EBUSYoriput()can free this newly allocated inode due to thei_lockrace.
Thanks,
Okay, I see.
Thanks!
Quoted 9 lines
fs/f2fs/namei.c out: · line 74
Quoted 4 lines
fs/f2fs/namei.c +0
-0return ERR_PTR (err); }--
Jaegeuk Kim
Samsung