From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] Revert "btrfs-progs: subvol delete: add options to delete the qgroup"
Date: Fri, 26 Apr 2024 07:35:52 +0930 [thread overview]
Message-ID: <fa8f65936f31c07ca4783229140ecfb1f7ada785.1714082499.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1714082499.git.wqu@suse.com>
This reverts commit 9da773aa46ba33a9c3bdd83b31e15b031b3bfe4d.
There are several problems related to the --delete-qgroup option:
- Currently kernel doesn not allow to delete non-empty qgroups
- A qgroup can only be empty after fully dropped and a transaction is
committed
The tool doesn not take either factor into consideration
- Things like drop_subtree_threshold or other operations can mark qgroup
inconsistent and skip accounting
This can mean the target qgroup will never be empty until next rescan
On the other hand, even if we do the proper way, it would hugely delay
the command (wait until the subvolume to be dropped).
Furthermore, even all the wait is handled properly,
drop_subtree_threshold can still prevent us deleting the qgroup (qgroup
numbers are inconsistent, and accounting is skipped completely).
So this qgroup cleanup needs kernel work to support them anyway, and it
would be much easier to handle all the operations inside kernel.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Documentation/btrfs-subvolume.rst | 7 -------
cmds/subvolume.c | 26 --------------------------
2 files changed, 33 deletions(-)
diff --git a/Documentation/btrfs-subvolume.rst b/Documentation/btrfs-subvolume.rst
index d4379a2df83d..d1e89f15e1e2 100644
--- a/Documentation/btrfs-subvolume.rst
+++ b/Documentation/btrfs-subvolume.rst
@@ -112,13 +112,6 @@ delete [options] [<subvolume> [<subvolume>...]], delete -i|--subvolid <subvolid>
-i|--subvolid <subvolid>
subvolume id to be removed instead of the <path> that should point to the
filesystem with the subvolume
-
- --delete-qgroup
- also delete the qgroup 0/subvolid if it exists
-
- --no-delete-qgroup
- do not delete the 0/subvolid qgroup (default)
-
-v|--verbose
(deprecated) alias for global *-v* option
diff --git a/cmds/subvolume.c b/cmds/subvolume.c
index 319f595ca495..f77a6e091569 100644
--- a/cmds/subvolume.c
+++ b/cmds/subvolume.c
@@ -348,8 +348,6 @@ static const char * const cmd_subvolume_delete_usage[] = {
OPTLINE("-c|--commit-after", "wait for transaction commit at the end of the operation"),
OPTLINE("-C|--commit-each", "wait for transaction commit after deleting each subvolume"),
OPTLINE("-i|--subvolid", "subvolume id of the to be removed subvolume"),
- OPTLINE("--delete-qgroup", "also delete the qgroup 0/subvolid if it exists"),
- OPTLINE("--no-delete-qgroup", "do not delete the qgroup 0/subvolid if it exists (default)"),
OPTLINE("-v|--verbose", "deprecated, alias for global -v option"),
HELPINFO_INSERT_GLOBALS,
HELPINFO_INSERT_VERBOSE,
@@ -378,20 +376,15 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
enum { COMMIT_AFTER = 1, COMMIT_EACH = 2 };
enum btrfs_util_error err;
uint64_t default_subvol_id, target_subvol_id = 0;
- bool opt_delete_qgroup = false;
optind = 0;
while (1) {
int c;
- enum { GETOPT_VAL_DELETE_QGROUP = GETOPT_VAL_FIRST,
- GETOPT_VAL_NO_DELETE_QGROUP };
static const struct option long_options[] = {
{"commit-after", no_argument, NULL, 'c'},
{"commit-each", no_argument, NULL, 'C'},
{"subvolid", required_argument, NULL, 'i'},
{"verbose", no_argument, NULL, 'v'},
- {"delete-qgroup", no_argument, NULL, GETOPT_VAL_DELETE_QGROUP },
- {"no-delete-qgroup", no_argument, NULL, GETOPT_VAL_NO_DELETE_QGROUP },
{NULL, 0, NULL, 0}
};
@@ -412,12 +405,6 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
case 'v':
bconf_be_verbose();
break;
- case GETOPT_VAL_DELETE_QGROUP:
- opt_delete_qgroup = true;
- break;
- case GETOPT_VAL_NO_DELETE_QGROUP:
- opt_delete_qgroup = false;
- break;
default:
usage_unknown_option(cmd, argv);
}
@@ -553,19 +540,6 @@ again:
warning("deletion failed with EPERM, you don't have permissions or send may be in progress");
ret = 1;
goto out;
- } else if (opt_delete_qgroup) {
- struct btrfs_ioctl_qgroup_create_args args = { .qgroupid = target_subvol_id };
-
- ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
- if (ret == 0) {
- pr_verbose(LOG_DEFAULT, "Delete qgroup 0/%" PRIu64 "\n", target_subvol_id);
- } else if (ret < 0 && (errno == ENOTCONN || errno == ENOENT)) {
- /* Quotas not enabled, or there's no qgroup. */
- } else {
- warning("unable to delete qgroup 0/%llu: %m", subvolid);
- }
- /* Qgroup errors are not fatal. */
- ret = 0;
}
if (commit_mode == COMMIT_EACH) {
--
2.44.0
next prev parent reply other threads:[~2024-04-25 22:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 22:05 [PATCH 0/2] btrfs-progs: revert `btrfs subvolume delete --delete-qgroup` option Qu Wenruo
2024-04-25 22:05 ` Qu Wenruo [this message]
2024-04-25 22:05 ` [PATCH 2/2] btrfs: misc-tests: remove the subvol-delete-qgroup test case Qu Wenruo
2024-04-29 17:48 ` David Sterba
2024-04-29 17:29 ` [PATCH 0/2] btrfs-progs: revert `btrfs subvolume delete --delete-qgroup` option David Sterba
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=fa8f65936f31c07ca4783229140ecfb1f7ada785.1714082499.git.wqu@suse.com \
--to=wqu@suse.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