From: Omar Sandoval <osandov@osandov.com>
To: linux-btrfs@vger.kernel.org
Cc: kernel-team@fb.com
Subject: [PATCH v2 25/27] btrfs-progs: add recursive snapshot/delete using libbtrfsutil
Date: Thu, 15 Feb 2018 11:05:10 -0800 [thread overview]
Message-ID: <0c443530936babb4c061c71817aa324da168e116.1518720598.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1518720598.git.osandov@fb.com>
In-Reply-To: <cover.1518720598.git.osandov@fb.com>
From: Omar Sandoval <osandov@fb.com>
And update the documentation.
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
Documentation/btrfs-subvolume.asciidoc | 14 ++++++++++++--
cmds-subvolume.c | 25 +++++++++++++++++++++----
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc
index a8c4af4b..7a2ec8d2 100644
--- a/Documentation/btrfs-subvolume.asciidoc
+++ b/Documentation/btrfs-subvolume.asciidoc
@@ -81,6 +81,12 @@ wait for transaction commit at the end of the operation
+
-C|--commit-each::::
wait for transaction commit after deleting each subvolume
++
+-R|--recursive::::
+delete subvolumes beneath each subvolume recursively
++
+-v|--verbose::::
+output more verbosely
*find-new* <subvolume> <last_gen>::
List the recently modified files in a subvolume, after <last_gen> ID.
@@ -157,7 +163,7 @@ The id can be obtained from *btrfs subvolume list*, *btrfs subvolume show* or
*show* <path>::
Show information of a given subvolume in the <path>.
-*snapshot* [-r] <source> <dest>|[<dest>/]<name>::
+*snapshot* [-r|-R] <source> <dest>|[<dest>/]<name>::
Create a snapshot of the subvolume <source> with the
name <name> in the <dest> directory.
+
@@ -167,7 +173,11 @@ If <source> is not a subvolume, btrfs returns an error.
`Options`
+
-r::::
-Make the new snapshot read only.
+make the new snapshot read-only
++
+-R::::
+recursively snapshot subvolumes beneath the source; this option cannot be
+combined with -r
*sync* <path> [subvolid...]::
Wait until given subvolume(s) are completely removed from the filesystem after
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 43875c96..101ba4ca 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -187,6 +187,7 @@ static const char * const cmd_subvol_delete_usage[] = {
"",
"-c|--commit-after wait for transaction commit at the end of the operation",
"-C|--commit-each wait for transaction commit after deleting each subvolume",
+ "-R|--recursive delete subvolumes beneath each subvolume recursively",
"-v|--verbose verbose output of operations",
NULL
};
@@ -203,6 +204,7 @@ static int cmd_subvol_delete(int argc, char **argv)
DIR *dirstream = NULL;
int verbose = 0;
int commit_mode = 0;
+ int flags = 0;
u8 fsid[BTRFS_FSID_SIZE];
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
struct seen_fsid *seen_fsid_hash[SEEN_FSID_HASH_SIZE] = { NULL, };
@@ -214,11 +216,12 @@ static int cmd_subvol_delete(int argc, char **argv)
static const struct option long_options[] = {
{"commit-after", no_argument, NULL, 'c'},
{"commit-each", no_argument, NULL, 'C'},
+ {"recursive", no_argument, NULL, 'R'},
{"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
- c = getopt_long(argc, argv, "cCv", long_options, NULL);
+ c = getopt_long(argc, argv, "cCRv", long_options, NULL);
if (c < 0)
break;
@@ -229,6 +232,9 @@ static int cmd_subvol_delete(int argc, char **argv)
case 'C':
commit_mode = COMMIT_EACH;
break;
+ case 'R':
+ flags |= BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE;
+ break;
case 'v':
verbose++;
break;
@@ -280,7 +286,7 @@ again:
commit_mode == COMMIT_EACH || (commit_mode == COMMIT_AFTER && cnt + 1 == argc)
? "commit" : "no-commit", dname, vname);
- err = btrfs_util_delete_subvolume_fd(fd, vname, 0);
+ err = btrfs_util_delete_subvolume_fd(fd, vname, flags);
if (err) {
error_btrfs_util(err);
ret = 1;
@@ -569,13 +575,15 @@ out:
}
static const char * const cmd_subvol_snapshot_usage[] = {
- "btrfs subvolume snapshot [-r] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>",
+ "btrfs subvolume snapshot [-r|-R] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>",
"Create a snapshot of the subvolume",
"Create a writable/readonly snapshot of the subvolume <source> with",
"the name <name> in the <dest> directory. If only <dest> is given,",
"the subvolume will be named the basename of <source>.",
"",
"-r create a readonly snapshot",
+ "-R recursively snapshot subvolumes beneath the source; this",
+ " option cannot be combined with -r",
"-i <qgroupid> add the newly created snapshot to a qgroup. This",
" option can be given multiple times.",
NULL
@@ -589,7 +597,7 @@ static int cmd_subvol_snapshot(int argc, char **argv)
int retval = 1;
while (1) {
- int c = getopt(argc, argv, "i:r");
+ int c = getopt(argc, argv, "i:rR");
if (c < 0)
break;
@@ -601,11 +609,20 @@ static int cmd_subvol_snapshot(int argc, char **argv)
case 'r':
flags |= BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY;
break;
+ case 'R':
+ flags |= BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE;
+ break;
default:
usage(cmd_subvol_snapshot_usage);
}
}
+ if ((flags & BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY) &&
+ (flags & BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE)) {
+ error("-r and -R cannot be combined");
+ return 1;
+ }
+
if (check_argc_exact(argc - optind, 2))
usage(cmd_subvol_snapshot_usage);
--
2.16.1
next prev parent reply other threads:[~2018-02-15 19:05 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 19:04 [PATCH v2 00/27] btrfs-progs: introduce libbtrfsutil, "btrfs-progs as a library" Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 01/27] btrfs-progs: get rid of undocumented qgroup inheritance options Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 02/27] Add libbtrfsutil Omar Sandoval
2018-02-20 17:32 ` Liu Bo
2018-02-20 18:34 ` David Sterba
2018-02-15 19:04 ` [PATCH v2 03/27] libbtrfsutil: add Python bindings Omar Sandoval
2018-02-21 13:47 ` David Sterba
2018-02-21 18:08 ` Omar Sandoval
2018-02-22 1:44 ` Misono, Tomohiro
2018-02-15 19:04 ` [PATCH v2 04/27] libbtrfsutil: add btrfs_util_is_subvolume() and btrfs_util_subvolume_id() Omar Sandoval
2018-02-21 11:43 ` David Sterba
2018-02-21 13:02 ` David Sterba
2018-02-21 18:13 ` Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 05/27] libbtrfsutil: add qgroup inheritance helpers Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 06/27] libbtrfsutil: add btrfs_util_create_subvolume() Omar Sandoval
2018-02-23 8:24 ` Misono, Tomohiro
2018-02-23 22:58 ` Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 07/27] libbtrfsutil: add btrfs_util_subvolume_path() Omar Sandoval
2018-02-23 6:27 ` Misono, Tomohiro
2018-02-23 22:44 ` Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 08/27] libbtrfsutil: add btrfs_util_subvolume_info() Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 09/27] libbtrfsutil: add btrfs_util_[gs]et_read_only() Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 10/27] libbtrfsutil: add btrfs_util_[gs]et_default_subvolume() Omar Sandoval
2018-02-22 1:55 ` Misono, Tomohiro
2018-02-23 22:40 ` Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 11/27] libbtrfsutil: add subvolume iterator helpers Omar Sandoval
2018-02-23 7:40 ` Misono, Tomohiro
2018-02-23 22:49 ` Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 12/27] libbtrfsutil: add btrfs_util_create_snapshot() Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 13/27] libbtrfsutil: add btrfs_util_delete_subvolume() Omar Sandoval
2018-02-15 19:04 ` [PATCH v2 14/27] libbtrfsutil: add btrfs_util_deleted_subvolumes() Omar Sandoval
2018-02-23 2:12 ` Misono, Tomohiro
2018-02-23 23:33 ` Omar Sandoval
2018-02-28 4:11 ` Misono, Tomohiro
2018-02-15 19:05 ` [PATCH v2 15/27] libbtrfsutil: add filesystem sync helpers Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 16/27] btrfs-progs: use libbtrfsutil for read-only property Omar Sandoval
2018-02-22 4:23 ` Misono, Tomohiro
2018-02-23 22:41 ` Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 17/27] btrfs-progs: use libbtrfsutil for sync ioctls Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 18/27] btrfs-progs: use libbtrfsutil for set-default Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 19/27] btrfs-progs: use libbtrfsutil for get-default Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 20/27] btrfs-progs: use libbtrfsutil for subvol create and snapshot Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 21/27] btrfs-progs: use libbtrfsutil for subvol delete Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 22/27] btrfs-progs: use libbtrfsutil for subvol show Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 23/27] btrfs-progs: use libbtrfsutil for subvol sync Omar Sandoval
2018-02-22 2:03 ` Misono, Tomohiro
2018-02-23 22:41 ` Omar Sandoval
2018-02-23 23:22 ` David Sterba
2018-02-22 2:09 ` Misono, Tomohiro
2018-02-15 19:05 ` [PATCH v2 24/27] btrfs-progs: replace test_issubvolume() with btrfs_util_is_subvolume() Omar Sandoval
2018-02-15 19:05 ` Omar Sandoval [this message]
2018-02-15 19:05 ` [PATCH v2 26/27] btrfs-progs: use libbtrfsutil for subvolume list Omar Sandoval
2018-02-23 2:26 ` Misono, Tomohiro
2018-02-23 23:05 ` Omar Sandoval
2018-02-15 19:05 ` [PATCH v2 27/27] btrfs-progs: deprecate libbtrfs helpers Omar Sandoval
2018-02-21 15:04 ` David Sterba
2018-02-21 18:19 ` Omar Sandoval
2018-02-20 18:50 ` [PATCH v2 00/27] btrfs-progs: introduce libbtrfsutil, "btrfs-progs as a library" David Sterba
2018-02-21 15:13 ` David Sterba
2018-02-21 18:50 ` Omar Sandoval
2018-02-23 20:28 ` David Sterba
2018-02-26 23:36 ` Omar Sandoval
2018-02-27 15:04 ` David Sterba
2018-02-27 20:48 ` Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0c443530936babb4c061c71817aa324da168e116.1518720598.git.osandov@fb.com \
--to=osandov@osandov.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).