All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated
@ 2017-02-25 11:23 Kinglong Mee
  2017-02-27  2:21 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Kinglong Mee @ 2017-02-25 11:23 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, 
the new_nid is not allocated (no alloc_nid is called).

       if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
                if (!alloc_nid(sbi, &new_nid))
                        return -ENOSPC;

Although it's harmless calling alloc_nid_failed, it's better drop them.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/f2fs/xattr.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 7298a44..fd9dc99 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 		/* no need to use xattr node block */
 		if (hsize <= inline_size) {
 			err = truncate_xattr_node(inode, ipage);
-			alloc_nid_failed(sbi, new_nid);
+			f2fs_bug_on(sbi, new_nid);
 			return err;
 		}
 	}
 
 	/* write to xattr node block */
 	if (F2FS_I(inode)->i_xattr_nid) {
+		f2fs_bug_on(sbi, new_nid);
 		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
-		if (IS_ERR(xpage)) {
-			alloc_nid_failed(sbi, new_nid);
+		if (IS_ERR(xpage))
 			return PTR_ERR(xpage);
-		}
-		f2fs_bug_on(sbi, new_nid);
+
 		f2fs_wait_on_page_writeback(xpage, NODE, true);
 	} else {
 		struct dnode_of_data dn;
-- 
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

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

* Re: [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated
  2017-02-25 11:23 [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated Kinglong Mee
@ 2017-02-27  2:21 ` Chao Yu
  2017-02-27  3:08   ` Kinglong Mee
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2017-02-27  2:21 UTC (permalink / raw)
  To: Kinglong Mee, Jaegeuk Kim; +Cc: linux-f2fs-devel

On 2017/2/25 19:23, Kinglong Mee wrote:
> If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, 
> the new_nid is not allocated (no alloc_nid is called).
> 
>        if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
>                 if (!alloc_nid(sbi, &new_nid))
>                         return -ENOSPC;
> 
> Although it's harmless calling alloc_nid_failed, it's better drop them.
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/f2fs/xattr.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 7298a44..fd9dc99 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
>  		/* no need to use xattr node block */
>  		if (hsize <= inline_size) {
>  			err = truncate_xattr_node(inode, ipage);
> -			alloc_nid_failed(sbi, new_nid);

Should keep this since new_nid was assigned above?

> +			f2fs_bug_on(sbi, new_nid);
>  			return err;
>  		}
>  	}
>  
>  	/* write to xattr node block */
>  	if (F2FS_I(inode)->i_xattr_nid) {
> +		f2fs_bug_on(sbi, new_nid);
>  		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
> -		if (IS_ERR(xpage)) {
> -			alloc_nid_failed(sbi, new_nid);
> +		if (IS_ERR(xpage))
>  			return PTR_ERR(xpage);
> -		}
> -		f2fs_bug_on(sbi, new_nid);

Cleanup here looks good to me.

Thanks,

> +
>  		f2fs_wait_on_page_writeback(xpage, NODE, true);
>  	} else {
>  		struct dnode_of_data dn;
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

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

* Re: [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated
  2017-02-27  2:21 ` Chao Yu
@ 2017-02-27  3:08   ` Kinglong Mee
  2017-02-27  3:16     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Kinglong Mee @ 2017-02-27  3:08 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim; +Cc: linux-f2fs-devel

On 2/27/2017 10:21, Chao Yu wrote:
> On 2017/2/25 19:23, Kinglong Mee wrote:
>> If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, 
>> the new_nid is not allocated (no alloc_nid is called).
>>
>>        if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
>>                 if (!alloc_nid(sbi, &new_nid))
>>                         return -ENOSPC;
>>
>> Although it's harmless calling alloc_nid_failed, it's better drop them.
>>
>> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
>> ---
>>  fs/f2fs/xattr.c | 9 ++++-----
>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
>> index 7298a44..fd9dc99 100644
>> --- a/fs/f2fs/xattr.c
>> +++ b/fs/f2fs/xattr.c
>> @@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
>>  		/* no need to use xattr node block */
>>  		if (hsize <= inline_size) {
>>  			err = truncate_xattr_node(inode, ipage);
>> -			alloc_nid_failed(sbi, new_nid);
> 
> Should keep this since new_nid was assigned above?

alloc_nid is called when, 


403         if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
404                 if (!alloc_nid(sbi, &new_nid))
405                         return -ENOSPC;

if (hsize <= inline_size), alloc_nid isn't called.

thanks,
Kinglong Mee
> 
>> +			f2fs_bug_on(sbi, new_nid);
>>  			return err;
>>  		}
>>  	}
>>  
>>  	/* write to xattr node block */
>>  	if (F2FS_I(inode)->i_xattr_nid) {
>> +		f2fs_bug_on(sbi, new_nid);
>>  		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
>> -		if (IS_ERR(xpage)) {
>> -			alloc_nid_failed(sbi, new_nid);
>> +		if (IS_ERR(xpage))
>>  			return PTR_ERR(xpage);
>> -		}
>> -		f2fs_bug_on(sbi, new_nid);
> 
> Cleanup here looks good to me.
> 
> Thanks,
> 
>> +
>>  		f2fs_wait_on_page_writeback(xpage, NODE, true);
>>  	} else {
>>  		struct dnode_of_data dn;
>>
> 
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

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

* Re: [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated
  2017-02-27  3:08   ` Kinglong Mee
@ 2017-02-27  3:16     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2017-02-27  3:16 UTC (permalink / raw)
  To: Kinglong Mee, Jaegeuk Kim; +Cc: linux-f2fs-devel

On 2017/2/27 11:08, Kinglong Mee wrote:
> On 2/27/2017 10:21, Chao Yu wrote:
>> On 2017/2/25 19:23, Kinglong Mee wrote:
>>> If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, 
>>> the new_nid is not allocated (no alloc_nid is called).
>>>
>>>        if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
>>>                 if (!alloc_nid(sbi, &new_nid))
>>>                         return -ENOSPC;
>>>
>>> Although it's harmless calling alloc_nid_failed, it's better drop them.
>>>
>>> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
>>> ---
>>>  fs/f2fs/xattr.c | 9 ++++-----
>>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
>>> index 7298a44..fd9dc99 100644
>>> --- a/fs/f2fs/xattr.c
>>> +++ b/fs/f2fs/xattr.c
>>> @@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
>>>  		/* no need to use xattr node block */
>>>  		if (hsize <= inline_size) {
>>>  			err = truncate_xattr_node(inode, ipage);
>>> -			alloc_nid_failed(sbi, new_nid);
>>
>> Should keep this since new_nid was assigned above?
> 
> alloc_nid is called when, 
> 
> 
> 403         if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
> 404                 if (!alloc_nid(sbi, &new_nid))
> 405                         return -ENOSPC;
> 
> if (hsize <= inline_size), alloc_nid isn't called.

You're right, I can confirm that. :)

Thanks,

> 
> thanks,
> Kinglong Mee
>>
>>> +			f2fs_bug_on(sbi, new_nid);
>>>  			return err;
>>>  		}
>>>  	}
>>>  
>>>  	/* write to xattr node block */
>>>  	if (F2FS_I(inode)->i_xattr_nid) {
>>> +		f2fs_bug_on(sbi, new_nid);
>>>  		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
>>> -		if (IS_ERR(xpage)) {
>>> -			alloc_nid_failed(sbi, new_nid);
>>> +		if (IS_ERR(xpage))
>>>  			return PTR_ERR(xpage);
>>> -		}
>>> -		f2fs_bug_on(sbi, new_nid);
>>
>> Cleanup here looks good to me.
>>
>> Thanks,
>>
>>> +
>>>  		f2fs_wait_on_page_writeback(xpage, NODE, true);
>>>  	} else {
>>>  		struct dnode_of_data dn;
>>>
>>
>>
> 
> .
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2017-02-27  3:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-25 11:23 [PATCH 3/3] f2fs: drop calling alloc_nid_failed when no nid is allocated Kinglong Mee
2017-02-27  2:21 ` Chao Yu
2017-02-27  3:08   ` Kinglong Mee
2017-02-27  3:16     ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.