diff mbox series

btrfs: remove btrfs_qgroup_inherit_add_copy()

Message ID 25d16c7c81b93d33d23fcbcaa35c24ce07cc00ef.1709006537.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: remove btrfs_qgroup_inherit_add_copy() | expand

Commit Message

Qu Wenruo Feb. 27, 2024, 4:02 a.m. UTC
The function btrfs_qgroup_inherit_add_copy() is designed to add a pair
of source/destination qgroups into btrfs_qgroup_inherit structure, so
that rfer/excl numbers would be copied from the source qgroup into the
destination one.

This behavior is intentionally hidden since 2016, as such copy will
cause qgroup inconsistent immediately and a rescan would reset whatever
numbers copied anyway.

Now we're going to reject the copy behaviors from kernel, there is no
need to keep those hidden (and already disabled for "subvolume create")
behaviors.

This patch would remove btrfs_qgroup_inherit_add_copy() call, and
cleanup those undocumented options.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 cmds/qgroup.c    | 41 -----------------------------------------
 cmds/qgroup.h    |  2 --
 cmds/subvolume.c | 23 +----------------------
 3 files changed, 1 insertion(+), 65 deletions(-)

Comments

David Sterba Feb. 28, 2024, 2:52 p.m. UTC | #1
On Tue, Feb 27, 2024 at 02:32:33PM +1030, Qu Wenruo wrote:
> The function btrfs_qgroup_inherit_add_copy() is designed to add a pair
> of source/destination qgroups into btrfs_qgroup_inherit structure, so
> that rfer/excl numbers would be copied from the source qgroup into the
> destination one.
> 
> This behavior is intentionally hidden since 2016, as such copy will
> cause qgroup inconsistent immediately and a rescan would reset whatever
> numbers copied anyway.
> 
> Now we're going to reject the copy behaviors from kernel, there is no
> need to keep those hidden (and already disabled for "subvolume create")
> behaviors.
> 
> This patch would remove btrfs_qgroup_inherit_add_copy() call, and
> cleanup those undocumented options.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Ok let's remove the support, I don't think we have a clear use case for
that. Added to devel, thanks.
diff mbox series

Patch

diff --git a/cmds/qgroup.c b/cmds/qgroup.c
index 20cc14aa8a58..72d68d918f7e 100644
--- a/cmds/qgroup.c
+++ b/cmds/qgroup.c
@@ -1687,47 +1687,6 @@  int btrfs_qgroup_inherit_add_group(struct btrfs_qgroup_inherit **inherit, char *
 	return 0;
 }
 
-int btrfs_qgroup_inherit_add_copy(struct btrfs_qgroup_inherit **inherit, char *arg,
-			    int type)
-{
-	int ret;
-	u64 qgroup_src;
-	u64 qgroup_dst;
-	char *p;
-	int pos = 0;
-
-	p = strchr(arg, ':');
-	if (!p) {
-bad:
-		error("invalid copy specification, missing separator :");
-		return -EINVAL;
-	}
-	*p = 0;
-	qgroup_src = parse_qgroupid_or_path(arg);
-	qgroup_dst = parse_qgroupid_or_path(p + 1);
-	*p = ':';
-
-	if (!qgroup_src || !qgroup_dst)
-		goto bad;
-
-	if (*inherit)
-		pos = (*inherit)->num_qgroups +
-		      (*inherit)->num_ref_copies * 2 * type;
-
-	ret = qgroup_inherit_realloc(inherit, 2, pos);
-	if (ret)
-		return ret;
-
-	(*inherit)->qgroups[pos++] = qgroup_src;
-	(*inherit)->qgroups[pos++] = qgroup_dst;
-
-	if (!type)
-		++(*inherit)->num_ref_copies;
-	else
-		++(*inherit)->num_excl_copies;
-
-	return 0;
-}
 static const char * const qgroup_cmd_group_usage[] = {
 	"btrfs qgroup <command> [options] <path>",
 	NULL
diff --git a/cmds/qgroup.h b/cmds/qgroup.h
index db48c0c2f8e2..1fc107221c3b 100644
--- a/cmds/qgroup.h
+++ b/cmds/qgroup.h
@@ -38,8 +38,6 @@  struct btrfs_qgroup_stats {
 
 int btrfs_qgroup_inherit_size(struct btrfs_qgroup_inherit *p);
 int btrfs_qgroup_inherit_add_group(struct btrfs_qgroup_inherit **inherit, char *arg);
-int btrfs_qgroup_inherit_add_copy(struct btrfs_qgroup_inherit **inherit, char *arg,
-			    int type);
 int btrfs_qgroup_query(int fd, u64 qgroupid, struct btrfs_qgroup_stats *stats);
 
 #endif
diff --git a/cmds/subvolume.c b/cmds/subvolume.c
index 30ddf178221f..00c5eacfa694 100644
--- a/cmds/subvolume.c
+++ b/cmds/subvolume.c
@@ -281,13 +281,6 @@  static int cmd_subvolume_create(const struct cmd_struct *cmd, int argc, char **a
 			break;
 
 		switch (c) {
-		case 'c':
-			ret = btrfs_qgroup_inherit_add_copy(&inherit, optarg, 0);
-			if (ret) {
-				retval = ret;
-				goto out;
-			}
-			break;
 		case 'i':
 			ret = btrfs_qgroup_inherit_add_group(&inherit, optarg);
 			if (ret) {
@@ -685,18 +678,11 @@  static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
 	memset(&args, 0, sizeof(args));
 	optind = 0;
 	while (1) {
-		int c = getopt(argc, argv, "c:i:r");
+		int c = getopt(argc, argv, "i:r");
 		if (c < 0)
 			break;
 
 		switch (c) {
-		case 'c':
-			res = btrfs_qgroup_inherit_add_copy(&inherit, optarg, 0);
-			if (res) {
-				retval = res;
-				goto out;
-			}
-			break;
 		case 'i':
 			res = btrfs_qgroup_inherit_add_group(&inherit, optarg);
 			if (res) {
@@ -707,13 +693,6 @@  static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
 		case 'r':
 			readonly = true;
 			break;
-		case 'x':
-			res = btrfs_qgroup_inherit_add_copy(&inherit, optarg, 1);
-			if (res) {
-				retval = res;
-				goto out;
-			}
-			break;
 		default:
 			usage_unknown_option(cmd, argv);
 		}