linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode
@ 2013-03-17  8:27 Namjae Jeon
  2013-03-18  2:11 ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2013-03-17  8:27 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-f2fs-devel, linux-fsdevel, linux-kernel, Namjae Jeon,
	Namjae Jeon, Amit Sahrawat

From: Namjae Jeon <namjae.jeon@samsung.com>

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.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
---
 fs/f2fs/namei.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index d4a171b..261d821 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -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);
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode
  2013-03-17  8:27 [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode Namjae Jeon
@ 2013-03-18  2:11 ` Jaegeuk Kim
  2013-03-18 12:00   ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2013-03-18  2:11 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: linux-f2fs-devel, linux-fsdevel, linux-kernel, Namjae Jeon,
	Amit Sahrawat

[-- Attachment #1: Type: text/plain, Size: 1698 bytes --]

2013-03-17 (일), 17:27 +0900, Namjae Jeon:
> From: Namjae Jeon <namjae.jeon@samsung.com>
> 
> 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.
> 
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> ---
>  fs/f2fs/namei.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index d4a171b..261d821 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -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);

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,

>  	return ERR_PTR(err);
>  }
>  

-- 
Jaegeuk Kim
Samsung

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode
  2013-03-18  2:11 ` Jaegeuk Kim
@ 2013-03-18 12:00   ` Namjae Jeon
  0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2013-03-18 12:00 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-f2fs-devel, linux-fsdevel, linux-kernel, Namjae Jeon,
	Amit Sahrawat

2013/3/18, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> 2013-03-17 (일), 17:27 +0900, Namjae Jeon:
>> From: Namjae Jeon <namjae.jeon@samsung.com>
>>
>> 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.
>>
>> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
>> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
>> ---
>>  fs/f2fs/namei.c |    5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
>> index d4a171b..261d821 100644
>> --- a/fs/f2fs/namei.c
>> +++ b/fs/f2fs/namei.c
>> @@ -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);
>
> 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,
Okay, I see.
Thanks!
>
>>  	return ERR_PTR(err);
>>  }
>>
>
> --
> Jaegeuk Kim
> Samsung
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-18 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-17  8:27 [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode Namjae Jeon
2013-03-18  2:11 ` Jaegeuk Kim
2013-03-18 12:00   ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).