From nobody Tue Sep 29 00:32:59 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E8C93B71A0 for ; Fri, 14 Aug 2026 11:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786706570; cv=none; b=Cd+7QpBiXggDS8dVh19sZ2aMqPjwPCkk/OjH34TI7/VHKme6dUXpIOrTSSl6Q4vIIMNhYtnLnXUt1QPJSWSfGMEXqqwphk6CnmjZwHMhhlGvDRAAI3/IMnLQE8U9x8Wmx2RrTdkUwS/Z0u6IlNYbmfbZt5jsLIUdWlUfYR7+YAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786706570; c=relaxed/simple; bh=kOdbizL2WbRrvUiqLkpBWdx/ZB5Hjf4LqdHDhv8Y8xI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Kdex1itXT8II/OKLslTnbNCIRP1/jyIfE5nC8RK/299ebGMp6zldupGzbMatQj9Uy+3Sxp0U/L/UsNlAbAdra1pGhUTxoTaa2clFHRt5TVIVQcn0q1KdmUHNpjqokCl+eGe1K+uMsQ12x8iipYempWTUCfhAL+65dZ8l3c8c8ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=icvBDZuM; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="icvBDZuM" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-38dfe910e9dso868399a91.3 for ; Fri, 14 Aug 2026 04:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786706566; x=1787311366; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=iaZDoExgTDNkepgAKTiMPW+JYa3Hj6tKGTWkAI87vXg=; b=icvBDZuMnsY7f0QL6eZHNGkpxoygcKMFjhTzUmuVRJXxkBWbjH3nEsEJy9UhpjDzLm oRB0XVrWk6if/TssoGFtW8iiDMCYrL9tXMBqSKzvYg648u6MTg/9/xwkmjxB3gfe9zYi kQlFocfw5Oa88B+NFFUAGO0Vsrosphn9APvd45tPNYbt5j8i102F9lWiwQt5lhsZu07F YesxCsc2N8dV3UoxMzX5IRSWWhtHGecZoNlCuAIlsfCtaXEAL799Hsd1RRz2HJEPlgh9 oBzpcnhDOpWtTSoFZtZ/7TgYgVnP5tF1BXEDF36Q76QPCE2wX7Fr7Z6LfNnzGmNYrZVU ziDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786706566; x=1787311366; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iaZDoExgTDNkepgAKTiMPW+JYa3Hj6tKGTWkAI87vXg=; b=lg9FWNEzdZzAXz2lxS8salwOMmfe9bxdIs9PICN49ZiZxKvxFjmr02lzh1BAQI+5Gf y1NNifEOOWCWrYasKHFDPszrDRGauzuRWQH5hs1YlVzrILuafjqdNNc8DHXGHL273wUf nTvVmw0fynBW8g5HqVwhi+/c1HRi5Qv8ZUq+EqX1DkTA8+dwhEaVoaB5DJpWkpxkTGXt eGW/5ltRK2A9806T6hMiuKcpl0seZ0ZDWh8VhK9wNO1U4AKqKPJOYP9+dno1PyjWDEUJ qTOAkWVpIbkyons9faBJG5bTLKzw644+BLjPLvtQ8njXrDEmRylReMJEsUKI2EGbC/rd 28wQ== X-Forwarded-Encrypted: i=1; AHgh+Rok3fTjSj9aHslQ/Sw5vyDY1wwkCgEs585HF/jpOXK+877D1H592l3Yhpb8paAcLIakEpeMq7S6Mkg9uOg=@vger.kernel.org X-Gm-Message-State: AOJu0YwV4wPNu42OXSPWuii/4XB6TH7hHRD3zDlGFVIxaCr+pynA/LYq t46K30R8sx5cy3+3mCUiIxTwsKirxQiL81ftH/wdFrqwQXnk476WSb8qcpPwazUm X-Gm-Gg: AR+sD13ve5zJ+KdzgrSBeG2BPvBpdu7/4dFk50CrlpMFMcCjFx+m8WTqK2oFg2bmB0/ 45nXRcrSWcXg7wbiLhOgJeU5Exs17WnBF/DTpOi9x4EKsQUtHZiL8JgulhccriXPrp1whFBXHNE 7iVRNeM2n8a8m5YxeXENGDWgQuZXBbUT2alT18lBgJowzhhginuo2byLpKLlRNF5m96LVUTfJmw pfn2fJGc62SIrEUKxSSrJWVJb20Sz9ux7+wB5yZAFWKtN+0mFyHwJBrtuzLAm//VOQJYreqAfUV 2QzJIDNKQGuzTYWHJhjnmpIZXXa6FEJ60civDS3thJe4j04WqAH0J2PMDVd5RBp5R/amSg+Ezit hCwJuurvMHs/WbNgit/Sg+gas3H9YP1nwoDxOJ19fXDe0qSOoHkuejJUf1P05ven6lAoGt4fKfi l+p4hvO3744WNh9NhPr/NgNSt3rCCD9NPwNLV96h8H+YB/mpqn0go0aTpl9NUvaKYjSzjeBlF8g BA= X-Received: by 2002:a17:90b:1f88:b0:392:c868:35af with SMTP id 98e67ed59e1d1-3933bd46d96mr5759300a91.20.1786706566416; Fri, 14 Aug 2026 04:22:46 -0700 (PDT) Received: from localhost.localdomain ([203.175.14.199]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea996575sm2300533a91.8.2026.08.14.04.22.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 14 Aug 2026 04:22:46 -0700 (PDT) From: Guanjie Chen To: linux-btrfs@vger.kernel.org Cc: clm@fb.com, dsterba@suse.com, fdmanana@suse.com, linux-kernel@vger.kernel.org, Guanjie Chen Subject: [PATCH] btrfs: free qgroup configuration when quota enable fails Date: Fri, 14 Aug 2026 19:22:40 +0800 Message-ID: <20260814112240.93514-1-jk.chen1095@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Quota enable adds qgroups to fs_info->qgroup_tree before the operation is guaranteed to succeed. On failure, the current error path removes only the sysfs entries, leaving the qgroups and their relations in memory. Use btrfs_free_qgroup_config() instead. It is the existing qgroup teardown helper and removes the in-memory qgroups, their relations and the sysfs entries. This is safe because the failure cleanup runs with qgroup_ioctl_lock held and before quota_root is published or quota accounting is enabled. Qgroups already added to the tree are freed by btrfs_free_qgroup_config(), while an untransferred preallocation and quota_root are still released by the existing cleanup code. Transaction handling is unchanged. Signed-off-by: Guanjie Chen --- fs/btrfs/qgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1292,7 +1292,7 @@ out_free_root: btrfs_put_root(quota_root); out: if (ret) - btrfs_sysfs_del_qgroups(fs_info); + btrfs_free_qgroup_config(fs_info); mutex_unlock(&fs_info->qgroup_ioctl_lock); if (ret && trans) btrfs_end_transaction(trans); --=20 2.43.0