btrfs-progs: Add command group for rescue operations
Subsystems (2)
cover btrfs-progs: Add command group for rescue operations
David Sterba (3):
btrfs-progs: introduce rescue command group
btrfs-progs: move chunk-recover to rescue group
btrfs-progs: separate command ant implementation of chunk-recover code
Makefile | 3 +- btrfs.c | 2 +- chunk-recover.c | 1745 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmds-chunk.c | 2 +- cmds-rescue.c | 100 ++++ commands.h | 3 + man/btrfs.8.in | 4 +- 7 files changed, 1854 insertions(+), 5 deletions(-) create mode 100644 chunk-recover.c create mode 100644 cmds-rescue.c
Signature · 1 line
1.8.3.1
PATCH 1/3 btrfs-progs: introduce rescue command group
Add an empty 1st level command namespace that will collect specialized recovery tools like chunk-recover, zero-log, select-super and similar.
--- Makefile | 2 +- btrfs.c | 1 + cmds-rescue.c | 37 +++++++++++++++++++++++++++++++++++++ commands.h | 3 +++ man/btrfs.8.in | 6 ++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 cmds-rescue.c
Makefile +1 -1
@@ -13,7 +13,7 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ - cmds-restore.o cmds-chunk.o cmds-dedup.o + cmds-restore.o cmds-chunk.o cmds-dedup.o cmds-rescue.o libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \ uuid-tree.o libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
btrfs.c +1 -0
@@ -247,6 +247,7 @@ static const struct cmd_group btrfs_cmd_group = { { "device", cmd_device, NULL, &device_cmd_group, 0 }, { "scrub", cmd_scrub, NULL, &scrub_cmd_group, 0 }, { "check", cmd_check, cmd_check_usage, NULL, 0 }, + { "rescue", cmd_rescue, NULL, &rescue_cmd_group, 0 }, { "chunk-recover", cmd_chunk_recover, cmd_chunk_recover_usage, NULL, 0}, { "restore", cmd_restore, cmd_restore_usage, NULL, 0 }, { "inspect-internal", cmd_inspect, NULL, &inspect_cmd_group, 0 },
cmds-rescue.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (C) 2013 SUSE. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 021110-1307, USA. +*/ + +#include "kerncompat.h" + +#include "commands.h" + +static const char *const rescue_cmd_group_usage[] = { +"btrfs rescue <command> [options] <path>" , +NULL +}; + +const struct cmd_group rescue_cmd_group = { + rescue_cmd_group_usage,NULL , { + {0 ,0 ,0 ,0 ,0 } + } +}; + +int cmd_rescue (int argc,char **argv) +{ +return handle_command_group (&rescue_cmd_group, argc, argv); +}
commands.h +3 -0
@@ -91,12 +91,14 @@ extern const struct cmd_group quota_cmd_group;extern const struct cmd_group qgroup_cmd_group;extern const struct cmd_group replace_cmd_group;extern const struct cmd_group dedup_cmd_group; +extern const struct cmd_group rescue_cmd_group;extern const char *const cmd_send_usage[];extern const char *const cmd_receive_usage[];extern const char *const cmd_check_usage[];extern const char *const cmd_chunk_recover_usage[];extern const char *const cmd_restore_usage[]; +extern const char *const cmd_rescue_usage[];int cmd_subvolume (int argc,char **argv);int cmd_filesystem (int argc,char **argv);
@@ -116,6 +118,7 @@ int cmd_select_super(int argc, char **argv);int cmd_dump_super (int argc,char **argv);int cmd_debug_tree (int argc,char **argv);int cmd_dedup (int argc,char **argv); +int cmd_rescue (int argc,char **argv);/* subvolume exported functions */ int test_issubvolume (char *path);
man/btrfs.8.in +6 -0
@@ -69,6 +69,8 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBcheck\fP [\fIoptions\fP] \fI<device>\fP .PP +\fBbtrfs\fP \fBrescue\fP [\fIoptions\fP] \fI<path>\fP +.PP \fBbtrfs\fP \fBchunk-recover\fP [\fIoptions\fP] \fI<device>\fP .PP \fBbtrfs\fP \fBrestore\fP [\fIoptions\fP] \fI<device>\fP
@@ -500,6 +502,10 @@ create a new extent tree. .RE .TP +\fBrescue\fR [\fIoptions\fP] <path>\fR +Rescue toolbox. +.TP + \fBchunk-recover\fR [\fIoptions\fP] <device>\fR Recover the chunk tree by scanning the devices one by one. .RS
Signature · 1 line
1.8.3.1
PATCH 2/3 btrfs-progs: move chunk-recover to rescue group
In reply to David Sterba--- btrfs.c | 1 - cmds-chunk.c | 2 +- cmds-rescue.c | 1 + man/btrfs.8.in | 10 ++-------- 4 files changed, 4 insertions(+), 10 deletions(-)
btrfs.c +0 -1
@@ -248,7 +248,6 @@ static const struct cmd_group btrfs_cmd_group = { { "scrub", cmd_scrub, NULL, &scrub_cmd_group, 0 }, { "check", cmd_check, cmd_check_usage, NULL, 0 }, { "rescue", cmd_rescue, NULL, &rescue_cmd_group, 0 }, - { "chunk-recover", cmd_chunk_recover, cmd_chunk_recover_usage, NULL, 0}, { "restore", cmd_restore, cmd_restore_usage, NULL, 0 }, { "inspect-internal", cmd_inspect, NULL, &inspect_cmd_group, 0 }, { "send", cmd_send, cmd_send_usage, NULL, 0 },
cmds-chunk.c +1 -1
@@ -1745,7 +1745,7 @@ fail_rc: }const char *const cmd_chunk_recover_usage[] = { -"btrfs chunk-recover [options] <device>" , +"btrfs rescue chunk-recover [options] <device>" ,"Recover the chunk tree by scanning the devices one by one." ,"" ,"-y Assume an answer of `yes' to all questions" ,
cmds-rescue.c +1 -0
@@ -27,6 +27,7 @@ static const char * const rescue_cmd_group_usage[] = {const struct cmd_group rescue_cmd_group = { rescue_cmd_group_usage,NULL , { + {"chunk-recover" , cmd_chunk_recover, cmd_chunk_recover_usage,NULL ,0 }, {0 ,0 ,0 ,0 ,0 } } };
man/btrfs.8.in +2 -8
@@ -69,9 +69,7 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBcheck\fP [\fIoptions\fP] \fI<device>\fP .PP -\fBbtrfs\fP \fBrescue\fP [\fIoptions\fP] \fI<path>\fP -.PP -\fBbtrfs\fP \fBchunk-recover\fP [\fIoptions\fP] \fI<device>\fP +\fBbtrfs\fP \fBrescue chunk-recover\fP [\fIoptions\fP] \fI<path>\fP .PP \fBbtrfs\fP \fBrestore\fP [\fIoptions\fP] \fI<device>\fP .PP
@@ -502,11 +500,7 @@ create a new extent tree. .RE .TP -\fBrescue\fR [\fIoptions\fP] <path>\fR -Rescue toolbox. -.TP - -\fBchunk-recover\fR [\fIoptions\fP] <device>\fR +\fBrescue chunk-recover\fR [\fIoptions\fP] <device>\fR Recover the chunk tree by scanning the devices one by one. .RS
Signature · 1 line
1.8.3.1
PATCH 3/3 btrfs-progs: separate command ant implementation of chunk-recover code
In reply to David SterbaThe command has been moved and we should rename the files accordingly, so the entry point is now in cmds-rescue.c and the core functionality in it's own file.
Return codes of btrfs_recover_chunk_tree have been simplified not to require a define and another file for defintion.
--- Makefile | 3 +- chunk-recover.c | 1745 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmds-rescue.c | 62 ++ 3 files changed, 1809 insertions(+), 1 deletion(-) create mode 100644 chunk-recover.c
Makefile +2 -1
@@ -13,7 +13,8 @@ objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \ - cmds-restore.o cmds-chunk.o cmds-dedup.o cmds-rescue.o + cmds-restore.o cmds-dedup.o cmds-rescue.o \ + chunk-recover.o libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \ uuid-tree.o libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
chunk-recover.c new file +1745 -0
1,745 lines not on this page · raw message
cmds-rescue.c +62 -0
75 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 3/3] btrfs-progs: separate command ant implementation of chunk-recover code
Quoted 7 lines · David Sterba
The command has been moved and we should rename the files accordingly, so the entry point is now in
cmds-rescue.cand the core functionality in it's own file.Return codes of
btrfs_recover_chunk_treehave been simplified not to require a define and another file for defintion.
Quoted 9 lines
CC Miao Xie <[email protected]>Signed-off-by David Sterba <[email protected]>--- Makefile | 3 +- chunk-recover.c | 1745 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmds-rescue.c | 62 ++ 3 files changed, 1809 insertions(+), 1 deletion(-) create mode 100644 chunk-recover.c
I'm not sure if this patch has gone 'final' yet, but since it relocates the code from cmds-chunk.c to chunk-recover.c, the cmds-chunk.c file needs to be deleted.
Re: [PATCH 3/3] btrfs-progs: separate command ant implementation of chunk-recover code
Quoted 17 lines · Mitch Harder
Quoted 7 lines · David Sterba
The command has been moved and we should rename the files accordingly, so the entry point is now in
cmds-rescue.cand the core functionality in it's own file.Return codes of
btrfs_recover_chunk_treehave been simplified not to require a define and another file for defintion.Quoted 8 lines
CC Miao Xie <[email protected]>Signed-off-by David Sterba <[email protected]>--- Makefile | 3 +- chunk-recover.c | 1745 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmds-rescue.c | 62 ++ 3 files changed, 1809 insertions(+), 1 deletion(-) create mode 100644 chunk-recover.c
Quoted 3 lines
I'm not sure if this patch has gone 'final' yet, but since it relocates the code from
cmds-chunk.ctochunk-recover.c, thecmds-chunk.cfile needs to be deleted.
Right, thanks for noticing.
david