+#ifdef CONFIG_BTRFS_EXPERIMENTAL +static void btrfs_remove_bdev(struct super_block *sb, struct block_device *bdev) +{ + struct btrfs_fs_info *fs_info = btrfs_sb(sb); + struct btrfs_device *device; + struct btrfs_dev_lookup_args lookup_args = { .devt = bdev->bd_dev }; + bool can_rw; + + mutex_lock(&fs_info->fs_devices->device_list_mutex); + device = btrfs_find_device(fs_info->fs_devices, &lookup_args); + if (!device) { + btrfs_warn(fs_info, "unable to find btrfs device for block device '%pg'", + bdev); + mutex_unlock(&fs_info->fs_devices->device_list_mutex); + return; + } + set_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state); + device->fs_devices->missing_devices++;
Where do we ensure that the block device wasn't already marked as missing? If there's no such check, could missing_devices end up exceeding total_devices? Thanks, Anand