All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist()
       [not found] <cover.1535593351.git.misono.tomohiro@jp.fujitsu.com>
@ 2018-08-30  1:59 ` Misono Tomohiro
  2018-09-06 15:57   ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Misono Tomohiro @ 2018-08-30  1:59 UTC (permalink / raw)
  To: linux-btrfs

Since commit d7df2c796d7e ("Btrfs attach delayed ref updates to
delayed ref heads"), check_delaed_ref() won't return -ENOENT.

In btrfs_cross_ref_exist(), two variable 'ret' and 'ret2' is
originally used to handle -ENOENT error case.

Since the code is not needed anymore, let's just remove 'ret2'.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2d9074295d7f..0c87472d5719 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3139,7 +3139,6 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 {
 	struct btrfs_path *path;
 	int ret;
-	int ret2;
 
 	path = btrfs_alloc_path();
 	if (!path)
@@ -3151,17 +3150,10 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 		if (ret && ret != -ENOENT)
 			goto out;
 
-		ret2 = check_delayed_ref(root, path, objectid,
+		ret = check_delayed_ref(root, path, objectid,
 					 offset, bytenr);
-	} while (ret2 == -EAGAIN);
+	} while (ret == -EAGAIN);
 
-	if (ret2 && ret2 != -ENOENT) {
-		ret = ret2;
-		goto out;
-	}
-
-	if (ret != -ENOENT || ret2 != -ENOENT)
-		ret = 0;
 out:
 	btrfs_free_path(path);
 	if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
-- 
2.17.1

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

* Re: [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist()
  2018-08-30  1:59 ` [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist() Misono Tomohiro
@ 2018-09-06 15:57   ` David Sterba
  2018-09-07  3:01     ` Misono Tomohiro
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2018-09-06 15:57 UTC (permalink / raw)
  To: Misono Tomohiro; +Cc: linux-btrfs

On Thu, Aug 30, 2018 at 10:59:16AM +0900, Misono Tomohiro wrote:
> Since commit d7df2c796d7e ("Btrfs attach delayed ref updates to
> delayed ref heads"), check_delaed_ref() won't return -ENOENT.
> 
> In btrfs_cross_ref_exist(), two variable 'ret' and 'ret2' is
> originally used to handle -ENOENT error case.
> 
> Since the code is not needed anymore, let's just remove 'ret2'.

Good cleanup and the patch would be ok as-is. I've noticed that
check_delayed_ref now returns only two values so it might make sense to
turn it to bool and update the name of check_delayed_ref to make it
clear what the return value means in the loop.

The concern here is that adding another error code in check_delayed_ref
in the future will not be caught in btrfs_cross_ref_exist. Adding an
assert filtering only EAGAIN would be sufficient as this might miss the
extra value in case it'd be an uncommon case.

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

* Re: [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist()
  2018-09-06 15:57   ` David Sterba
@ 2018-09-07  3:01     ` Misono Tomohiro
  2018-09-07 11:17       ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Misono Tomohiro @ 2018-09-07  3:01 UTC (permalink / raw)
  To: dsterba, linux-btrfs

On 2018/09/07 0:57, David Sterba wrote:
> On Thu, Aug 30, 2018 at 10:59:16AM +0900, Misono Tomohiro wrote:
>> Since commit d7df2c796d7e ("Btrfs attach delayed ref updates to
>> delayed ref heads"), check_delaed_ref() won't return -ENOENT.
>>
>> In btrfs_cross_ref_exist(), two variable 'ret' and 'ret2' is
>> originally used to handle -ENOENT error case.
>>
>> Since the code is not needed anymore, let's just remove 'ret2'.
> 
> Good cleanup and the patch would be ok as-is. I've noticed that
> check_delayed_ref now returns only two values so it might make sense to
> turn it to bool and update the name of check_delayed_ref to make it
> clear what the return value means in the loop.

check_delaed_ref()'s return value is:
 0       ... no cross ref found in delayed ref
 1       ... cross ref found in delayed ref
 -EAGAIN ... cannot acquire lock and try again later

so I don't think we can convert it to bool directly or
do you mean we should handle -EAGAIN in check_delayed_ref()?

> The concern here is that adding another error code in check_delayed_ref
> in the future will not be caught in btrfs_cross_ref_exist. Adding an
> assert filtering only EAGAIN would be sufficient as this might miss the
> extra value in case it'd be an uncommon case.

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

* Re: [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist()
  2018-09-07  3:01     ` Misono Tomohiro
@ 2018-09-07 11:17       ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-09-07 11:17 UTC (permalink / raw)
  To: Misono Tomohiro; +Cc: dsterba, linux-btrfs

On Fri, Sep 07, 2018 at 12:01:21PM +0900, Misono Tomohiro wrote:
> On 2018/09/07 0:57, David Sterba wrote:
> > On Thu, Aug 30, 2018 at 10:59:16AM +0900, Misono Tomohiro wrote:
> >> Since commit d7df2c796d7e ("Btrfs attach delayed ref updates to
> >> delayed ref heads"), check_delaed_ref() won't return -ENOENT.
> >>
> >> In btrfs_cross_ref_exist(), two variable 'ret' and 'ret2' is
> >> originally used to handle -ENOENT error case.
> >>
> >> Since the code is not needed anymore, let's just remove 'ret2'.
> > 
> > Good cleanup and the patch would be ok as-is. I've noticed that
> > check_delayed_ref now returns only two values so it might make sense to
> > turn it to bool and update the name of check_delayed_ref to make it
> > clear what the return value means in the loop.
> 
> check_delaed_ref()'s return value is:
>  0       ... no cross ref found in delayed ref
>  1       ... cross ref found in delayed ref
>  -EAGAIN ... cannot acquire lock and try again later
> 
> so I don't think we can convert it to bool directly or
> do you mean we should handle -EAGAIN in check_delayed_ref()?

Oh right, I missed there's ret = 1 in one of the branches, that makes my
point moot.

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

end of thread, other threads:[~2018-09-07 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1535593351.git.misono.tomohiro@jp.fujitsu.com>
2018-08-30  1:59 ` [PATCH] btrfs: extent-tree.c: Remove redundant variable from btrfs_cross_ref_exist() Misono Tomohiro
2018-09-06 15:57   ` David Sterba
2018-09-07  3:01     ` Misono Tomohiro
2018-09-07 11:17       ` David Sterba

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.