From patchwork Fri Jun 28 14:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 13716307 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EE771C2310 for ; Fri, 28 Jun 2024 14:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586709; cv=none; b=mYsm9owKfKPMiCYuHHDj7jlWR3fxLnp4CnmCLJzMWnuq6+OUPjxjeCiEUdPmAiVO2nfnTH3jHyGQKbjCK7nf0JpzSj6flvewQKeyexu8Pwo6ZJT/djgHCpd3uXe3RLb4lzI1hBqPr+uQfM9EK4iSWF6VG/rzXr/wsgZZqAHey5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586709; c=relaxed/simple; bh=V1v5Y1qvJsmErKP6eACPBZmmln2eDlfF8LdIb+V+BSA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TDEnnZhbg9PtaIJSlwFT5ro3HJzyqo5gZuIlwXGGvLFzjI0sSCjQIdrGT9KsT2Erte0jKDYOPz83kz7H6QdF9xNZRZ2NdM3b0OVWmmumOQKJtMUR4rt2f53emeFOfkRu1qqTRpVLZNx8FLv7F7QSslZ+u8Hqk6TIChheM0NKEvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b=a48CjYxp; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="a48CjYxp" Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45SA2YbG010220 for ; Fri, 28 Jun 2024 07:58:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= facebook; bh=RcgqlsiejS1+Zj59bYvDBllgmGWEMxCRDauiY4blxVE=; b=a48 CjYxpShEiMp8H5CjvNceaBvQRUFN5ZwonGalHlTRNKsqtLiNMfRC4P1KxzlvN2vf 9WP1Jx6AAQoZOTuPgPeMr38eZ0P45BQ22d4rvf6eK5SwuF3LAuKtqc9DAQiKCRLr ehBo93c7Hi/D4nQLpkvK8X3H8obp73GDDQomNp8k= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 401grkv7sp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 28 Jun 2024 07:58:27 -0700 (PDT) Received: from twshared13822.17.frc2.facebook.com (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Fri, 28 Jun 2024 14:58:25 +0000 Received: by devbig276.nha1.facebook.com (Postfix, from userid 660015) id C72F33B2670E; Fri, 28 Jun 2024 15:58:17 +0100 (BST) From: Mark Harmstone To: CC: Omar Sandoval , Mark Harmstone Subject: [PATCH 1/3] btrfs-progs: use libbtrfsutil for btrfs subvolume create Date: Fri, 28 Jun 2024 15:56:47 +0100 Message-ID: <20240628145807.1800474-2-maharmstone@fb.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628145807.1800474-1-maharmstone@fb.com> References: <20240628145807.1800474-1-maharmstone@fb.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: C7MKq1cQ4jj8Ent8vPdSEjGWd12B3KLI X-Proofpoint-ORIG-GUID: C7MKq1cQ4jj8Ent8vPdSEjGWd12B3KLI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-28_10,2024-06-28_01,2024-05-17_01 From: Omar Sandoval Call btrfs_util_create_subvolume in create_one_subvolume rather than calling the ioctl directly. Signed-off-by: Mark Harmstone Co-authored-by: Mark Harmstone --- cmds/subvolume.c | 133 +++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 80 deletions(-) diff --git a/cmds/subvolume.c b/cmds/subvolume.c index b4151af2..8fa0d407 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -46,6 +46,7 @@ #include "common/units.h" #include "common/format-output.h" #include "common/tree-search.h" +#include "common/parse-utils.h" #include "cmds/commands.h" #include "cmds/qgroup.h" @@ -140,63 +141,27 @@ static const char * const cmd_subvolume_create_usage[] = { NULL }; -static int create_one_subvolume(const char *dst, struct btrfs_qgroup_inherit *inherit, +static int create_one_subvolume(const char *dst, struct btrfs_util_qgroup_inherit *inherit, bool create_parents) { int ret; - int len; - int fddst = -1; - char *dupname = NULL; - char *dupdir = NULL; - const char *newname; - char *dstdir; - - ret = path_is_dir(dst); - if (ret < 0 && ret != -ENOENT) { - errno = -ret; - error("cannot access %s: %m", dst); - goto out; - } - if (ret >= 0) { - error("target path already exists: %s", dst); - ret = -EEXIST; - goto out; - } - - dupname = strdup(dst); - if (!dupname) { - error_msg(ERROR_MSG_MEMORY, "duplicating %s", dst); - ret = -ENOMEM; - goto out; - } - newname = path_basename(dupname); - - dupdir = strdup(dst); - if (!dupdir) { - error_msg(ERROR_MSG_MEMORY, "duplicating %s", dst); - ret = -ENOMEM; - goto out; - } - dstdir = path_dirname(dupdir); - - if (!test_issubvolname(newname)) { - error("invalid subvolume name: %s", newname); - ret = -EINVAL; - goto out; - } - - len = strlen(newname); - if (len > BTRFS_VOL_NAME_MAX) { - error("subvolume name too long: %s", newname); - ret = -EINVAL; - goto out; - } + enum btrfs_util_error err; if (create_parents) { char p[PATH_MAX] = { 0 }; char dstdir_dup[PATH_MAX]; + char *dupdir = NULL; + char *dstdir; char *token; + dupdir = strdup(dst); + if (!dupdir) { + error_msg(ERROR_MSG_MEMORY, "duplicating %s", dst); + free(dupdir); + return -ENOMEM; + } + dstdir = path_dirname(dupdir); + strncpy_null(dstdir_dup, dstdir, sizeof(dstdir_dup)); if (dstdir_dup[0] == '/') strcat(p, "/"); @@ -209,61 +174,68 @@ static int create_one_subvolume(const char *dst, struct btrfs_qgroup_inherit *in ret = mkdir(p, 0777); if (ret < 0) { error("failed to create directory %s: %m", p); - goto out; + free(dupdir); + return ret; } } else if (ret <= 0) { if (ret == 0) ret = -EEXIST; errno = ret ; error("failed to check directory %s before creation: %m", p); - goto out; + free(dupdir); + return ret; } strcat(p, "/"); token = strtok(NULL, "/"); } - } - fddst = btrfs_open_dir(dstdir); - if (fddst < 0) { - ret = fddst; - goto out; + free(dupdir); } - if (inherit) { - struct btrfs_ioctl_vol_args_v2 args; + pr_verbose(LOG_DEFAULT, "Create subvolume '%s'\n", dst); - memset(&args, 0, sizeof(args)); - strncpy_null(args.name, newname, sizeof(args.name)); - args.flags |= BTRFS_SUBVOL_QGROUP_INHERIT; - args.size = btrfs_qgroup_inherit_size(inherit); - args.qgroup_inherit = inherit; + err = btrfs_util_create_subvolume(dst, 0, NULL, inherit); + if (err) { + error_btrfs_util(err); + return 1; + } - ret = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE_V2, &args); - } else { - struct btrfs_ioctl_vol_args args; + return 0; +} + +static int qgroup_inherit_add_group(struct btrfs_util_qgroup_inherit **inherit, + const char *arg) +{ + enum btrfs_util_error err; + u64 qgroupid; - memset(&args, 0, sizeof(args)); - strncpy_null(args.name, newname, sizeof(args.name)); - ret = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args); + if (!*inherit) { + err = btrfs_util_create_qgroup_inherit(0, inherit); + if (err) { + error_btrfs_util(err); + return -1; + } } - if (ret < 0) { - error("cannot create subvolume: %m"); - goto out; + qgroupid = parse_qgroupid_or_path(optarg); + if (qgroupid == 0) { + error("invalid qgroup specification, qgroupid must not be 0"); + return -1; } - pr_verbose(LOG_DEFAULT, "Create subvolume '%s/%s'\n", dstdir, newname); -out: - close(fddst); - free(dupname); - free(dupdir); + err = btrfs_util_qgroup_inherit_add_group(inherit, qgroupid); + if (err) { + error_btrfs_util(err); + return -1; + } - return ret; + return 0; } + static int cmd_subvolume_create(const struct cmd_struct *cmd, int argc, char **argv) { int retval, ret; - struct btrfs_qgroup_inherit *inherit = NULL; + struct btrfs_util_qgroup_inherit *inherit = NULL; bool has_error = false; bool create_parents = false; @@ -281,7 +253,7 @@ static int cmd_subvolume_create(const struct cmd_struct *cmd, int argc, char **a switch (c) { case 'i': - ret = btrfs_qgroup_inherit_add_group(&inherit, optarg); + ret = qgroup_inherit_add_group(&inherit, optarg); if (ret) { retval = ret; goto out; @@ -310,7 +282,8 @@ static int cmd_subvolume_create(const struct cmd_struct *cmd, int argc, char **a if (!has_error) retval = 0; out: - free(inherit); + if (inherit) + btrfs_util_destroy_qgroup_inherit(inherit); return retval; } From patchwork Fri Jun 28 14:56:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 13716305 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 344CA1C230B for ; Fri, 28 Jun 2024 14:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586709; cv=none; b=UzimLiWd2nhUA0/j56lFZAi1xvPVzmXdsophH0IO8WQGhAIVFtHdeOVEvLEiWXIXWj0aHShAna+aaEljjSI75gwvMhjtYAJIOkHkDh/G7WS1FS1B9zjns57mAV6rAf2JRZpU/sNa0SgmHPkYc9As9f8/ad7PsEB44RS36MQcdkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586709; c=relaxed/simple; bh=wdQuDgu+iO+37x2Jo53YT21oS0H+jAQCGV5WCPe1Csc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mc77EcvzN6wf0rL233ZlJUTF58VglLtYUuZJsyV1HgUsO9gvjZmbl9l6SELZAZtMFNQY8URhKu75+HPyVzXmZlnKvxXz69GiVY1si+kp6E+gqLDXOd0Md7ot3oB5uFlbh93iLz87akD06oBmpmuCgyJTWaebAMQQIPQzFlft0aQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b=rlltqUmW; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="rlltqUmW" Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45SA2O65016820 for ; Fri, 28 Jun 2024 07:58:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= facebook; bh=VmmW1bvPtWkXMhCe7v38iPKdKVdMmf01FrXriwWS5eo=; b=rll tqUmWvHKEo/CSoYR/M+8g+VM1kXokfjvl6OQONE2uQYn2M7yP/9w17NiJq85A1gu jbBmzkEgnOblDDuf5Aij77iIaWXI5SWaqC6ta0IXTBOMnL/emDdA/MAFT1M6KRjt ociUQtkHDSf+SXH01bMTn6svEAjBmWEe25+/mUPI= Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 401j2g3qwq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 28 Jun 2024 07:58:25 -0700 (PDT) Received: from twshared48820.07.ash9.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Fri, 28 Jun 2024 14:58:22 +0000 Received: by devbig276.nha1.facebook.com (Postfix, from userid 660015) id 9C7273B26711; Fri, 28 Jun 2024 15:58:18 +0100 (BST) From: Mark Harmstone To: CC: Omar Sandoval , Mark Harmstone Subject: [PATCH 2/3] btrfs-progs: use libbtrfsutil for btrfs subvolume snapshot Date: Fri, 28 Jun 2024 15:56:48 +0100 Message-ID: <20240628145807.1800474-3-maharmstone@fb.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628145807.1800474-1-maharmstone@fb.com> References: <20240628145807.1800474-1-maharmstone@fb.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: snsx-V09gjN4vaSbIRo4J0lJ0jtBrnIF X-Proofpoint-GUID: snsx-V09gjN4vaSbIRo4J0lJ0jtBrnIF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-28_10,2024-06-28_01,2024-05-17_01 From: Omar Sandoval Call btrfs_util_create_snapshot in cmd_subvolume_snapshot rather than calling the ioctl directly. Signed-off-by: Mark Harmstone Co-authored-by: Mark Harmstone --- cmds/subvolume.c | 94 +++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 8fa0d407..c668ae91 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -622,18 +622,11 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char * { char *subvol, *dst; int res, retval; - int fd = -1, fddst = -1; - int len; - bool readonly = false; - char *dupname = NULL; - char *dupdir = NULL; - const char *newname; - char *dstdir; + char *dstdir = NULL; enum btrfs_util_error err; - struct btrfs_ioctl_vol_args_v2 args; - struct btrfs_qgroup_inherit *inherit = NULL; + struct btrfs_util_qgroup_inherit *inherit = NULL; + int flags = 0; - memset(&args, 0, sizeof(args)); optind = 0; while (1) { int c = getopt(argc, argv, "i:r"); @@ -642,14 +635,14 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char * switch (c) { case 'i': - res = btrfs_qgroup_inherit_add_group(&inherit, optarg); + res = qgroup_inherit_add_group(&inherit, optarg); if (res) { retval = res; goto out; } break; case 'r': - readonly = true; + flags |= BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY; break; default: usage_unknown_option(cmd, argv); @@ -683,72 +676,51 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char * } if (res > 0) { + char *dupname; + const char *newname; + dupname = strdup(subvol); newname = path_basename(dupname); - dstdir = dst; - } else { - dupname = strdup(dst); - newname = path_basename(dupname); - dupdir = strdup(dst); - dstdir = path_dirname(dupdir); - } - - if (!test_issubvolname(newname)) { - error("invalid snapshot name '%s'", newname); - goto out; - } - - len = strlen(newname); - if (len > BTRFS_VOL_NAME_MAX) { - error("snapshot name too long '%s'", newname); - goto out; - } - fddst = btrfs_open_dir(dstdir); - if (fddst < 0) - goto out; - - fd = btrfs_open_dir(subvol); - if (fd < 0) - goto out; + dstdir = malloc(strlen(dst) + 1 + strlen(newname) + 1); + if (!dstdir) { + error("out of memory"); + free(dupname); + goto out; + } - if (readonly) - args.flags |= BTRFS_SUBVOL_RDONLY; + dstdir[0] = 0; + strcpy(dstdir, dst); + strcat(dstdir, "/"); + strcat(dstdir, newname); - args.fd = fd; - if (inherit) { - args.flags |= BTRFS_SUBVOL_QGROUP_INHERIT; - args.size = btrfs_qgroup_inherit_size(inherit); - args.qgroup_inherit = inherit; + free(dupname); + } else { + dstdir = strdup(dst); } - strncpy_null(args.name, newname, sizeof(args.name)); - res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE_V2, &args); - if (res < 0) { - if (errno == ETXTBSY) - error("cannot snapshot '%s': source subvolume contains an active swapfile (%m)", subvol); - else - error("cannot snapshot '%s': %m", subvol); + err = btrfs_util_create_snapshot(subvol, dstdir, flags, NULL, inherit); + if (err) { + error_btrfs_util(err); goto out; } retval = 0; /* success */ - if (readonly) + if (flags & BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY) pr_verbose(LOG_DEFAULT, - "Create readonly snapshot of '%s' in '%s/%s'\n", - subvol, dstdir, newname); + "Create readonly snapshot of '%s' in '%s'\n", + subvol, dstdir); else pr_verbose(LOG_DEFAULT, - "Create snapshot of '%s' in '%s/%s'\n", - subvol, dstdir, newname); + "Create snapshot of '%s' in '%s'\n", + subvol, dstdir); out: - close(fddst); - close(fd); - free(inherit); - free(dupname); - free(dupdir); + free(dstdir); + + if (inherit) + btrfs_util_destroy_qgroup_inherit(inherit); return retval; } From patchwork Fri Jun 28 14:56:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 13716308 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16AF71C68B9 for ; Fri, 28 Jun 2024 14:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586714; cv=none; b=tQSWIERyr6MQy74R1ODtnK6KyRGEgtlq7ovsZYwNkj2mZxyUlwzMC6CsLvqbMQ659Z5WRHxuuRvD833fJNDhKDobMAEq+kGURI5zS+8SrCawHf+KuodxJU+Lv6Q3uOaYHWnWGGheGrxEaxuMMO6H/xwjinDAggtJ7/oS/087/lU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719586714; c=relaxed/simple; bh=NtEtPWvsxmVWyy4w3fVOenXiJbhO7hZraXQ4Ez9RWlA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KacylrBJteKItqEpwBJ5JPJmEajtXKXKmJaSq3TygdgM5pT2PbCOa4E55/GLRKfbpLLxiRbygaXpas2A9gGNsRkzcrLfkOt2GS6owbKWHvavlVoriR5hpiMmBAY+5Ueq0zxcgxj6PxA9lxJHX9dtaolN8EPSxvc154RMdlkuHSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b=HrTU1wE4; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fb.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="HrTU1wE4" Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 45SA2jTH018809 for ; Fri, 28 Jun 2024 07:58:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= facebook; bh=fq2RARGJLAIaGPU2hIBTWMU+BqSjCIkayOAfbVai4SA=; b=HrT U1wE4f7s/XadDVuOdorRcjI72qcE0qN9dvYk1VUaqaOkKhiRLnKKy4MD9rOHZ7EN /bm0IWwjR9+Ccn33iwhc0dFvt9kPMR31fLhkCw4ZIWyY+4sWGhpcj1XPzgTJUnVM txRMQdH2ByIhBkZmxZCqWQdU/STqzbh6zhYgNaYg= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 4016w2rn2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 28 Jun 2024 07:58:31 -0700 (PDT) Received: from twshared53332.38.frc1.facebook.com (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Fri, 28 Jun 2024 14:58:31 +0000 Received: by devbig276.nha1.facebook.com (Postfix, from userid 660015) id DAFF93B2671D; Fri, 28 Jun 2024 15:58:19 +0100 (BST) From: Mark Harmstone To: CC: Omar Sandoval , Mark Harmstone Subject: [PATCH 3/3] btrfs-progs: remove unused qgroup functions Date: Fri, 28 Jun 2024 15:56:49 +0100 Message-ID: <20240628145807.1800474-4-maharmstone@fb.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628145807.1800474-1-maharmstone@fb.com> References: <20240628145807.1800474-1-maharmstone@fb.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: ySIBXkJTz9SbX8IYp8gbTVyhy1mUH1sg X-Proofpoint-GUID: ySIBXkJTz9SbX8IYp8gbTVyhy1mUH1sg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-28_10,2024-06-28_01,2024-05-17_01 From: Omar Sandoval Remove functions that after the previous two patches are no longer referenced. Signed-off-by: Mark Harmstone Co-authored-by: Mark Harmstone --- cmds/qgroup.c | 64 --------------------------------------------------- cmds/qgroup.h | 2 -- 2 files changed, 66 deletions(-) diff --git a/cmds/qgroup.c b/cmds/qgroup.c index bffe942b..35b8c7b8 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -1688,70 +1688,6 @@ out: return ret; } -int btrfs_qgroup_inherit_size(struct btrfs_qgroup_inherit *p) -{ - return sizeof(*p) + sizeof(p->qgroups[0]) * - (p->num_qgroups + 2 * p->num_ref_copies + - 2 * p->num_excl_copies); -} - -static int qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit, int n, - int pos) -{ - struct btrfs_qgroup_inherit *out; - int nitems = 0; - - if (*inherit) { - nitems = (*inherit)->num_qgroups + - (*inherit)->num_ref_copies + - (*inherit)->num_excl_copies; - } - - out = calloc(1, sizeof(*out) + sizeof(out->qgroups[0]) * (nitems + n)); - if (out == NULL) { - error_msg(ERROR_MSG_MEMORY, NULL); - return -ENOMEM; - } - - if (*inherit) { - struct btrfs_qgroup_inherit *i = *inherit; - int s = sizeof(out->qgroups[0]); - - out->num_qgroups = i->num_qgroups; - out->num_ref_copies = i->num_ref_copies; - out->num_excl_copies = i->num_excl_copies; - memcpy(out->qgroups, i->qgroups, pos * s); - memcpy(out->qgroups + pos + n, i->qgroups + pos, - (nitems - pos) * s); - } - free(*inherit); - *inherit = out; - - return 0; -} - -int btrfs_qgroup_inherit_add_group(struct btrfs_qgroup_inherit **inherit, char *arg) -{ - int ret; - u64 qgroupid = parse_qgroupid_or_path(arg); - int pos = 0; - - if (qgroupid == 0) { - error("invalid qgroup specification, qgroupid must not 0"); - return -EINVAL; - } - - if (*inherit) - pos = (*inherit)->num_qgroups; - ret = qgroup_inherit_realloc(inherit, 1, pos); - if (ret) - return ret; - - (*inherit)->qgroups[(*inherit)->num_qgroups++] = qgroupid; - - return 0; -} - static const char * const qgroup_cmd_group_usage[] = { "btrfs qgroup [options] ", NULL diff --git a/cmds/qgroup.h b/cmds/qgroup.h index 1fc10722..32309ce4 100644 --- a/cmds/qgroup.h +++ b/cmds/qgroup.h @@ -36,8 +36,6 @@ struct btrfs_qgroup_stats { struct btrfs_qgroup_limit limit; }; -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_query(int fd, u64 qgroupid, struct btrfs_qgroup_stats *stats); #endif