Skip to content

Commit 99447fb

Browse files
adam900710kdave
authored andcommitted
Revert "btrfs-progs: subvol delete: add options to delete the qgroup"
This reverts commit 9da773a. There are several problems related to the --delete-qgroup option: - Currently kernel doesn't allow to delete non-empty qgroups - A qgroup can only be empty after fully dropped and a transaction is committed The tool doesn't 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 we do it the proper way, it would hugely delay the command (wait until the subvolume to be cleaned). Furthermore, even if the waiting is handled properly, drop_subtree_threshold can still prevent us deleting the qgroup (qgroup numbers are inconsistent, and accounting is skipped completely). So the qgroup cleanup needs kernel to make it work properly. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 40588d4 commit 99447fb

File tree

2 files changed

+0
-33
lines changed

2 files changed

+0
-33
lines changed

Documentation/btrfs-subvolume.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ delete [options] [<subvolume> [<subvolume>...]], delete -i|--subvolid <subvolid>
112112
-i|--subvolid <subvolid>
113113
subvolume id to be removed instead of the <path> that should point to the
114114
filesystem with the subvolume
115-
116-
--delete-qgroup
117-
also delete the qgroup 0/subvolid if it exists
118-
119-
--no-delete-qgroup
120-
do not delete the 0/subvolid qgroup (default)
121-
122115
-v|--verbose
123116
(deprecated) alias for global *-v* option
124117

cmds/subvolume.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ static const char * const cmd_subvolume_delete_usage[] = {
348348
OPTLINE("-c|--commit-after", "wait for transaction commit at the end of the operation"),
349349
OPTLINE("-C|--commit-each", "wait for transaction commit after deleting each subvolume"),
350350
OPTLINE("-i|--subvolid", "subvolume id of the to be removed subvolume"),
351-
OPTLINE("--delete-qgroup", "also delete the qgroup 0/subvolid if it exists"),
352-
OPTLINE("--no-delete-qgroup", "do not delete the qgroup 0/subvolid if it exists (default)"),
353351
OPTLINE("-v|--verbose", "deprecated, alias for global -v option"),
354352
HELPINFO_INSERT_GLOBALS,
355353
HELPINFO_INSERT_VERBOSE,
@@ -378,20 +376,15 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
378376
enum { COMMIT_AFTER = 1, COMMIT_EACH = 2 };
379377
enum btrfs_util_error err;
380378
uint64_t default_subvol_id, target_subvol_id = 0;
381-
bool opt_delete_qgroup = false;
382379

383380
optind = 0;
384381
while (1) {
385382
int c;
386-
enum { GETOPT_VAL_DELETE_QGROUP = GETOPT_VAL_FIRST,
387-
GETOPT_VAL_NO_DELETE_QGROUP };
388383
static const struct option long_options[] = {
389384
{"commit-after", no_argument, NULL, 'c'},
390385
{"commit-each", no_argument, NULL, 'C'},
391386
{"subvolid", required_argument, NULL, 'i'},
392387
{"verbose", no_argument, NULL, 'v'},
393-
{"delete-qgroup", no_argument, NULL, GETOPT_VAL_DELETE_QGROUP },
394-
{"no-delete-qgroup", no_argument, NULL, GETOPT_VAL_NO_DELETE_QGROUP },
395388
{NULL, 0, NULL, 0}
396389
};
397390

@@ -412,12 +405,6 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
412405
case 'v':
413406
bconf_be_verbose();
414407
break;
415-
case GETOPT_VAL_DELETE_QGROUP:
416-
opt_delete_qgroup = true;
417-
break;
418-
case GETOPT_VAL_NO_DELETE_QGROUP:
419-
opt_delete_qgroup = false;
420-
break;
421408
default:
422409
usage_unknown_option(cmd, argv);
423410
}
@@ -553,19 +540,6 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
553540
warning("deletion failed with EPERM, you don't have permissions or send may be in progress");
554541
ret = 1;
555542
goto out;
556-
} else if (opt_delete_qgroup) {
557-
struct btrfs_ioctl_qgroup_create_args args = { .qgroupid = target_subvol_id };
558-
559-
ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
560-
if (ret == 0) {
561-
pr_verbose(LOG_DEFAULT, "Delete qgroup 0/%" PRIu64 "\n", target_subvol_id);
562-
} else if (ret < 0 && (errno == ENOTCONN || errno == ENOENT)) {
563-
/* Quotas not enabled, or there's no qgroup. */
564-
} else {
565-
warning("unable to delete qgroup 0/%llu: %m", subvolid);
566-
}
567-
/* Qgroup errors are not fatal. */
568-
ret = 0;
569543
}
570544

571545
if (commit_mode == COMMIT_EACH) {

0 commit comments

Comments
 (0)