On 3/8/24 21:18, Christoph Hellwig wrote:
On Fri, Mar 08, 2024 at 08:15:07AM +0530, Anand Jain wrote:
@@ -692,6 +692,16 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
device->bdev = bdev_handle->bdev;
clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);
+ if (device->devt != device->bdev->bd_dev) {
+ btrfs_warn(NULL,
+ "device %s maj:min changed from %d:%d to %d:%d",
+ device->name->str, MAJOR(device->devt),
+ MINOR(device->devt), MAJOR(device->bdev->bd_dev),
+ MINOR(device->bdev->bd_dev));
+
+ device->devt = device->bdev->bd_dev;
+ }
Just above this calls btrfs_get_bdev_and_sb, which calls
bdev_open_by_path. bdev_open_by_path bdev_open_by_path calls
lookup_bdev to translate the path to a dev_t and then calls
bdev_open_by_dev on the dev_t, which stored the passes in dev_t in
bdev->bd_dev. I see absolutely no way how this check could ever
trigger.
Prior to this patch, the device->devt value of the device could become
stale, as it might not have been updated since the last scan of the
device. During this interval, the device could have undergone changes
to its devt.
Thanks, Anand