Re: [PATCH 0/4] btrfs-progs repair support for unaligned/mismatched device sizes

2017-10-17 Thread Qu Wenruo


On 2017年10月17日 14:06, Ursul Hempel Egal wrote:
> Hi,
> 
> I have encountered the issue where a btrfs filesystem would not mount due to 
> mismatch of super_total_bytes with fs_devices total_rw_bytes
> 
> I was able to fix it with the new parameter --fix-dev-size
> 
> Below I have listed the steps I took.
> 
> Reference
> https://www.spinics.net/lists/linux-btrfs/msg70025.html

Glad this works for you.

However the patch set will be updated soon, to move the tool to "btrfs
rescue" other than "btrfs check".

Although "btrfs check --repair" can still repair it after the update.
> 
> 
> 
> My setup
> 
> HDDs are
>   sdb 2.7TB
>   3.7TB (sdd) with partition sdd1
>   sde 2.7TB
>   sdf 2.7TB
> 
> 
> Running on latest version of Fedora stable
> 
> [root@localhost ~]# uname -a
> Linux localhost.localdomain 4.13.5-200.fc26.x86_64 #1 SMP Thu Oct 5 16:53:13 
> UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
> [root@localhost ~]# btrfs --version
> btrfs-progs v4.9.1
> 
> 
> These are previous conversions of the fs:
> 
> 1) I had originally created this as a RAID0 array on two drives.
> 2) Then converted to RAID1 and added a third drive.
> 3) Then converted to RAID10 and added a fourth drive.
> 
> 4) I wanted to use the remaining 1TB on sdd, so I
>   converted back to RAID1
>   removed sdd
>   created a sdd1 partition and added it to the filesystem
>   converted the fs to RAID10
> 
> 5) Then I found out that the sdd1 partition size was not aligned to 4096 
> bytes, so I
>   increased partition size to exactly match the sdb drive size
>   increased the fs size on sdd1 using btrfs fi resize 4:max /mnt/6TB

Considering the kernel version is just 4.13, it lacks the extra
alignment check.

So that the final resize increased device size, but super size doesn't
get increased as much as device did, maybe due to alignment change.

And this makes super size smaller than total device size and caused the
problem.

If using v4.14 from the very beginning, at least we can avoid such problem.

So the windows to cause the problem may be between v4.6 (which
introduced the check) to v4.14 (which introduced better alignment check).

Thanks for your feedback,
Qu

> 
> 6) After reboot the whole filesystem would no longer mount
> 7) The --fix-dev-size parameter seems to have fixed it, details below
> 
> 
> 
> 
> 
> 
> 
> 
> [root@localhost ~]# lsblk 
> NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
> sda  8:00  59.6G  0 disk 
> ├─sda1   8:10   200M  0 part /boot/efi
> ├─sda2   8:20 1G  0 part /boot
> └─sda3   8:30  58.4G  0 part /
> sdb  8:16   0   2.7T  0 disk 
> sdc  8:32   0 465.8G  0 disk 
> ├─sdc1   8:33   0   450M  0 part 
> ├─sdc2   8:34   0   100M  0 part 
> ├─sdc3   8:35   016M  0 part 
> ├─sdc4   8:36   0 146.5G  0 part 
> └─sdc5   8:37   0 318.7G  0 part /home
> sdd  8:48   0   3.7T  0 disk 
> ├─sdd1   8:49   0   2.7T  0 part 
> └─sdd2   8:50   0 931.5G  0 part 
> sde  8:64   0   2.7T  0 disk 
> sdf  8:80   0   2.7T  0 disk 
> 
> 
> [root@localhost ~]# btrfs inspect dump-super /dev/sdd1
> superblock: bytenr=65536, device=/dev/sdd1
> -
> csum_type 0 (crc32c)
> csum_size 4
> csum  0x9c9d6da0 [match]
> bytenr65536
> flags 0x1
>   ( WRITTEN )
> magic _BHRfS_M [match]
> fsid  41806396-8892-4278-a534-23ce61d78970
> label 6TB
> generation245580
> root  48007926906880
> sys_array_size193
> chunk_root_generation 245539
> root_level1
> chunk_root38578614435840
> chunk_root_level  1
> log_root  0
> log_root_transid  0
> log_root_level0
> total_bytes   12002371923968
> bytes_used4542498934784
> sectorsize4096
> nodesize  16384
> leafsize  16384
> stripesize4096
> root_dir  6
> num_devices   4
> compat_flags  0x0
> compat_ro_flags   0x0
> incompat_flags0x163
>   ( MIXED_BACKREF |
> DEFAULT_SUBVOL |
> BIG_METADATA |
> EXTENDED_IREF |
> SKINNY_METADATA )
> cache_generation  245580
> uuid_tree_generation  245580
> dev_item.uuid 2d19c08c-8a16-48c2-ae28-4547b19ae419
> dev_item.fsid 41806396-8892-4278-a534-23ce61d78970 [match]
> dev_item.type 0
> dev_item.total_bytes  3000592982016
> dev_item.bytes_used   2725190303744
> dev_item.io_align 4096
> dev_item.io_width 4096
> dev_item.sector_size  4096
> dev_item.devid4
> dev_item.dev_group0
> dev_item.seek_speed   0
> dev_item.bandwidth0
> dev_item.generation   0
> 
> 
> 
> 
> [root@localhost ~]# btrfs inspect dump-super /dev/sdb

