linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Should btrfs reuse the src_dev's dev UUID when doing dev replacing?
@ 2014-05-22  1:35 Qu Wenruo
  2014-05-22  3:09 ` Anand Jain
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2014-05-22  1:35 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Anand Jain

Hi,

[Current dev replace]
As kernel codes show, 'btrfs dev replace' will swap tgt_dev's uuid with 
src_dev's uuid.
This method works fine most of the time, since it doesn't need to change 
the chunk tree.

[Problem with re-appear missing device]
(Anand Jain reported the problem in Jan 2014)
Take the following suitiuation as example:
/dev/sda, /dev/sdb, /dev/sdc as btrfs RAID1.
1, 2, 3 as their dev id.

1)/dev/sdb is missing,
Mount them in degraded mode.

2) 'btrfs dev replace start 2 /dev/sdd' will replace missing /dev/sdb.

3) /dev/sdb is online again.

4) umount /BTRFS/MOUNT/POINT; mount /dev/sda
After mount, btrfs will still use /dev/sdb but not /dev/sdd

[Cause of the bug]
When this comes to missing device, since the src_dev is missing, neither 
UUID swap nor superblock wipe will
work. So if the device reappears, next mount will scan the the fsid and 
dev uuid, and if btrfs scan the re-appeared
device first, it will use the re-appeared device.

[Method to fix]
IMO there are 2 possible method to fix the bug.
1) Don't reuse the src_dev's dev UUID.
I don't think any of the UUID in btrfs should be reused, so if every 
device in btrfs has its own UUID,
it is quite easy to distinguish different devices, and even don't need 
to wipe the superblock of src_dev.
(But superblock wipe is still needed for other reasons)

2) Do generation check in device_list_add.
When multiple devices with same dev UUID is found, only add the one 
whose generation is the same with
other deivces.
IMO this is just a workaround.

I think it is better to be decided before any related patch sent.

Any suggestions?

Thanks,
Qu

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

end of thread, other threads:[~2014-06-04  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22  1:35 Should btrfs reuse the src_dev's dev UUID when doing dev replacing? Qu Wenruo
2014-05-22  3:09 ` Anand Jain
2014-06-03  6:28   ` Qu Wenruo
2014-06-03  6:28   ` Qu Wenruo
2014-06-04  3:27     ` Anand Jain

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