From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33B213C6615 for ; Tue, 17 Mar 2026 12:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752227; cv=none; b=XeSAxb41E67KaFNa+JYOhyKU1d2Yl5EkBs6qXEnZTaqBd6hiwy/4WLAxANlRmEBWgXgUjsGr0bwxlda+f2e3LC1IN4jrz4dPQQ6hU1N7YLfXakyAU7f65AsiLP1hAZVcaA1JPcI0T93S5UMxNLt8hS13NUaEWYqBvdXTMSJx8SM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752227; c=relaxed/simple; bh=jkv3wrwHqYCxtnF74/RXnypRZ5qDBDJkD6w54HZqFDo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=T3se2Gn4OxxTvWj3VB/fQFtuOAxwcirU6SwOXDocQgSqlfe9thOs9eqN15qriTEuK8SY/aHkq5NvahDk9z8Qt4lG/RMMWBFFgrS0RGusEVhp68BkBnQ5d6iNKb02sFrIsAqXTO1yo1xj2rV9llEWA0L71swa2frDR2uEFsi2urc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AcMp93Rx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AcMp93Rx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C2CAC4CEF7; Tue, 17 Mar 2026 12:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773752226; bh=jkv3wrwHqYCxtnF74/RXnypRZ5qDBDJkD6w54HZqFDo=; h=Subject:To:Cc:From:Date:From; b=AcMp93Rxpq+OugTIM53GZ7XFk+fQoTnULlD1WkSwoOgh/PJKQL/bnAOygLkOCCjFG DZK/sop1fx2HIaOMjkFkmt6iI4b7oXy14fs1kDphanJc4TJnRtic7XAbuRmL1hqn2x Jfipl9fiR3i3d3iggcR6zt/Gmlc2TePBqfZwyGGk= Subject: FAILED: patch "[PATCH] xfs: ensure dquot item is deleted from AIL only after log" failed to apply to 5.10-stable tree To: leo.lilong@huawei.com,cem@kernel.org,cmaiolino@redhat.com,hch@lst.de Cc: From: Date: Tue, 17 Mar 2026 13:56:51 +0100 Message-ID: <2026031751-drastic-afraid-2b79@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 186ac39b8a7d3ec7ce9c5dd45e5c2730177f375c # git commit -s git send-email --to '' --in-reply-to '2026031751-drastic-afraid-2b79@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 186ac39b8a7d3ec7ce9c5dd45e5c2730177f375c Mon Sep 17 00:00:00 2001 From: Long Li Date: Thu, 5 Mar 2026 16:49:22 +0800 Subject: [PATCH] xfs: ensure dquot item is deleted from AIL only after log shutdown In xfs_qm_dqflush(), when a dquot flush fails due to corruption (the out_abort error path), the original code removed the dquot log item from the AIL before calling xfs_force_shutdown(). This ordering introduces a subtle race condition that can lead to data loss after a crash. The AIL tracks the oldest dirty metadata in the journal. The position of the tail item in the AIL determines the log tail LSN, which is the oldest LSN that must be preserved for crash recovery. When an item is removed from the AIL, the log tail can advance past the LSN of that item. The race window is as follows: if the dquot item happens to be at the tail of the log, removing it from the AIL allows the log tail to advance. If a concurrent log write is sampling the tail LSN at the same time and subsequently writes a complete checkpoint (i.e., one containing a commit record) to disk before the shutdown takes effect, the journal will no longer protect the dquot's last modification. On the next mount, log recovery will not replay the dquot changes, even though they were never written back to disk, resulting in silent data loss. Fix this by calling xfs_force_shutdown() before xfs_trans_ail_delete() in the out_abort path. Once the log is shut down, no new log writes can complete with an updated tail LSN, making it safe to remove the dquot item from the AIL. Cc: stable@vger.kernel.org Fixes: b707fffda6a3 ("xfs: abort consistently on dquot flush failure") Signed-off-by: Long Li Reviewed-by: Carlos Maiolino Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 2b208e2c5264..69e9bc588c8b 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1439,9 +1439,15 @@ xfs_qm_dqflush( return 0; out_abort: + /* + * Shut down the log before removing the dquot item from the AIL. + * Otherwise, the log tail may advance past this item's LSN while + * log writes are still in progress, making these unflushed changes + * unrecoverable on the next mount. + */ + xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); dqp->q_flags &= ~XFS_DQFLAG_DIRTY; xfs_trans_ail_delete(lip, 0); - xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); xfs_dqfunlock(dqp); return error; }