RE: [PATCH 0/4] btrfs-progs repair support for unaligned/mismatched device sizes

2017-10-17 Thread Ursul Hempel Egal
Hi,

I have encountered the issue where a btrfs filesystem would not mount due to 
mismatch of super_total_bytes with fs_devices total_rw_bytes

I was able to fix it with the new parameter --fix-dev-size

Below I have listed the steps I took.

Reference
https://www.spinics.net/lists/linux-btrfs/msg70025.html



My setup

HDDs are
sdb 2.7TB
3.7TB (sdd) with partition sdd1
sde 2.7TB
sdf 2.7TB


Running on latest version of Fedora stable

[root@localhost ~]# uname -a
Linux localhost.localdomain 4.13.5-200.fc26.x86_64 #1 SMP Thu Oct 5 16:53:13 
UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# btrfs --version
btrfs-progs v4.9.1


These are previous conversions of the fs:

1) I had originally created this as a RAID0 array on two drives.
2) Then converted to RAID1 and added a third drive.
3) Then converted to RAID10 and added a fourth drive.

4) I wanted to use the remaining 1TB on sdd, so I
converted back to RAID1
removed sdd
created a sdd1 partition and added it to the filesystem
converted the fs to RAID10

5) Then I found out that the sdd1 partition size was not aligned to 4096 bytes, 
so I
increased partition size to exactly match the sdb drive size
increased the fs size on sdd1 using btrfs fi resize 4:max /mnt/6TB

6) After reboot the whole filesystem would no longer mount
7) The --fix-dev-size parameter seems to have fixed it, details below








[root@localhost ~]# lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda  8:00  59.6G  0 disk 
├─sda1   8:10   200M  0 part /boot/efi
├─sda2   8:20 1G  0 part /boot
└─sda3   8:30  58.4G  0 part /
sdb  8:16   0   2.7T  0 disk 
sdc  8:32   0 465.8G  0 disk 
├─sdc1   8:33   0   450M  0 part 
├─sdc2   8:34   0   100M  0 part 
├─sdc3   8:35   016M  0 part 
├─sdc4   8:36   0 146.5G  0 part 
└─sdc5   8:37   0 318.7G  0 part /home
sdd  8:48   0   3.7T  0 disk 
├─sdd1   8:49   0   2.7T  0 part 
└─sdd2   8:50   0 931.5G  0 part 
sde  8:64   0   2.7T  0 disk 
sdf  8:80   0   2.7T  0 disk 


[root@localhost ~]# btrfs inspect dump-super /dev/sdd1
superblock: bytenr=65536, device=/dev/sdd1
-
csum_type   0 (crc32c)
csum_size   4
csum0x9c9d6da0 [match]
bytenr  65536
flags   0x1
( WRITTEN )
magic   _BHRfS_M [match]
fsid41806396-8892-4278-a534-23ce61d78970
label   6TB
generation  245580
root48007926906880
sys_array_size  193
chunk_root_generation   245539
root_level  1
chunk_root  38578614435840
chunk_root_level1
log_root0
log_root_transid0
log_root_level  0
total_bytes 12002371923968
bytes_used  4542498934784
sectorsize  4096
nodesize16384
leafsize16384
stripesize  4096
root_dir6
num_devices 4
compat_flags0x0
compat_ro_flags 0x0
incompat_flags  0x163
( MIXED_BACKREF |
  DEFAULT_SUBVOL |
  BIG_METADATA |
  EXTENDED_IREF |
  SKINNY_METADATA )
