Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] btrfs: reject refs=0 subvolume without DEAD in" failed to apply to 6.18-stable tree
@ 2026-11-24 15:43 gregkh
  2026-11-24 22:45 ` [PATCH 6.18.y 1/3] btrfs: check type flags in alloc_ordered_extent() Sasha Levin
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-11-24 15:43 UTC (permalink / raw)
  To: teel4res, dsterba, quwenruo.btrfs, wqu; +Cc: stable


The patch below does not apply to the 6.18-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 <stable@vger.kernel.org>.

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-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 9a58e56e70f610e29b53821e9c706600e529cca3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112428-spearmint-famished-4675@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9a58e56e70f610e29b53821e9c706600e529cca3 Mon Sep 17 00:00:00 2001
From: Cheng Yongkang <teel4res@gmail.com>
Date: Sat, 31 Oct 2026 23:25:39 -0700
Subject: [PATCH] btrfs: reject refs=0 subvolume without DEAD in
 SUBVOL_SYNC_WAIT

btrfs_ioctl_subvol_sync() assumes that a cached root with zero
references has BTRFS_ROOT_SUBVOL_DEAD set, and asserts that before
waiting for the cleaner. Two states break the assumption:

- A corrupt ROOT_ITEM with zero references and a matching orphan item,
  on a writable filesystem.
- A failed subvolume deletion. btrfs_delete_subvolume() zeroes the
  root references, aborts the transaction, which forces the filesystem
  read-only, and then clears DEAD again. No on-disk metadata is
  corrupted in this case.

With CONFIG_BTRFS_ASSERT=y, both reach a BUG().

Change the ASSERT() into a proper rejection to avoid triggering a BUG().

Fixes: 6c83d153ed86 ("btrfs: add new ioctl to wait for cleaned subvolumes")
CC: stable@vger.kernel.org
Suggested-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Link: https://lore.kernel.org/linux-btrfs/dd97efe9-91ec-495b-b698-acff1447421c@gmx.com/
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
[ Rework the commit message, drop the ad-hoc RW check. ]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 847fdc19bd40..000276bb49ad 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -5161,8 +5161,12 @@ static int btrfs_ioctl_subvol_sync(struct btrfs_fs_info *fs_info, void __user *a
 			return -ENOENT;
 
 		wait_for_deletion = true;
-		ASSERT(root_flags & BTRFS_ROOT_SUBVOL_DEAD, "root_flags=0x%llx",
-		       root_flags);
+		if (unlikely(!(root_flags & BTRFS_ROOT_SUBVOL_DEAD))) {
+			btrfs_err(fs_info,
+				  "subvol %llu has refs 0 without DEAD flag",
+				  args.subvolid);
+			return -EUCLEAN;
+		}
 		sched_ret = schedule_timeout_interruptible(HZ);
 		/* Early wake up or error. */
 		if (sched_ret != 0)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-24 22:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 15:43 FAILED: patch "[PATCH] btrfs: reject refs=0 subvolume without DEAD in" failed to apply to 6.18-stable tree gregkh
2026-11-24 22:45 ` [PATCH 6.18.y 1/3] btrfs: check type flags in alloc_ordered_extent() Sasha Levin
2026-11-24 22:45   ` [PATCH 6.18.y 2/3] btrfs: make more ASSERTs verbose, part 3 Sasha Levin
2026-11-24 22:45   ` [PATCH 6.18.y 3/3] btrfs: reject refs=0 subvolume without DEAD in SUBVOL_SYNC_WAIT Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox