summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2014-03-17 19:59:01 +0800
committerChris Mason <clm@fb.com>2014-04-04 17:54:35 -0700
commita062ffd74de0b6ad74ea2c9750da94e2964856a1 (patch)
tree6ad555771e5975b744f32afc02726a296107d835
parentbf357ff320f80eb1a47e0fd4d06be374e2f2b3fd (diff)
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>
-rw-r--r--disk-io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/disk-io.c b/disk-io.c
index 0bd1bb01..19b95a72 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -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))