From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 BE1CE3C0623 for ; Fri, 14 Aug 2026 12:30:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786710649; cv=none; b=tq7giPvD9vqL9cezRvIzehyh/SMj4E+4t4jRexKo2Vvk8FmBpKpcRTDLjTBVH8mKeHytFhAkF3OHxfoXhausEOCPyNFtCWcEr7PXScEXJRnJbHOn2r2HO753+/oIp+wjH0JfWyJDSPBUwXjPSXWH83J+ZPG37mGetgyHUGQTXhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786710649; c=relaxed/simple; bh=U1Y2j+92d+vHnkozImzjd00wOBSLsV600VZjEpum4S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XSpb8bpkNyybU5VEqk9jphrg9FGZqO9fPHhXfe+zITWQLaTVQ1HX5cB0IJs0DU5QOOqp/NX3SQaqk7EpWy85eZ5pi5R9NBuX2bCB8wd8EoSIUBnNXuDlWwJ9iYqvbUBcjx55TiMPBMxwt9K3k1vUCfTX3rk+ZH5JC9fDn3jNnSc= 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=Lgn7jwVX; arc=none smtp.client-ip=209.85.216.48 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="Lgn7jwVX" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-38e7109321dso640860a91.3 for ; Fri, 14 Aug 2026 05:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786710647; x=1787315447; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=U1Y2j+92d+vHnkozImzjd00wOBSLsV600VZjEpum4S4=; b=Lgn7jwVXae/cHVFis1XSd4FTQucpCMDFTPi50+SxVq8c3oe/punicr77Xkc2EFPew5 VtDp83dPVRNtPqGSw/KCI2VY5gxlanBzgVApvEGcpjDs98ekCwz5QbRHia7bWcqIUXWi zdPH7khjv9jlUsxw7QvmmSBWYrT8BOtGA68+D3RYr3YL1XvTWElaVQeBEwihSnSTP43t MR/WfskI5vVFrScutqK4QiKwe+HuDqTcRHyTj5bQ4bk8Cyp5bcEzIc/70shIbqbKecec ERr7o1DDXUCX7+ve/iF8Du+X5euFkErz8PtDfAwj6VdEQvhfaqUMXzvb9dequG0607r6 q+lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786710647; x=1787315447; h=content-transfer-encoding:mime-version:references:in-reply-to :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=U1Y2j+92d+vHnkozImzjd00wOBSLsV600VZjEpum4S4=; b=WzhwXv168igXUIYJjTdn0Cke8icwvKVEvlN1/Xezg7E+bCwKYpmz2zs+P02RfAXMAJ zi5lLpBzpyewABblf7L49AP0ThTl1gwL5O719s8CqIGW1ETP/me3P7ygIJEiago+dC6Q OFwDQSk+6fnejS9qU5kJsnc1sXaThw+mD63omRDeceyWEanms5IVbSPdVJ7rwndyklf5 9Cd8C04LVnyha+hGrhcDSgz4dDsvyk4N2U08HP4ho7pCjJw13q8oz29AfxbMUKEVCrpW vDmZ+8viOpGGS2WT6tbzNSSIy7jp18yLwlfC2mEx/CPn/3NI61LZdGG842RgRS9y2FdY mPdA== X-Forwarded-Encrypted: i=1; AHgh+RoBLp9aZnHhl7tD3Bg+GQ8yKw+MYLs3eChYjNxantFcyEMWq65I5dc/goeZUwCga93idqJ9Ql6skSpCcvw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz87/p7L+3inbk0eyyg8GROYpzKNVjKvORdHrUtZjg3znLy39s5 LD88D2+salIdGZvnKzsun28cKbNXudyJYO3ElSWSNSJcwaZryYhhHgD8 X-Gm-Gg: AR+sD10MxmOHwXq07sEUO880j0gz63U+RbokYiA+XmjBYpuRZjw0Fi0fWeKdi5C1w7/ zN2Y+WdY0cn/npzRr6T4i1I0zhPv3R7LL4rIGrwinlmZO8kc1c0sXv4dfNeQ0jngrwNMVZBVFTT huqdC4Ij3GADIo1rY7vnG/HGX9p+4Nnd/++clZdYYgthdys1YU7jOlhhqhnArRaH51hNkaz41HR lPxTTB21BMm/ejabH5Xxs9jnl0HAMFTXBAUwBeocUEdenVX7RrZ1t0QHPjm8MbXz4I68KrU9vkX 4JOnMEdEx5uHU/6Vz7EADtS2rFpmd0CTM60ufoBL8OXuKgIRH6D0oOS0DhxdSjCmQwqrfNWRCJ8 ZUXwrjIS3NTu+xBn+/AAI330nhdIezqDqpsmszdzZjUHSZolHAw0oWNVGzmSRBA1ZZe7Jd04bmj VbREneptdXbzgL6UUC6XFm9JV54YitsIiIHCHwgvRGEwU3IZdXeShC2uxeQjbT4q5xsy9qO9/z3 zOPVFI63kymu1il X-Received: by 2002:a17:90b:35c6:b0:392:6638:2e6a with SMTP id 98e67ed59e1d1-3933b95d5e1mr5969840a91.13.1786710646690; Fri, 14 Aug 2026 05:30:46 -0700 (PDT) Received: from localhost.localdomain ([14.153.235.3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394eaca3e48sm2589992a91.11.2026.08.14.05.30.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 14 Aug 2026 05:30:46 -0700 (PDT) From: Guanjie Chen To: wqu@suse.com Cc: clm@fb.com, dsterba@suse.com, fdmanana@suse.com, jk.chen1095@gmail.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] btrfs: free qgroup configuration when quota enable fails Date: Fri, 14 Aug 2026 20:30:34 +0800 Message-ID: <20260814123034.19289-1-jk.chen1095@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <694e88fd-a165-4518-88d4-cb2f22e8925b@suse.com> References: <694e88fd-a165-4518-88d4-cb2f22e8925b@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Qu, > We can reach this out branch if btrfs_start_transaction() failed, but > the fs_info->quota_root is already setup by another process. Do you mean the window where qgroup_ioctl_lock is dropped before btrfs_start_transaction()? I don't think another task can set fs_info->quota_root in that window. The quota ioctl holds fs_info->subvol_sem for writing across the whole btrfs_quota_enable() call, including while qgroup_ioctl_lock is dropped. As far as I can see, quota_root is only set in two places: btrfs_quota_enable(), which is serialized by subvol_sem, and btrfs_read_roots(), which runs during mount initialization. The disable path also calls btrfs_free_qgroup_config() and relies on the same subvol_sem and qgroup_ioctl_lock serialization for the qgroup configuration. If subvol_sem did not prevent another quota operation here, the disable path would have a similar lifetime problem. So if quota_root was NULL at the first check, I believe it must still be NULL when btrfs_start_transaction() fails. I agree that the changelog should have mentioned subvol_sem as part of the protection. Did I miss another runtime path that can set quota_root without holding subvol_sem? Also, just to clarify, this is not my first btrfs contribution, although my previous change was only a small one. Thanks, Guanjie