From: Anand Jain <anand.jain@oracle.com>
To: Nikolay Borisov <nborisov@orcl-no-reply_suse.com>,
Liu Bo <bo.li.liu@oracle.com>,
linux-btrfs@vger.kernel.org, linux_lkml_grp@oracle.com
Subject: Re: [PATCH] Btrfs-progs: do not add stale device into fs_devices
Date: Wed, 11 Oct 2017 21:45:38 +0800 [thread overview]
Message-ID: <a05cf9b5-6995-b446-b076-6ad4bf4864f1@oracle.com> (raw)
In-Reply-To: <f56dc49b-817b-6655-2215-5bf1552c9d3d@suse.com>
On 10/11/2017 05:33 PM, Nikolay Borisov wrote:
>
>
> On 11.10.2017 03:28, Liu Bo wrote:
>> If one of btrfs's devices was pulled out and we've replaced it with a
>> new one, then they have the same uuid.
>>
>> If that device gets reconnected, 'btrfs filesystem show' will show the
>> stale one instead of the new one, but on kernel side btrfs has a fix
>> to not include the stale one, this could confuse users as people may
>> monitor btrfs by running that cli.
>>
>> This does the similar thing to what kernel side has done.
>>
>> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
>> ---
>> volumes.c | 15 ++++++++++++++-
>> 1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/volumes.c b/volumes.c
>> index 2f3943d..c7b7a41 100644
>> --- a/volumes.c
>> +++ b/volumes.c
>> @@ -138,7 +138,20 @@ static int device_list_add(const char *path,
>> list_add(&device->dev_list, &fs_devices->devices);
>> device->fs_devices = fs_devices;
>> } else if (!device->name || strcmp(device->name, path)) {
>> - char *name = strdup(path);
>> + char *name;
>> +
>> + /*
>> + * The existing device has newer generation, so this
>> + * one could be a stale one, don't add it.
>> + */
>> + if (found_transid < device->generation) {
>> + warning("adding device %s gen %llu but found a existing device %s gen %llu\n",
>> + path, found_transid, device->name,
>> + device->generation, found_transid);
>
> You pass in 5 parameters but have only 4 formatting strings. I don't see
> the same happening on other warning() invocations? Perhaps the last
> found_transid is not necessary?
I missed that. Sorry.
Thanks, Anand
>> + return -EEXIST;
>> + }
>> +
>> + name = strdup(path);
>> if (!name)
>> return -ENOMEM;
>> kfree(device->name);
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2017-10-11 13:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 0:28 [PATCH] Btrfs-progs: do not add stale device into fs_devices Liu Bo
2017-10-11 6:33 ` Anand Jain
2017-10-11 9:33 ` Nikolay Borisov
2017-10-11 13:45 ` Anand Jain [this message]
2017-10-11 16:54 ` Liu Bo
2017-10-11 17:57 ` [PATCH v2] " Liu Bo
2017-10-17 16:38 ` David Sterba
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=a05cf9b5-6995-b446-b076-6ad4bf4864f1@oracle.com \
--to=anand.jain@oracle.com \
--cc=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux_lkml_grp@oracle.com \
--cc=nborisov@orcl-no-reply_suse.com \
/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).