btrfs-progs: device delete to accept devid
Subsystems (2)
PATCH v2 2/2 btrfs-progs: device delete to accept devid
This patch introduces new option <devid> for the command
btrfs device delete <device_path|devid>[..] <mnt>
In a user reported issue on a 3-disk-RAID1, one disk failed with its SB unreadable. Now with this patch user will have a choice to delete the device using devid.
The other method we could do, is to match the input device_path to the available device_paths with in the kernel. But that won't work in all the cases, like what if user provided mapper path when the path within the kernel is a non-mapper path.
This patch depends on the below kernel patch for the new feature to work, however it will fail-back to the old interface for the kernel without the patch
Btrfs: device delete by devid
---v1->v2: update the missed Documentation for delete (not just remove) as well.
Thanks to Goffredo.
Documentation/btrfs-device.asciidoc | 4 ++-- cmds-device.c | 45 ++++++++++++++++++++++++++++--------- ioctl.h | 8 +++++++ 3 files changed, 45 insertions(+), 12 deletions(-)
Documentation/btrfs-device.asciidoc +2 -2
@@ -74,10 +74,10 @@ do not perform discard by default -f|--force:::: force overwrite of existing filesystem on the given disk(s) -*remove* <dev> [<dev>...] <path>:: +*remove* <dev>|<devid> [<dev>|<devid>...] <path>:: Remove device(s) from a filesystem identified by <path>. -*delete* <dev> [<dev>...] <path>:: +*delete* <dev>|<devid> [<dev>|<devid>...] <path>:: Alias of remove kept for backwards compatability *ready* <device>::
cmds-device.c +35 -10
74 lines not on this page · raw message
ioctl.h +8 -0
@@ -40,6 +40,12 @@ struct btrfs_ioctl_vol_args {char name[BTRFS_PATH_NAME_MAX +1 ]; }; +struct btrfs_ioctl_vol_args_v3 { +__s64 fd; +char name[BTRFS_PATH_NAME_MAX +1 ]; +__u64 devid; +}; +#define BTRFS_DEVICE_PATH_NAME_MAX 1024#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
@@ -683,6 +689,8 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_feature_flags[2])#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ struct btrfs_ioctl_feature_flags[3]) +#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ + struct btrfs_ioctl_vol_args_v3) #ifdef __cplusplus }#endif
Signature · 1 line
2.4.1
Quoted 1 line · Anand Jain
+struct
btrfs_ioctl_vol_args_v3{
Can we use struct btrfs_ioctl_vol_args_v2 for that purpose? It contains the 'flags' so we can abuse the name field to store the device id and set the flags accordingly.
Quoted 9 lines
ioctl.h +5
-0+__s64 fd; +char name[BTRFS_PATH_NAME_MAX +1 ]; +__u64 devid; +}; +#define BTRFS_DEVICE_PATH_NAME_MAX 1024#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
ioctl.h static inline char *btrfs_err_str(enum btrfs_err_code err_code) · line 693
Quoted 5 lines
ioctl.h +2
-0@@ -683,6 +689,8 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_feature_flags[2])#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ struct btrfs_ioctl_feature_flags[3]) +#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ + struct btrfs_ioctl_vol_args_v3)
And we can reuse the ioctl nmuber 11
#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 11, \
struct btrfs_ioctl_vol_args_v2)
The vol_v2 structure is extensible so we can add more functionality there and then I think it justifies the V2 interface bump.
Thanks for the review..
Quoted 24 lines · David Sterba
Quoted 1 line · Anand Jain
+struct
btrfs_ioctl_vol_args_v3{Can we use struct
btrfs_ioctl_vol_args_v2for that purpose? It contains the 'flags' so we can abuse the name field to store the device id and set the flags accordingly.Quoted 9 lines
ioctl.h +5
-0+__s64 fd; +char name[BTRFS_PATH_NAME_MAX +1 ]; +__u64 devid; +}; +#define BTRFS_DEVICE_PATH_NAME_MAX 1024#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)ioctl.h static inline char *btrfs_err_str(enum btrfs_err_code err_code) · line 693
Quoted 5 lines
ioctl.h +2
-0@@ -683,6 +689,8 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code) struct btrfs_ioctl_feature_flags[2])#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ struct btrfs_ioctl_feature_flags[3]) +#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ + struct btrfs_ioctl_vol_args_v3)And we can reuse the ioctl nmuber 11
Quoted 5 lines
#define
BTRFS_IOC_RM_DEV_V2_IOW(BTRFS_IOCTL_MAGIC, 11, \
structbtrfs_ioctl_vol_args_v2)The
vol_v2structure is extensible so we can add more functionality there and then I think it justifies the V2 interface bump.
I have implemented it in V3 and sent out.
Thanks, Anand