]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: harden identification of a stale device
authorAnand Jain <anand.jain@oracle.com>
Wed, 12 Jan 2022 05:05:59 +0000 (13:05 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:46 +0000 (13:13 +0100)
commit9c123fc7f2432522ec0e153acc621b7a0ebedec1
treef306d74b6040d9db7bef92e1dacec6b15237b03f
parent6f8f564517ffad082d2c14e6c0a59f7a6d93371f
btrfs: harden identification of a stale device

Identifying and removing the stale device from the fs_uuids list is done
by btrfs_free_stale_devices().  btrfs_free_stale_devices() in turn
depends on device_path_matched() to check if the device appears in more
than one btrfs_device structure.

The matching of the device happens by its path, the device path. However,
when device mapper is in use, the dm device paths are nothing but a link
to the actual block device, which leads to the device_path_matched()
failing to match.

Fix this by matching the dev_t as provided by lookup_bdev() instead of
plain string compare of the device paths.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c