From patchwork Wed Jun 3 06:57:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6532661 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D1BA9F326 for ; Wed, 3 Jun 2015 07:02:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8ED2B20697 for ; Wed, 3 Jun 2015 07:02:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83072206B8 for ; Wed, 3 Jun 2015 07:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751739AbbFCHC2 (ORCPT ); Wed, 3 Jun 2015 03:02:28 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:8271 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751945AbbFCHC1 (ORCPT ); Wed, 3 Jun 2015 03:02:27 -0400 X-IronPort-AV: E=Sophos;i="5.01,1,1399996800"; d="scan'208";a="96344677" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Jun 2015 15:06:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t5370r6v010789 for ; Wed, 3 Jun 2015 15:00:53 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 3 Jun 2015 15:02:26 +0800 From: Dongsheng Yang To: CC: Dongsheng Yang Subject: [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup. Date: Wed, 3 Jun 2015 14:57:33 +0800 Message-ID: <1433314653-548-3-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1433314653-548-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1433314653-548-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we can not clear a limitation on a qgroup. Although there is a 'none' choice provided to user to do it, it does not work well. It does not set the flag which user want to clear, then kernel will never know what the user want to do at all. *Without this commit* # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none # ./btrfs qgroup limit none /mnt # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none This patch will set the flag user want to clear and pass a size=-1 to kernel. Then kernel will clear it correctly. *With this commit* # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none # ./btrfs qgroup limit none /mnt # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB none none 0/257 100.02MiB 100.02MiB none none Reported-by: Tsutomu Itoh Signed-off-by: Dongsheng Yang Tested-by: Tsutomu Itoh --- cmds-qgroup.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index b073250..00cc089 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long *s) { char *endptr; unsigned long long size; + unsigned long long CLEAR_VALUE = -1; if (strcasecmp(p, "none") == 0) { - *s = 0; + *s = CLEAR_VALUE; return 1; } size = strtoull(p, &endptr, 10); @@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv) } memset(&args, 0, sizeof(args)); - if (size) { - if (compressed) - args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR | - BTRFS_QGROUP_LIMIT_EXCL_CMPR; - if (exclusive) { - args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL; - args.lim.max_exclusive = size; - } else { - args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER; - args.lim.max_referenced = size; - } + if (compressed) + args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR | + BTRFS_QGROUP_LIMIT_EXCL_CMPR; + if (exclusive) { + args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL; + args.lim.max_exclusive = size; + } else { + args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER; + args.lim.max_referenced = size; } if (argc - optind == 2) {