linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [bug] its messy when missing device reappears after its been replaced in RAID1
Date: Mon, 13 Jan 2014 18:05:08 +0800	[thread overview]
Message-ID: <52D3BA54.6010601@cn.fujitsu.com> (raw)
In-Reply-To: <52CAE033.3020604@oracle.com>

Hello Anand,

It seems that other developers did not notice such an important thread.:-)
I gave some of my opinions about this issue.

See more below.....

On 01/07/2014 12:56 AM, Anand Jain wrote:
>
> test case:
[snip]
....
> ----------------------------------------------------
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 2ca91fc..b226284 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -496,14 +496,39 @@ static noinline int device_list_add(const char 
> *path,
>
>                 device->fs_devices = fs_devices;
>         } else if (!device->name || strcmp(device->name->str, path)) {
> -               name = rcu_string_strdup(path, GFP_NOFS);
> -               if (!name)
> -                       return -ENOMEM;
> -               rcu_string_free(device->name);
> -               rcu_assign_pointer(device->name, name);
> -               if (device->missing) {
> -                       fs_devices->missing_devices--;
> -                       device->missing = 0;
> +
> +               struct buffer_head *bh;
> +               struct btrfs_super_block *cur_disk_super;
> +               u64 cur_transid;
> +
> +               if (!device->missing) {
> +                       bh = btrfs_read_dev_super(device->bdev);
> +                       if (!bh)
> +                               return -EINVAL;
> +
> +                       cur_disk_super = (struct btrfs_super_block *)
> +                        bh->b_data;
> +                       cur_transid = btrfs_super_generation(ds);
> +               } else
> +                       cur_transid = 0;
> +
> +               if (found_transid > cur_transid) {

I agree we use transid to find most proper device, but this check is not 
right.
Here @found_transid is the most biggest generation, so a right candidate 
device's
transid should be @found_tranid -1 (power off for example)or same as 
@found_transid.

Anyway, i think the right way should be to check two same id device, and 
we only replace
existed one if new found one's transid > previous one.

Please correct me if i miss something here.^_^

Thanks,
Wang
> +
> +                       name = rcu_string_strdup(path, GFP_NOFS);
> +                       if (!name)
> +                               return -ENOMEM;
> +
> +                       rcu_string_free(device->name);
> +                       rcu_assign_pointer(device->name, name);
> +
> +                       if (device->missing) {
> +                               fs_devices->missing_devices--;
> +                               device->missing = 0;
> +                       }
> +
> +       printk_in_rcu(KERN_INFO "%s tran %llu replaced %s tran %llu\n",
> +                               path, found_transid,
> +                               rcu_str_deref(device->name), tranid);
>                 }
>         }
>
> ---------------------------------------
>
>
> Thanks Anand
>
>
> [1] github.com/anajain/devmgt.git
>
>
>
> -- 
> 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
>


  reply	other threads:[~2014-01-13 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06 16:56 [bug] its messy when missing device reappears after its been replaced in RAID1 Anand Jain
2014-01-13 10:05 ` Wang Shilong [this message]
2014-01-14 11:43   ` 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=52D3BA54.6010601@cn.fujitsu.com \
    --to=wangsl.fnst@cn.fujitsu.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).