All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
@ 2018-05-30  2:07 Su Yue
  2018-05-30  2:55 ` Su Yue
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Su Yue @ 2018-05-30  2:07 UTC (permalink / raw)
  To: linux-btrfs; +Cc: suy.fnst

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 44093f92a532..99df6199dffc 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3311,7 +3311,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOENT;
+		return -ENOMEM;
 
 	do {
 		ret = check_committed_ref(root, path, objectid,
-- 
2.17.0




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

* Re: [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30  2:07 [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist() Su Yue
@ 2018-05-30  2:55 ` Su Yue
  2018-05-30  6:24 ` Nikolay Borisov
  2018-05-30  6:49 ` [PATCH v2] " Su Yue
  2 siblings, 0 replies; 7+ messages in thread
From: Su Yue @ 2018-05-30  2:55 UTC (permalink / raw)
  To: linux-btrfs

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

Sorry, the [PATCH 2/2] is abandoned. So the subject should be [PATCH].


On 05/30/2018 10:07 AM, Su Yue wrote:
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 44093f92a532..99df6199dffc 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3311,7 +3311,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
>  
>  	path = btrfs_alloc_path();
>  	if (!path)
> -		return -ENOENT;
> +		return -ENOMEM;
>  
>  	do {
>  		ret = check_committed_ref(root, path, objectid,
> 



[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1791 bytes --]

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

* Re: [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30  2:07 [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist() Su Yue
  2018-05-30  2:55 ` Su Yue
@ 2018-05-30  6:24 ` Nikolay Borisov
  2018-05-30  6:49 ` [PATCH v2] " Su Yue
  2 siblings, 0 replies; 7+ messages in thread
From: Nikolay Borisov @ 2018-05-30  6:24 UTC (permalink / raw)
  To: Su Yue, linux-btrfs



On 30.05.2018 05:07, Su Yue wrote:
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>

Generally we discourage commit log messages. I understand this patch is
very obvious but put a sentence saying that btrfs_alloc_path can fail
due to enomem hence returning enomem is the right ting to do here.
> ---
>  fs/btrfs/extent-tree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 44093f92a532..99df6199dffc 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3311,7 +3311,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
>  
>  	path = btrfs_alloc_path();
>  	if (!path)
> -		return -ENOENT;
> +		return -ENOMEM;
>  
>  	do {
>  		ret = check_committed_ref(root, path, objectid,
> 

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

* Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30  6:49 ` [PATCH v2] " Su Yue
@ 2018-05-30  6:44   ` Nikolay Borisov
  2018-05-30 15:33   ` David Sterba
  1 sibling, 0 replies; 7+ messages in thread
From: Nikolay Borisov @ 2018-05-30  6:44 UTC (permalink / raw)
  To: Su Yue, linux-btrfs



On 30.05.2018 09:49, Su Yue wrote:
> btrfs_alloc_path() may fail due to no enough memory,
> so let the function return -ENOMEM instead of -ENOENT is better.
> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> Changelog:
> v2:
>   Add commit message to describe the patch. Thanks Nikolay.
>   
>  fs/btrfs/extent-tree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 44093f92a532..99df6199dffc 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3311,7 +3311,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
>  
>  	path = btrfs_alloc_path();
>  	if (!path)
> -		return -ENOENT;
> +		return -ENOMEM;
>  
>  	do {
>  		ret = check_committed_ref(root, path, objectid,
> 

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

* [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30  2:07 [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist() Su Yue
  2018-05-30  2:55 ` Su Yue
  2018-05-30  6:24 ` Nikolay Borisov
@ 2018-05-30  6:49 ` Su Yue
  2018-05-30  6:44   ` Nikolay Borisov
  2018-05-30 15:33   ` David Sterba
  2 siblings, 2 replies; 7+ messages in thread
From: Su Yue @ 2018-05-30  6:49 UTC (permalink / raw)
  To: linux-btrfs; +Cc: suy.fnst

btrfs_alloc_path() may fail due to no enough memory,
so let the function return -ENOMEM instead of -ENOENT is better.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
Changelog:
v2:
  Add commit message to describe the patch. Thanks Nikolay.
  
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 44093f92a532..99df6199dffc 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3311,7 +3311,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOENT;
+		return -ENOMEM;
 
 	do {
 		ret = check_committed_ref(root, path, objectid,
-- 
2.17.0




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

* Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30  6:49 ` [PATCH v2] " Su Yue
  2018-05-30  6:44   ` Nikolay Borisov
@ 2018-05-30 15:33   ` David Sterba
  2018-05-31  2:08     ` Su Yue
  1 sibling, 1 reply; 7+ messages in thread
From: David Sterba @ 2018-05-30 15:33 UTC (permalink / raw)
  To: Su Yue; +Cc: linux-btrfs

On Wed, May 30, 2018 at 02:49:10PM +0800, Su Yue wrote:
> btrfs_alloc_path() may fail due to no enough memory,
> so let the function return -ENOMEM instead of -ENOENT is better.
> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.com>

Thanks. I've audited all return codes after failed path allocation, this
was the only one not matching.

The return code of btrfs_cross_ref_exist should be also distinguished at
the call sites, as both places expect only the ENOENT but should not
react to ENOMEM as if it were ENOENT.

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

* Re: [PATCH v2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist()
  2018-05-30 15:33   ` David Sterba
@ 2018-05-31  2:08     ` Su Yue
  0 siblings, 0 replies; 7+ messages in thread
From: Su Yue @ 2018-05-31  2:08 UTC (permalink / raw)
  To: dsterba, linux-btrfs

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



On 05/30/2018 11:33 PM, David Sterba wrote:
> On Wed, May 30, 2018 at 02:49:10PM +0800, Su Yue wrote:
>> btrfs_alloc_path() may fail due to no enough memory,
>> so let the function return -ENOMEM instead of -ENOENT is better.
>>
>> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> 
> Reviewed-by: David Sterba <dsterba@suse.com>
> 
> Thanks. I've audited all return codes after failed path allocation, this
> was the only one not matching.
> 
> The return code of btrfs_cross_ref_exist should be also distinguished at
> the call sites, as both places expect only the ENOENT but should not
> react to ENOMEM as if it were ENOENT.
> 
Not quite understand the last paragraph. Is necessary to send patches to
make the two callers to distinguish ENOMEM and ENOENT?

Thanks,
Su

> 



[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1791 bytes --]

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

end of thread, other threads:[~2018-05-31  2:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-30  2:07 [PATCH 1/2] btrfs: returns -ENOMEM if path allocation failed in btrfs_cross_ref_exist() Su Yue
2018-05-30  2:55 ` Su Yue
2018-05-30  6:24 ` Nikolay Borisov
2018-05-30  6:49 ` [PATCH v2] " Su Yue
2018-05-30  6:44   ` Nikolay Borisov
2018-05-30 15:33   ` David Sterba
2018-05-31  2:08     ` Su Yue

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.