From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/9] btrfs: replace cancel is successful if scrub cancel is successful
Date: Wed, 7 Nov 2018 14:26:50 +0200 [thread overview]
Message-ID: <c0f9ac16-bd00-610c-86c2-af3fd598e23a@suse.com> (raw)
In-Reply-To: <c97e7a6b-5fee-9f9d-2f7b-1e3fad586b7b@suse.com>
On 7.11.18 г. 14:25 ч., Nikolay Borisov wrote:
>
>
> On 7.11.18 г. 13:43 ч., Anand Jain wrote:
>> In btrfs_dev_replace_cancel() we should check if the
>> btrfs_scrub_cancel() is successful. If the btrfs_scrub_cancel() fails, return
>> BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED so that user can try to
>> cancel the replace again.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> fs/btrfs/dev-replace.c | 22 +++++++++++++---------
>> 1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
>> index 90c124edec76..c092ed559714 100644
>> --- a/fs/btrfs/dev-replace.c
>> +++ b/fs/btrfs/dev-replace.c
>> @@ -799,18 +799,22 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
>> btrfs_dev_replace_write_unlock(dev_replace);
>> break;
>> case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
>> - result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
>> tgt_device = dev_replace->tgtdev;
>> src_device = dev_replace->srcdev;
>> btrfs_dev_replace_write_unlock(dev_replace);
>> - btrfs_scrub_cancel(fs_info);
>> - /*
>> - * btrfs_dev_replace_finishing() will handle the cleanup part
>> - */
>> - btrfs_info_in_rcu(fs_info,
>> - "dev_replace from %s (devid %llu) to %s canceled",
>> - btrfs_dev_name(src_device), src_device->devid,
>> - btrfs_dev_name(tgt_device));
>> + ret = btrfs_scrub_cancel(fs_info);
>> + if (ret) {
>> + result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED;
>> + } else {
>> + result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
>> + /*
>> + * btrfs_dev_replace_finishing() will handle the cleanup part
>> + */
>> + btrfs_info_in_rcu(fs_info,
>> + "dev_replace from %s (devid %llu) to %s canceled",
>> + btrfs_dev_name(src_device), src_device->devid,
>> + btrfs_dev_name(tgt_device));
>
> This is identical to the btrfs_info_in_rcu several lines further down.
> So if btrfs_scrub_cancel is successful you will print this messages
> twice. Furthermore, there is already an unconditinal call to
> btrfs_scrub_cancel. You are duplicating this function, this definitely
> needs another look...
Ah, it builds on top of the previous patch which I still haven't
reviewed. So ignore this, my bad.
>
>> + }
>> break;
>> case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
>> /*
>>
next prev parent reply other threads:[~2018-11-07 12:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 11:43 [PATCH 0/9] fix replace-start and replace-cancel racing Anand Jain
2018-11-07 11:43 ` [PATCH 1/9] btrfs: mark btrfs_dev_replace_start() as static Anand Jain
2018-11-07 12:04 ` Nikolay Borisov
2018-11-07 11:43 ` [PATCH 2/9] btrfs: replace go back to suspended if target missing Anand Jain
2018-11-07 12:35 ` Nikolay Borisov
2018-11-11 14:00 ` Anand Jain
2018-11-07 11:43 ` [PATCH 3/9] btrfs: replace back to suspend state if EXCL OP is running Anand Jain
2018-11-07 11:43 ` [PATCH 4/9] btrfs: fix UAF due to race between replace start and cancel Anand Jain
2018-11-07 11:43 ` [PATCH 5/9] btrfs: replace cancel is successful if scrub cancel is successful Anand Jain
2018-11-07 12:25 ` Nikolay Borisov
2018-11-07 12:26 ` Nikolay Borisov [this message]
2018-11-07 11:43 ` [PATCH 6/9] btrfs: replace's scrub must not be running in replace suspended state Anand Jain
2018-11-07 12:19 ` Nikolay Borisov
2018-11-08 8:33 ` Anand Jain
2018-11-08 8:52 ` Nikolay Borisov
2018-11-08 9:07 ` Anand Jain
2018-11-07 11:43 ` [PATCH 7/9] btrfs: quiten warn if the replace is canceled at finish Anand Jain
2018-11-07 12:17 ` Nikolay Borisov
2018-11-08 8:06 ` Anand Jain
2018-11-07 11:43 ` [PATCH 8/9] btrfs: user requsted replace cancel is not an error Anand Jain
2018-11-07 11:43 ` [PATCH 9/9] btrfs: add explicit check for replace result no error Anand Jain
2018-11-07 12:15 ` Nikolay Borisov
2018-11-08 7:26 ` Anand Jain
-- strict thread matches above, loose matches on Subject: below --
2018-11-11 14:22 [PATCH 0/9 v2] fix replace-start and replace-cancel racing Anand Jain
2018-11-11 14:22 ` [PATCH 5/9] btrfs: replace cancel is successful if scrub cancel is successful Anand Jain
2018-11-15 15:27 ` David Sterba
2018-11-16 6:38 ` Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c0f9ac16-bd00-610c-86c2-af3fd598e23a@suse.com \
--to=nborisov@suse.com \
--cc=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).