Support for a new command that can be used eg. as a command $ btrfs device scan --forget [dev]' (the final name may change though) to undo the effects of 'btrfs device scan [dev]'. For this purpose this patch proposes to use ioctl #5 as it was empty and is next to the SCAN ioctl. The new ioctl BTRFS_IOC_FORGET_DEV works only on the control device (/dev/btrfs-control) to unregister one or all devices, devices that are not mounted. The argument is struct btrfs_ioctl_vol_args, ::name specifies the device path. To unregister all device, the path is an empty string. Again, the devices are removed only if they aren't part of a mounte filesystem. This new ioctl provides: - release of unwanted btrfs_fs_devices and btrfs_devices structures from memory if the device is not going to be mounted - ability to mount filesystem in degraded mode, when one devices is corrupted like in split brain raid1 - running test cases which would require reloading the kernel module but this is not possible eg. due to mounted filesystem or built-in
Showing the changes to include/uapi/linux (1 of 4 files). Show all
Unified · Split
| @@ -837,6 +837,8 @@ enum btrfs_err_code { · 836 unmodified lines | |||
| 837 | struct btrfs_ioctl_vol_args) | 837 | struct btrfs_ioctl_vol_args) |
| 838 | #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ | 838 | #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ |
| 839 | struct btrfs_ioctl_vol_args) | 839 | struct btrfs_ioctl_vol_args) |
| 840 | #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ | ||
| 841 | struct btrfs_ioctl_vol_args) | ||
| 840 | /* trans start and trans end are dangerous, and only for | 842 | /* trans start and trans end are dangerous, and only for |
| 841 | * use by applications that know how to avoid the | 843 | * use by applications that know how to avoid the |
| 842 | * resulting deadlocks | 844 | * resulting deadlocks |