linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/9 v2] fix warn_on for replace cancel
@ 2018-11-20 11:56 Anand Jain
  2018-11-20 11:56 ` [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish Anand Jain
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anand Jain @ 2018-11-20 11:56 UTC (permalink / raw)
  To: linux-btrfs

These two patches were sent as part of
   [PATCH 0/9 v2] fix replace-start and replace-cancel racing
before but as these aren't integrated so I am sending these again.

The patch [1] which is in misc-next, calls btrfs_dev_replace_finishing()
after replace is canceled, so the ret argument passed to the
btrfs_dev_replace_finishing() is -ECANCEL, which is not a real error.
So these patches quieten the warn and error log if its -ECANCEL.

These should be integrated otherwise we see the WARN_ON and btrfs_error()
after replace cancel.

[1] 
08bdfc3a0611 btrfs: fix use-after-free due to race between replace start and cancel

Anand Jain (2):
  btrfs: quieten warn if the replace is canceled at finish
  btrfs: user requsted replace cancel is not an error

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

* [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish
  2018-11-20 11:56 [PATCH RESEND 0/9 v2] fix warn_on for replace cancel Anand Jain
@ 2018-11-20 11:56 ` Anand Jain
  2018-11-20 13:29   ` David Sterba
  2018-11-20 11:56 ` [PATCH RESEND v2 2/2] btrfs: user requsted replace cancel is not an error Anand Jain
  2018-11-20 13:35 ` [PATCH RESEND 0/9 v2] fix warn_on for replace cancel David Sterba
  2 siblings, 1 reply; 5+ messages in thread
From: Anand Jain @ 2018-11-20 11:56 UTC (permalink / raw)
  To: linux-btrfs

When we successfully cancel the replace its scrub returns -ECANCELED,
which then passed to btrfs_dev_replace_finishing(), it cleans up based
on the scrub returned status and propagates the same -ECANCELED back
the parent function. As of now only user can cancel the replace-scrub,
so its ok to quieten the warn here.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
[fix: quieten spelling]
v1->v2: Use the condition within the WARN_ON()

 fs/btrfs/dev-replace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 1dc8e86546db..9031a362921a 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -497,7 +497,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
 	ret = btrfs_dev_replace_finishing(fs_info, ret);
 	if (ret == -EINPROGRESS) {
 		ret = BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS;
-	} else {
+	} else if (ret != -ECANCELED) {
 		WARN_ON(ret);
 	}
 
@@ -954,7 +954,7 @@ static int btrfs_dev_replace_kthread(void *data)
 			      btrfs_device_get_total_bytes(dev_replace->srcdev),
 			      &dev_replace->scrub_progress, 0, 1);
 	ret = btrfs_dev_replace_finishing(fs_info, ret);
-	WARN_ON(ret);
+	WARN_ON(ret && ret != -ECANCELED);
 
 	clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
 	return 0;
-- 
1.8.3.1


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

* [PATCH RESEND v2 2/2] btrfs: user requsted replace cancel is not an error
  2018-11-20 11:56 [PATCH RESEND 0/9 v2] fix warn_on for replace cancel Anand Jain
  2018-11-20 11:56 ` [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish Anand Jain
@ 2018-11-20 11:56 ` Anand Jain
  2018-11-20 13:35 ` [PATCH RESEND 0/9 v2] fix warn_on for replace cancel David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2018-11-20 11:56 UTC (permalink / raw)
  To: linux-btrfs

As of now only user requested replace cancel can cancel the replace-scrub
so no need to log error for it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: none.

 fs/btrfs/dev-replace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 9031a362921a..40a0942b4659 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -622,7 +622,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 								src_device,
 								tgt_device);
 	} else {
-		btrfs_err_in_rcu(fs_info,
+		if (scrub_ret != -ECANCELED)
+			btrfs_err_in_rcu(fs_info,
 				 "btrfs_scrub_dev(%s, %llu, %s) failed %d",
 				 btrfs_dev_name(src_device),
 				 src_device->devid,
-- 
1.8.3.1


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

* Re: [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish
  2018-11-20 11:56 ` [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish Anand Jain
@ 2018-11-20 13:29   ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-11-20 13:29 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Tue, Nov 20, 2018 at 07:56:15PM +0800, Anand Jain wrote:
> When we successfully cancel the replace its scrub returns -ECANCELED,
> which then passed to btrfs_dev_replace_finishing(), it cleans up based
> on the scrub returned status and propagates the same -ECANCELED back
> the parent function. As of now only user can cancel the replace-scrub,
> so its ok to quieten the warn here.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Ok for getting rid if the ECANCELED warning, though it would be better
to replace the WARN_ON too.

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

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

* Re: [PATCH RESEND 0/9 v2] fix warn_on for replace cancel
  2018-11-20 11:56 [PATCH RESEND 0/9 v2] fix warn_on for replace cancel Anand Jain
  2018-11-20 11:56 ` [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish Anand Jain
  2018-11-20 11:56 ` [PATCH RESEND v2 2/2] btrfs: user requsted replace cancel is not an error Anand Jain
@ 2018-11-20 13:35 ` David Sterba
  2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-11-20 13:35 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Tue, Nov 20, 2018 at 07:56:14PM +0800, Anand Jain wrote:
> These two patches were sent as part of
>    [PATCH 0/9 v2] fix replace-start and replace-cancel racing
> before but as these aren't integrated so I am sending these again.
> 
> The patch [1] which is in misc-next, calls btrfs_dev_replace_finishing()
> after replace is canceled, so the ret argument passed to the
> btrfs_dev_replace_finishing() is -ECANCEL, which is not a real error.
> So these patches quieten the warn and error log if its -ECANCEL.
> 
> These should be integrated otherwise we see the WARN_ON and btrfs_error()
> after replace cancel.
> 
> [1] 
> 08bdfc3a0611 btrfs: fix use-after-free due to race between replace start and cancel
> 
> Anand Jain (2):
>   btrfs: quieten warn if the replace is canceled at finish
>   btrfs: user requsted replace cancel is not an error

Thanks, patches added to misc-next, right after the other dev-replace
patches.

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

end of thread, other threads:[~2018-11-20 13:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-20 11:56 [PATCH RESEND 0/9 v2] fix warn_on for replace cancel Anand Jain
2018-11-20 11:56 ` [PATCH RESEND v2 1/2] btrfs: quieten warn if replace is canceled at finish Anand Jain
2018-11-20 13:29   ` David Sterba
2018-11-20 11:56 ` [PATCH RESEND v2 2/2] btrfs: user requsted replace cancel is not an error Anand Jain
2018-11-20 13:35 ` [PATCH RESEND 0/9 v2] fix warn_on for replace cancel David Sterba

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).