cache_generation245580
uuid_tree_generation245580
dev_item.uuid   2d19c08c-8a16-48c2-ae28-4547b19ae419
dev_item.fsid   41806396-8892-4278-a534-23ce61d78970 [match]
dev_item.type   0
dev_item.total_bytes3000592982016
dev_item.bytes_used 2725190303744
dev_item.io_align   4096
dev_item.io_width   4096
dev_item.sector_size4096
dev_item.devid  4
dev_item.dev_group  0
dev_item.seek_speed 0
dev_item.bandwidth  0
dev_item.generation 0




[root@localhost ~]# btrfs inspect dump-super /dev/sdb
superblock: bytenr=65536, device=/dev/sdb
-
csum_type   0 (crc32c)
csum_size   4
csum0xb540bd25 [match]
bytenr  65536
flags   0x1
( WRITTEN )
magic   _BHRfS_M [match]
fsid41806396-8892-4278-a534-23ce61d78970
label   6TB
generation  245580
root48007926906880
sys_array_size  193
chunk_root_generation   245539
root_level  1
chunk_root  38578614435840
chunk_root_level1
log_root0
log_root_transid0
log_root_level  0
total_bytes 12002371923968
bytes_used  4542498934784
sectorsize  4096
nodesize16384
leafsize16384
stripesize  4096
root_dir6
num_devices 4
compat_flags0x0

Re: [PATCH 0/4] btrfs-progs repair support for unaligned/mismatched device sizes

2017-10-10 Thread Qu Wenruo



On 2017年10月10日 16:15, Nikolay Borisov wrote:



On 10.10.2017 10:51, Qu Wenruo wrote:

The patchset can be fetched from github:
https://github.com/adam900710/btrfs-progs/tree/check_unaligned_dev

There are several reports in mail list for btrfs device size related
problems.

1) Unmountable fs, due to mismatched super total_bytes
Unmountable if super total_bytes is smaller than total rw bytes of
all devices.
Root cause under investigation, but only one report here.


Don't you mean mountable? We've internally seen mounting being a problem
due to said size mismatch.


I mean the fs is unable to be mounted.
(Which is the correct single word to express "unable to be mounted"?)

The direct cause is obvious, strict super block total_bytes checker.

But I don't know how it happened.

Maybe there is a window between some kernel release make it out of sync, 
but anyway, your introduced alignment enhancement commit should handle 
them well in v4.14.


At least for worst case, such users with fs unable to mount, won't be 
left in cold wind.

And new users starting from v4.13 should not hit such problems.

Thanks,
Qu





This patchset provides the tool to fix it offline.
(At least better than unmountable forever)

2) Harmless kernel warning for btrfs_update_device()
v4.14 introduced restrict device size checker.
This somewhat break the backward compatibility and causing kernel
warning.

It can be fixed online with "btrfs filesystem resize".
(Although it is better to fixed it at mount time)

This patchset also provide a fallback method to fix it.

Qu Wenruo (4):
   btrfs-progs: Introduce functions to repair unaligned/mismatch device
 size
   btrfs-progs: fsck: Introduce --fix-dev-size option
   btrfs-progs: check: Also check unalignment/mismatch device and super
 size
   btrfs-progs: test/fsck: Add test case image for --fix-dev-size

Qu Wenruo (4):
   btrfs-progs: Introduce functions to repair unaligned/mismatch device
 size
   btrfs-progs: fsck: Introduce --fix-dev-size option
   btrfs-progs: check: Also check unalignment/mismatch device and super
 size
   btrfs-progs: test/fsck: Add test case image for --fix-dev-size

  Documentation/btrfs-check.asciidoc |  23 ++
  cmds-check.c   | 292 -
  .../dev_and_super_mismatch_unaligned.raw.xz| Bin 0 -> 21536 bytes
  3 files changed, 314 insertions(+), 1 deletion(-)
  create mode 100644 
