linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand
@ 2020-10-29 23:17 Daniel Xu
  2020-10-29 23:17 ` [PATCH 1/3] " Daniel Xu
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Daniel Xu @ 2020-10-29 23:17 UTC (permalink / raw)
  To: linux-btrfs, dsterba; +Cc: Daniel Xu, kernel-team

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.

Link: https://github.com/kdave/btrfs-progs/issues/223

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] btrfs-progs: rescue: Add create-control-device subcommand
  2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
@ 2020-10-29 23:17 ` Daniel Xu
  2020-11-11  1:33   ` Daniel Xu
  2020-10-29 23:17 ` [PATCH 2/3] btrfs-progs: bash: Update completion script with create-control-device Daniel Xu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Daniel Xu @ 2020-10-29 23:17 UTC (permalink / raw)
  To: linux-btrfs, dsterba; +Cc: Daniel Xu, kernel-team

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.

Link: https://github.com/kdave/btrfs-progs/issues/223
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
 cmds/rescue.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/cmds/rescue.c b/cmds/rescue.c
index 100d25f3..e6972fb7 100644
--- a/cmds/rescue.c
+++ b/cmds/rescue.c
@@ -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
 	}
 };
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] btrfs-progs: bash: Update completion script with create-control-device
  2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
  2020-10-29 23:17 ` [PATCH 1/3] " Daniel Xu
@ 2020-10-29 23:17 ` Daniel Xu
  2020-10-29 23:17 ` [PATCH 3/3] btrfs-progs: rescue: Update docs " Daniel Xu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Xu @ 2020-10-29 23:17 UTC (permalink / raw)
  To: linux-btrfs, dsterba; +Cc: Daniel Xu, kernel-team

The previous commit added a new subcommand so in this commit we update
the bash completion script.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
 btrfs-completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btrfs-completion b/btrfs-completion
index 6ae57d1b..5bbd5378 100644
--- a/btrfs-completion
+++ b/btrfs-completion
@@ -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'
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] btrfs-progs: rescue: Update docs with create-control-device
  2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
  2020-10-29 23:17 ` [PATCH 1/3] " Daniel Xu
  2020-10-29 23:17 ` [PATCH 2/3] btrfs-progs: bash: Update completion script with create-control-device Daniel Xu
@ 2020-10-29 23:17 ` Daniel Xu
  2020-11-13 20:34 ` [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Josef Bacik
  2021-02-19 14:48 ` David Sterba
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Xu @ 2020-10-29 23:17 UTC (permalink / raw)
  To: linux-btrfs, dsterba; +Cc: Daniel Xu, kernel-team

This commit updates the documentation for the new `btrfs rescue
create-control-device` subcommand.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
 Documentation/btrfs-man5.asciidoc   | 8 +++++++-
 Documentation/btrfs-rescue.asciidoc | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/btrfs-man5.asciidoc b/Documentation/btrfs-man5.asciidoc
index 65352009..082599c1 100644
--- a/Documentation/btrfs-man5.asciidoc
+++ b/Documentation/btrfs-man5.asciidoc
@@ -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.
diff --git a/Documentation/btrfs-rescue.asciidoc b/Documentation/btrfs-rescue.asciidoc
index af544372..db40ce64 100644
--- a/Documentation/btrfs-rescue.asciidoc
+++ b/Documentation/btrfs-rescue.asciidoc
@@ -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
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] btrfs-progs: rescue: Add create-control-device subcommand
  2020-10-29 23:17 ` [PATCH 1/3] " Daniel Xu
@ 2020-11-11  1:33   ` Daniel Xu
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Xu @ 2020-11-11  1:33 UTC (permalink / raw)
  To: linux-btrfs, dsterba; +Cc: Kernel Team

On Thu, Oct 29, 2020, at 4:17 PM, Daniel Xu wrote:
> 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.
> 
> Link: https://github.com/kdave/btrfs-progs/issues/223
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
>  cmds/rescue.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
[...]

Ping

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand
  2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
                   ` (2 preceding siblings ...)
  2020-10-29 23:17 ` [PATCH 3/3] btrfs-progs: rescue: Update docs " Daniel Xu
@ 2020-11-13 20:34 ` Josef Bacik
  2021-02-19 14:48 ` David Sterba
  4 siblings, 0 replies; 7+ messages in thread
From: Josef Bacik @ 2020-11-13 20:34 UTC (permalink / raw)
  To: Daniel Xu, linux-btrfs, dsterba; +Cc: kernel-team

On 10/29/20 7:17 PM, Daniel Xu wrote:
> 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.
> 
> Link: https://github.com/kdave/btrfs-progs/issues/223

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand
  2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
                   ` (3 preceding siblings ...)
  2020-11-13 20:34 ` [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Josef Bacik
@ 2021-02-19 14:48 ` David Sterba
  4 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2021-02-19 14:48 UTC (permalink / raw)
  To: Daniel Xu; +Cc: linux-btrfs, dsterba, kernel-team

On Thu, Oct 29, 2020 at 04:17:35PM -0700, Daniel Xu wrote:
> 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.

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-19 14:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 23:17 [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Daniel Xu
2020-10-29 23:17 ` [PATCH 1/3] " Daniel Xu
2020-11-11  1:33   ` Daniel Xu
2020-10-29 23:17 ` [PATCH 2/3] btrfs-progs: bash: Update completion script with create-control-device Daniel Xu
2020-10-29 23:17 ` [PATCH 3/3] btrfs-progs: rescue: Update docs " Daniel Xu
2020-11-13 20:34 ` [PATCH 0/3] btrfs-progs: rescue: Add create-control-device subcommand Josef Bacik
2021-02-19 14:48 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).