From patchwork Fri Feb 22 12:02:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2175701 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0D2993FCFC for ; Fri, 22 Feb 2013 12:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756902Ab3BVMC0 (ORCPT ); Fri, 22 Feb 2013 07:02:26 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]:60096 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756367Ab3BVMC0 (ORCPT ); Fri, 22 Feb 2013 07:02:26 -0500 Received: by mail-pb0-f49.google.com with SMTP id xa12so371812pbc.36 for ; Fri, 22 Feb 2013 04:02:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=bsiqVTRaA8+RJUMWs3K2cIcpOnzx+1Aggp+guK//N3Y=; b=JW1p0GxJhkrSYtrD5Dfr74chMald8yG25f0GQ4zGGxFmmCsTF0okkNb5dR6KfnkUpj 4TrHaquvKyxbgYCy9R75nf5XKeNWhqBJPfe6pFZNIaRrUCxUaOLlTV5Kc46MhkeaRJO+ ivzpDMyRyCmWTT820cgxg61+Ajz0PLk2ddTs5JpC+LIcJrFeFMWu1Q50W67gElVDbPdF hOqhU2hvJCb2A8DtkhLpArTk+iawMu/b0MJnMhuPg32q6Rsrj4Sz2Iex96FnQcwwEiJw 2T7VVVuA5ZNp/o+OFE7S2cT+pnPGvZzBZj865zzmzQG0np1ggD0MCdju6BAvRYCX7e3K cgAg== X-Received: by 10.66.88.198 with SMTP id bi6mr3639668pab.54.1361534545566; Fri, 22 Feb 2013 04:02:25 -0800 (PST) Received: from localhost.localdomain ([223.65.185.63]) by mx.google.com with ESMTPS id td10sm2326355pbb.25.2013.02.22.04.02.23 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Feb 2013 04:02:25 -0800 (PST) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: sensille@gmx.net Subject: [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically Date: Fri, 22 Feb 2013 20:02:20 +0800 Message-Id: <1361534540-2381-1-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Wang Shilong Creating the root subvolume qgroup when enabling quota,with this patch,it will be ok to limit the whole filesystem size. Signed-off-by: Wang Shilong Reviewed-by: Miao Xie Cc: Arne Jansen --- fs/btrfs/qgroup.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index a5c8562..c409096 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -777,6 +777,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, struct extent_buffer *leaf; struct btrfs_key key; int ret = 0; + struct btrfs_qgroup *qgroup = NULL; spin_lock(&fs_info->qgroup_lock); if (fs_info->quota_root) { @@ -823,7 +824,18 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans, btrfs_mark_buffer_dirty(leaf); + btrfs_release_path(path); + ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID); + if (ret) + goto out; + spin_lock(&fs_info->qgroup_lock); + qgroup = add_qgroup_rb(fs_info, BTRFS_FS_TREE_OBJECTID); + if (IS_ERR(qgroup)) { + spin_unlock(&fs_info->qgroup_lock); + ret = PTR_ERR(qgroup); + goto out; + } fs_info->quota_root = quota_root; fs_info->pending_quota_state = 1; spin_unlock(&fs_info->qgroup_lock);