btrfs: check generation as replace duplicates devid+uuid
authorAnand Jain <anand.jain@oracle.com>
Thu, 3 Jul 2014 10:22:06 +0000 (18:22 +0800)
committerChris Mason <clm@fb.com>
Tue, 19 Aug 2014 15:36:30 +0000 (08:36 -0700)
commit77bdae4d136e167bab028cbec58b988f91cf73c0
tree3c2477baa2f64cc00db475efc2f52d399f1a4beb
parentb96de000bc8bc9688b3a2abea4332bd57648a49f
btrfs: check generation as replace duplicates devid+uuid

When FS in unmounted we need to check generation number as well
since devid+uuid combination could match with the missing replaced
disk when it reappears, and without this patch it might pair with
the replaced disk again.

 device_list_add() function is called in the following threads,
mount device option
mount argument
ioctl BTRFS_IOC_SCAN_DEV (btrfs dev scan)
ioctl BTRFS_IOC_DEVICES_READY (btrfs dev ready <dev>)
 they have been unit tested to work fine with this patch.

 If the user knows what he is doing and really want to pair with
 replaced disk (which is not a standard operation), then he should
 first clear the kernel btrfs device list in the memory by doing
 the module unload/load and followed with the mount -o device option.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/volumes.c