btrfs-progs: rescue: Add create-control-device subcommand
Subsystems (2)
cover btrfs-progs: rescue: Add create-control-device subcommand
This patchset adds a new btrfs rescue create-control-device subcommand that acts as a convenient way to invoke:
# mknod --mode=600 c 10 234 /dev/btrfs-control
on systems that don't have mknod installed or when you're lazy.
Daniel Xu (3):
btrfs-progs: rescue: Add create-control-device subcommand
btrfs-progs: bash: Update completion script with create-control-device
btrfs-progs: rescue: Update docs with create-control-device
Documentation/btrfs-man5.asciidoc | 8 ++++++- Documentation/btrfs-rescue.asciidoc | 5 +++++ btrfs-completion | 2 +- cmds/rescue.c | 35 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-)
--
2.26.2
PATCH 1/3 btrfs-progs: rescue: Add create-control-device subcommand
This commit adds a new btrfs rescue create-control-device subcommand that creats /dev/btrfs-control. This is helpful on systems that may not have mknod installed.
--- cmds/rescue.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
cmds/rescue.c +35 -0
@@ -18,6 +18,12 @@#include "kerncompat.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> +#include <fcntl.h> +#include <unistd.h> +#include <getopt.h> #include "kernel-shared/ctree.h" #include "kernel-shared/volumes.h"
@@ -264,6 +270,34 @@ out: } static DEFINE_SIMPLE_COMMAND(rescue_fix_device_size, "fix-device-size"); +static const char *const cmd_rescue_create_control_device_usage[] = { +"btrfs rescue create-control-device" , +"Create /dev/btrfs-control (see 'CONTROL DEVICE' in btrfs(5))" , +NULL +}; + +static int cmd_rescue_create_control_device (const struct cmd_struct *cmd, +int argc,char **argv) +{ +dev_t device; +int ret; + +if (check_argc_exact (argc,1 )) +return 1 ; + + device =makedev (10 ,234 ); + + ret =mknod ("/dev/btrfs-control" ,S_IFCHR |S_IRUSR |S_IWUSR , device); +if (ret) { +error ("could not create /dev/btrfs-control: %m" ); +return 1 ; + } + +return 0 ; + +} +static DEFINE_SIMPLE_COMMAND(rescue_create_control_device, "create-control-device"); + static const char rescue_cmd_group_info[] ="toolbox for specific rescue operations" ;
@@ -273,6 +307,7 @@ static const struct cmd_group rescue_cmd_group = { &cmd_struct_rescue_super_recover, &cmd_struct_rescue_zero_log, &cmd_struct_rescue_fix_device_size, + &cmd_struct_rescue_create_control_device, NULL } };
Signature · 1 line
2.26.2
PATCH 3/3 btrfs-progs: rescue: Update docs with create-control-device
In reply to Daniel XuThis commit updates the documentation for the new btrfs rescue create-control-device subcommand.
--- Documentation/btrfs-man5.asciidoc | 8 +++++++- Documentation/btrfs-rescue.asciidoc | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-)
Documentation/btrfs-man5.asciidoc +7 -1
@@ -898,12 +898,18 @@ filesystem module: * get the supported features (can be also found under '/sys/fs/btrfs/features') The device is usually created by a system device node manager (eg. udev), but -can be created manually: +can be created manually with: -------------------- # mknod --mode=600 c 10 234 /dev/btrfs-control -------------------- +or with: + +-------------------- +# btrfs rescue create-control-device +-------------------- + The control device is not strictly required but the device scanning will not work and a workaround would need to be used to mount a multi-device filesystem. The mount option 'device' can trigger the device scanning during mount.
Documentation/btrfs-rescue.asciidoc +5 -0
@@ -93,6 +93,11 @@ the log and the filesystem may be mounted normally again. The keywords to look for are 'open_ctree' which says that it's during mount and function names that contain 'replay', 'recover' or 'log_tree'. +*create-control-device* :: +Creates /dev/btrfs-control control device ++ +This command is for convenience when *mknod* is not installed on a system. + EXIT STATUS ----------- *btrfs rescue* returns a zero exit status if it succeeds. Non zero is
Signature · 1 line
2.26.2
PATCH 2/3 btrfs-progs: bash: Update completion script with create-control-device
In reply to Daniel XuThe previous commit added a new subcommand so in this commit we update the bash completion script.
--- btrfs-completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
btrfs-completion +1 -1
@@ -28,7 +28,7 @@ _btrfs() commands_balance='start pause cancel resume status' commands_device='scan add delete remove ready stats usage' commands_scrub='start cancel resume status' - commands_rescue='chunk-recover super-recover zero-log' + commands_rescue='chunk-recover super-recover zero-log create-control-device' commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size dump-tree dump-super tree-stats' commands_property='get set list' commands_quota='enable disable rescan'
Signature · 1 line
2.26.2
Quoted 10 lines · Daniel Xu
This commit adds a new
btrfs rescue create-control-devicesubcommand that creats/dev/btrfs-control. This is helpful on systems that may not havemknodinstalled.Signed-off-by Daniel Xu <[email protected]>--- cmds/rescue.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
[...]
Ping
Quoted 8 lines · Daniel Xu
This patchset adds a new
btrfs rescue create-control-devicesubcommand that acts as a convenient way to invoke:# mknod --mode=600 c 10 234 /dev/btrfs-controlon systems that don't have
mknodinstalled or when you're lazy.
Thanks,
Josef
Quoted 6 lines · Daniel Xu
This patchset adds a new
btrfs rescue create-control-devicesubcommand that acts as a convenient way to invoke:# mknod --mode=600 c 10 234 /dev/btrfs-controlon systems that don't have
mknodinstalled or when you're lazy.
Well, I don't think the part 'lazy' applies.
The whole thing with the control device is simpler that I originally thought. On a system without loaded btrfs module there's no /dev/btrfs-control. This is correct because the device node is created at load time or when btrfs_interface_init is called.
Creating just the device node makes no sense because there's nothing handling it. Once module is loaded it appears and works as expected.
The only case where the rescue command makes sense is when the module is loaded, device node creatd and then manually deleted. This is possible but highly unlikely. For that reason the rescue command still has some sense but the reasoning needs to reflect how it's related to the module status.
As this is docs update only, I'll fix that myself, no need to resend.