From patchwork Sat May 20 08:38:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sargun Dhillon X-Patchwork-Id: 9738521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E4386034C for ; Sat, 20 May 2017 08:39:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83152285C8 for ; Sat, 20 May 2017 08:39:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77042285D4; Sat, 20 May 2017 08:39:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA961285C8 for ; Sat, 20 May 2017 08:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755618AbdETIjA (ORCPT ); Sat, 20 May 2017 04:39:00 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:36854 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755602AbdETIiz (ORCPT ); Sat, 20 May 2017 04:38:55 -0400 Received: by mail-it0-f48.google.com with SMTP id o5so130128321ith.1 for ; Sat, 20 May 2017 01:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=wK9nEeQbWlT86t4y2z0ry/9qwKSlFydWgB0ma6oFVO8=; b=mAlKnrgqxWjfUAAo2rb6e+snvDUOsdnmIqo6c6a7CWz9jXXN81THtCLFaCFqFJ31pR F5PfjbsvbhQaM0/YaJhfaZkusfr/7KKBJfuy+HSDNBFRD+u+LXPXNJh3PGprsS9xZkKU aBE9JEV5kiD16toYJoA4tJcH5GFKHeQx7Tx9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=wK9nEeQbWlT86t4y2z0ry/9qwKSlFydWgB0ma6oFVO8=; b=oeF8zKQ8vbxMvN3CP1y3DuuzBfBQ5pg97l6cTyocpbD3m7Yw9QW5bfmgky8u2T7Ksn InJwufW43JCzeGkwO1BwNFcfHF7qqtzP/DlbcxESYgOJEYjpfH1hDh9OjVm/ZLwPQGbA gYLM+V5jxAWnFvP76kNuMvz8cmIySjS/8wiOOUVDRvHJlHdyXx27KQw6ndhGuYg+/Qel t2d58zJrwXDmLqP9v/BOd9BvVGxb2dCzF6hbqw6eYb/lLH+32T2bximDAyDmbAMlVOMO YNzFzm8kHNqn6tS2iTHWqF7Ow8Dw93N1iF7C6OE5gm5xyx7+PRI68+YLqO77cBH/rpW+ M8BQ== X-Gm-Message-State: AODbwcDQYBT5WcJ0yjClKufu8SGlvj8zDzDcWLjNyQS/5TyjLVGuxYou 8S3Jy6iEL6ABBeWTaraTBw== X-Received: by 10.36.190.133 with SMTP id i127mr32053040itf.41.1495269534753; Sat, 20 May 2017 01:38:54 -0700 (PDT) Received: from ircssh-2.c.rugged-nimbus-611.internal (80.60.198.104.bc.googleusercontent.com. [104.198.60.80]) by smtp.gmail.com with ESMTPSA id y7sm11684495itc.27.2017.05.20.01.38.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 May 2017 01:38:54 -0700 (PDT) Date: Sat, 20 May 2017 08:38:53 +0000 From: Sargun Dhillon To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/8] btrfs: Split up btrfs_remove_qgroup, no logic changes Message-ID: <20170520083851.GA4195@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change is purely a style change, so that btrfs_remove_qgroup is split. There is some whitespace changes, but this shouldn't have any effect on the logic of the code. Signed-off-by: Sargun Dhillon --- fs/btrfs/qgroup.c | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index deffbeb..a2add44 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1281,40 +1281,35 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, return ret; } -int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, - struct btrfs_fs_info *fs_info, u64 qgroupid) +/* Must be called with qgroup_ioctl_lock held */ +static int __btrfs_remove_qgroup(struct btrfs_trans_handle *trans, + struct btrfs_fs_info *fs_info, u64 qgroupid) { + struct btrfs_qgroup_list *list; struct btrfs_root *quota_root; struct btrfs_qgroup *qgroup; - struct btrfs_qgroup_list *list; - int ret = 0; + int ret; - mutex_lock(&fs_info->qgroup_ioctl_lock); quota_root = fs_info->quota_root; - if (!quota_root) { - ret = -EINVAL; - goto out; - } + if (!quota_root) + return -EINVAL; qgroup = find_qgroup_rb(fs_info, qgroupid); - if (!qgroup) { - ret = -ENOENT; - goto out; - } else { - /* check if there are no children of this qgroup */ - if (!list_empty(&qgroup->members)) { - ret = -EBUSY; - goto out; - } - } + if (!qgroup) + return -ENOENT; + + /* check if there are no children of this qgroup */ + if (!list_empty(&qgroup->members)) + return -EBUSY; + ret = del_qgroup_item(trans, quota_root, qgroupid); while (!list_empty(&qgroup->groups)) { list = list_first_entry(&qgroup->groups, struct btrfs_qgroup_list, next_group); ret = __del_qgroup_relation(trans, fs_info, - qgroupid, - list->group->qgroupid); + qgroupid, + list->group->qgroupid); if (ret) goto out; } @@ -1322,8 +1317,20 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, spin_lock(&fs_info->qgroup_lock); del_qgroup_rb(fs_info, qgroupid); spin_unlock(&fs_info->qgroup_lock); + out: + return ret; +} + +int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, + struct btrfs_fs_info *fs_info, u64 qgroupid) +{ + int ret; + + mutex_lock(&fs_info->qgroup_ioctl_lock); + ret = __btrfs_remove_qgroup(trans, fs_info, qgroupid); mutex_unlock(&fs_info->qgroup_ioctl_lock); + return ret; }