On 11/13/2018 10:31 AM, David Sterba wrote:
On Mon, Oct 01, 2018 at 09:31:04PM +0800, Anand Jain wrote:
+ /*
+ * we are going to replace the device path, make sure its the
+ * same device if the device mounted
+ */
+ if (device->bdev) {
+ struct block_device *path_bdev;
+
+ path_bdev = lookup_bdev(path);
+ if (IS_ERR(path_bdev)) {
+ mutex_unlock(&fs_devices->device_list_mutex);
+ return ERR_CAST(path_bdev);
+ }
+
+ if (device->bdev != path_bdev) {
+ bdput(path_bdev);
+ mutex_unlock(&fs_devices->device_list_mutex);
+ return ERR_PTR(-EEXIST);
It would be _really_ nice to have an informative error message printed
here. Aside from the possibility of an admin accidentally making a
block-level copy of the volume,
this code triggering could represent an
attempted attack against the system, so it's arguably something that
should be reported as happening.
Personally, I think a WARN_ON_ONCE for
this would make sense, ideally per-volume if possible.
Ah. Will add an warn. Thanks, Anand
The requested error message is not in the patch you posted or I have
missed that (https://patchwork.kernel.org/patch/10641041/) .
Austin, is the following ok for you?
"BTRFS: duplicate device fsid:devid for %pU:%llu old:%s new:%s\n"
BTRFS: duplicate device fsid:devid 7c667b96-59eb-43ad-9ae9-c878f6ad51d8:2
old:/dev/sda6 new:/dev/sdb6
As the UUID and paths are long I tried to squeeeze the rest so it's
still comprehensible but this would be better confirmed. Thanks.
Looks perfectly fine to me.