btrfs-progs: avoid implicit scan for backup SB
When a disk containing btrfs is overwritten with other FS, ext4 for example it doesn't overwrite 2nd and 3rd copy of the btrfs SB. And btrfs_read_dev_super() would look for backup SB when primary SB isn't found. This causes the problem as in the reproducer below. In kernel we avoid this by _not_ reading backup SB implicitly, this patch would port the same to btrfs-progs. reproducer: mkfs.btrfs /dev/sde mkfs.ext4 /dev/sde mount /dev/sde /ext4 btrfs-convert /dev/sde (is successful (bug)) with this patch :: btrfs-convert /dev/sde /dev/sde is mounted Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
bf357ff320
commit
a062ffd74d
|
@ -1206,7 +1206,14 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
|
||||
/*
|
||||
* we would like to check all the supers, but that would make
|
||||
* a btrfs mount succeed after a mkfs from a different FS.
|
||||
* So, we need to add a special mount option to scan for
|
||||
* later supers, using BTRFS_SUPER_MIRROR_MAX instead
|
||||
*/
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
bytenr = btrfs_sb_offset(i);
|
||||
ret = pread64(fd, &buf, sizeof(buf), bytenr);
|
||||
if (ret < sizeof(buf))
|
||||
|
|
Loading…
Reference in a new issue