tests/fsck-tests/027-unaligned-super-dev-sizes/dev_and_super_mismatch_unaligned.raw.xz


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4] btrfs-progs repair support for unaligned/mismatched device sizes

2017-10-10 Thread Nikolay Borisov


On 10.10.2017 10:51, Qu Wenruo wrote:
> The patchset can be fetched from github:
> https://github.com/adam900710/btrfs-progs/tree/check_unaligned_dev
> 
> There are several reports in mail list for btrfs device size related
> problems.
> 
> 1) Unmountable fs, due to mismatched super total_bytes
>Unmountable if super total_bytes is smaller than total rw bytes of
>all devices.
>Root cause under investigation, but only one report here.

Don't you mean mountable? We've internally seen mounting being a problem
due to said size mismatch.

> 
>This patchset provides the tool to fix it offline.
>(At least better than unmountable forever)
> 
> 2) Harmless kernel warning for btrfs_update_device()
>v4.14 introduced restrict device size checker.
>This somewhat break the backward compatibility and causing kernel
>warning.
> 
>It can be fixed online with "btrfs filesystem resize".
>(Although it is better to fixed it at mount time)
> 
>This patchset also provide a fallback method to fix it.
> 
> Qu Wenruo (4):
>   btrfs-progs: Introduce functions to repair unaligned/mismatch device
> size
>   btrfs-progs: fsck: Introduce --fix-dev-size option
>   btrfs-progs: check: Also check unalignment/mismatch device and super
> size
>   btrfs-progs: test/fsck: Add test case image for --fix-dev-size
> 
> Qu Wenruo (4):
>   btrfs-progs: Introduce functions to repair unaligned/mismatch device
> size
>   btrfs-progs: fsck: Introduce --fix-dev-size option
>   btrfs-progs: check: Also check unalignment/mismatch device and super
> size
>   btrfs-progs: test/fsck: Add test case image for --fix-dev-size
> 
>  Documentation/btrfs-check.asciidoc |  23 ++
>  cmds-check.c   | 292 
> -
>  .../dev_and_super_mismatch_unaligned.raw.xz| Bin 0 -> 21536 bytes
>  3 files changed, 314 insertions(+), 1 deletion(-)
>  create mode 100644 
> tests/fsck-tests/027-unaligned-super-dev-sizes/dev_and_super_mismatch_unaligned.raw.xz
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] btrfs-progs repair support for unaligned/mismatched device sizes

2017-10-10 Thread Qu Wenruo
The patchset can be fetched from github:
https://github.com/adam900710/btrfs-progs/tree/check_unaligned_dev

There are several reports in mail list for btrfs device size related
problems.

1) Unmountable fs, due to mismatched super total_bytes
   Unmountable if super total_bytes is smaller than total rw bytes of
   all devices.
   Root cause under investigation, but only one report here.

   This patchset provides the tool to fix it offline.
   (At least better than unmountable forever)

2) Harmless kernel warning for btrfs_update_device()
   v4.14 introduced restrict device size checker.
   This somewhat break the backward compatibility and causing kernel
   warning.

   It can be fixed online with "btrfs filesystem resize".
   (Although it is better to fixed it at mount time)

   This patchset also provide a fallback method to fix it.

Qu Wenruo (4):
  btrfs-progs: Introduce functions to repair unaligned/mismatch device
size
  btrfs-progs: fsck: Introduce --fix-dev-size option
  btrfs-progs: check: Also check unalignment/mismatch device and super
size
  btrfs-progs: test/fsck: Add test case image for --fix-dev-size

Qu Wenruo (4):
  btrfs-progs: Introduce functions to repair unaligned/mismatch device
size
  btrfs-progs: fsck: Introduce --fix-dev-size option
  btrfs-progs: check: Also check unalignment/mismatch device and super
size
  btrfs-progs: test/fsck: Add test case image for --fix-dev-size

 Documentation/btrfs-check.asciidoc |  23 ++
 cmds-check.c   | 292 -
 .../dev_and_super_mismatch_unaligned.raw.xz| Bin 0 -> 21536 bytes
 3 files changed, 314 insertions(+), 1 deletion(-)
 create mode 100644 
tests/fsck-tests/027-unaligned-super-dev-sizes/dev_and_super_mismatch_unaligned.raw.xz

-- 
2.14.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html