From patchwork Wed Sep 13 00:13:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 13382337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB447EE3F39 for ; Wed, 13 Sep 2023 00:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237279AbjIMAND (ORCPT ); Tue, 12 Sep 2023 20:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236262AbjIMANC (ORCPT ); Tue, 12 Sep 2023 20:13:02 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30C011706 for ; Tue, 12 Sep 2023 17:12:59 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 78223320093C; Tue, 12 Sep 2023 20:12:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 12 Sep 2023 20:12:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1694563977; x= 1694650377; bh=6IvEpnpGHmhKZx01M9taeNawAipMUx6oDLlNde+G5is=; b=u HdX+eO05vzCMEW6d5BfskL6e75aVuYxVLhW1v1A6qGALeUQf5H97aQgrlr7NrUBL tgrDJ/nck5j+UB9e8bhHs40kxAtTecWWDf43gTfdbFcnthyyBNPKyDgUAAJ64Kz5 4Ohl3ZCfPe7DvnEqgmGr5scn09rMVI/qK95UVcqfyDbVX24LmZ6kRp9Cuhj+uPy4 7nJEGI3FD8AF6ODSpyuh2/CGmVTwMFO5BqDtpDq5KPzzyg7gQQ5/DveTs7VTQIdv J/MPFCbgnLos/W0VrvWkfcDzWrus52nb4bPjP2l+kh4tVz7eBwdYqNj/L3poW4wW zXw6zrDZ9qmnPfUt5DEVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1694563977; x=1694650377; bh=6 IvEpnpGHmhKZx01M9taeNawAipMUx6oDLlNde+G5is=; b=Ld+y92jl+aJY3vr+M gXX9tEtvxI6GgMhBHsv/Ms2wY6XZZHnGBgQbnx434vxv1sFo9WIGhYUZqePPSecP aA33FUAWo5R/d4bsHneMdqqiO1T+q7NgZ92WOaKvxWdcIHQwQwktybM3+8/7lFQ6 jYMfsCk5WoLF5pdnJR0svjadVKli6NffftYA1faBOek9rYVQ+4zz9i2VXCT+6C9e 9WyzPV62+I9+OsXRU99tn+QleUs2N3wUsPUCG8lsTVscIZQO9p2PIIbzxbu/zD8B b4DzxVG33i1xo6L3gzveoOQqFV0Y3n4pw3mYxtSALGWG7rVsIliHT727+TqzLmN3 yhfHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeijedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepuehorhhishcuuehurhhkohhvuceosghorhhishessghurhdr ihhoqeenucggtffrrghtthgvrhhnpeeiueffuedvieeujefhheeigfekvedujeejjeffve dvhedtudefiefhkeegueehleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegsohhrihhssegsuhhrrdhioh X-ME-Proxy: Feedback-ID: i083147f8:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Sep 2023 20:12:57 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v6 06/18] btrfs: create qgroup earlier in snapshot creation Date: Tue, 12 Sep 2023 17:13:17 -0700 Message-ID: <6355e2bf2ef93b5c998659f59e2b576ece7b7e1b.1694563454.git.boris@bur.io> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Pull creating the qgroup earlier in the snapshot. This allows simple quotas qgroups to see all the metadata writes related to the snapshot being created and to be born with the root node accounted. Signed-off-by: Boris Burkov --- fs/btrfs/qgroup.c | 3 +++ fs/btrfs/transaction.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 84030f81a1d8..ae6ccf1eb0e4 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1700,6 +1700,9 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) struct btrfs_qgroup *prealloc = NULL; int ret = 0; + if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED) + return 0; + mutex_lock(&fs_info->qgroup_ioctl_lock); if (!fs_info->quota_root) { ret = -ENOTCONN; diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 12876517c29e..eb649860ecfb 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1813,6 +1813,12 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, } btrfs_release_path(path); + ret = btrfs_create_qgroup(trans, objectid); + if (ret) { + btrfs_abort_transaction(trans, ret); + goto fail; + } + /* * pull in the delayed directory update * and the delayed inode item