Qu Wenruo 1b3922a8bc btrfs: Use real device structure to verify dev extent
[BUG]
Linux v5.0-rc1 will fail fstests/btrfs/163 with the following kernel
message:

  BTRFS error (device dm-6): dev extent devid 1 physical offset 13631488 len 8388608 is beyond device boundary 0
  BTRFS error (device dm-6): failed to verify dev extents against chunks: -117
  BTRFS error (device dm-6): open_ctree failed

[CAUSE]
Commit cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent
mapping check") introduced strict check on dev extents.

We use btrfs_find_device() with dev uuid and fs uuid set to NULL, and
only dependent on @devid to find the real device.

For seed devices, we call clone_fs_devices() in open_seed_devices() to
allow us search seed devices directly.

However clone_fs_devices() just populates devices with devid and dev
uuid, without populating other essential members, like disk_total_bytes.

This makes any device returned by btrfs_find_device(fs_info, devid,
NULL, NULL) is just a dummy, with 0 disk_total_bytes, and any dev
extents on the seed device will not pass the device boundary check.

[FIX]
This patch will try to verify the device returned by btrfs_find_device()
and if it's a dummy then re-search in seed devices.

Fixes: cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent mapping check")
CC: stable@vger.kernel.org # 4.19+
Reported-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-10 17:13:00 +01:00
..
2018-09-04 11:35:03 +08:00
2018-08-21 23:54:17 -04:00
2018-11-27 10:21:15 +01:00
2018-11-30 14:56:14 -08:00
2018-08-17 16:20:28 -07:00
2018-09-29 22:47:48 -04:00
2018-10-26 16:26:33 -07:00
2018-05-22 14:27:52 -04:00
2018-11-05 14:57:05 -05:00
2018-10-12 22:46:50 -04:00
2018-11-30 14:56:15 -08:00
2018-11-01 11:46:27 -07:00
2018-11-30 09:03:15 -08:00
2018-05-22 14:27:52 -04:00
2018-08-18 11:44:53 -07:00
2018-10-23 13:49:02 +02:00
2018-12-14 12:18:30 -08:00
2018-07-03 16:44:45 -04:00
2018-10-24 00:40:44 +01:00
2018-11-02 11:25:48 -07:00
2018-10-29 14:29:58 -07:00
2018-06-05 19:23:26 +02:00
2018-10-31 08:54:16 -07:00
2018-08-21 18:19:09 -07:00
2018-10-21 10:46:42 -04:00
2018-08-21 18:19:09 -07:00
2018-06-11 08:22:34 -07:00
2018-08-21 18:19:09 -07:00
2018-02-15 15:34:42 -05:00
2018-08-21 18:19:09 -07:00
2018-09-03 15:14:01 +02:00
2018-04-04 12:44:02 -07:00