]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.12-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Apr 2025 11:27:23 +0000 (13:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Apr 2025 11:27:23 +0000 (13:27 +0200)
added patches:
btrfs-fix-non-empty-delayed-iputs-list-on-unmount-due-to-compressed-write-workers.patch
btrfs-tests-fix-chunk-map-leak-after-failure-to-add-it-to-the-tree.patch
btrfs-zoned-fix-zone-activation-with-missing-devices.patch
btrfs-zoned-fix-zone-finishing-with-missing-devices.patch

queue-6.12/btrfs-fix-non-empty-delayed-iputs-list-on-unmount-due-to-compressed-write-workers.patch [new file with mode: 0644]
queue-6.12/btrfs-tests-fix-chunk-map-leak-after-failure-to-add-it-to-the-tree.patch [new file with mode: 0644]
queue-6.12/btrfs-zoned-fix-zone-activation-with-missing-devices.patch [new file with mode: 0644]
queue-6.12/btrfs-zoned-fix-zone-finishing-with-missing-devices.patch [new file with mode: 0644]
queue-6.12/series

diff --git a/queue-6.12/btrfs-fix-non-empty-delayed-iputs-list-on-unmount-due-to-compressed-write-workers.patch b/queue-6.12/btrfs-fix-non-empty-delayed-iputs-list-on-unmount-due-to-compressed-write-workers.patch
new file mode 100644 (file)
index 0000000..de13af4
--- /dev/null
@@ -0,0 +1,80 @@
+From 4c782247b89376a83fa132f7d45d6977edae0629 Mon Sep 17 00:00:00 2001
+From: Filipe Manana <fdmanana@suse.com>
+Date: Wed, 5 Mar 2025 16:52:26 +0000
+Subject: btrfs: fix non-empty delayed iputs list on unmount due to compressed write workers
+
+From: Filipe Manana <fdmanana@suse.com>
+
+commit 4c782247b89376a83fa132f7d45d6977edae0629 upstream.
+
+At close_ctree() after we have ran delayed iputs either through explicitly
+calling btrfs_run_delayed_iputs() or later during the call to
+btrfs_commit_super() or btrfs_error_commit_super(), we assert that the
+delayed iputs list is empty.
+
+When we have compressed writes this assertion may fail because delayed
+iputs may have been added to the list after we last ran delayed iputs.
+This happens like this:
+
+1) We have a compressed write bio executing;
+
+2) We enter close_ctree() and flush the fs_info->endio_write_workers
+   queue which is the queue used for running ordered extent completion;
+
+3) The compressed write bio finishes and enters
+   btrfs_finish_compressed_write_work(), where it calls
+   btrfs_finish_ordered_extent() which in turn calls
+   btrfs_queue_ordered_fn(), which queues a work item in the
+   fs_info->endio_write_workers queue that we have flushed before;
+
+4) At close_ctree() we proceed, run all existing delayed iputs and
+   call btrfs_commit_super() (which also runs delayed iputs), but before
+   we run the following assertion below:
+
+      ASSERT(list_empty(&fs_info->delayed_iputs))
+
+   A delayed iput is added by the step below...
+
+5) The ordered extent completion job queued in step 3 runs and results in
+   creating a delayed iput when dropping the last reference of the ordered
+   extent (a call to btrfs_put_ordered_extent() made from
+   btrfs_finish_one_ordered());
+
+6) At this point the delayed iputs list is not empty, so the assertion at
+   close_ctree() fails.
+
+Fix this by flushing the fs_info->compressed_write_workers queue at
+close_ctree() before flushing the fs_info->endio_write_workers queue,
+respecting the queue dependency as the later is responsible for the
+execution of ordered extent completion.
+
+CC: stable@vger.kernel.org # 5.15+
+Reviewed-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/btrfs/disk-io.c |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -4275,6 +4275,18 @@ void __cold close_ctree(struct btrfs_fs_
+       btrfs_flush_workqueue(fs_info->delalloc_workers);
+       /*
++       * When finishing a compressed write bio we schedule a work queue item
++       * to finish an ordered extent - btrfs_finish_compressed_write_work()
++       * calls btrfs_finish_ordered_extent() which in turns does a call to
++       * btrfs_queue_ordered_fn(), and that queues the ordered extent
++       * completion either in the endio_write_workers work queue or in the
++       * fs_info->endio_freespace_worker work queue. We flush those queues
++       * below, so before we flush them we must flush this queue for the
++       * workers of compressed writes.
++       */
++      flush_workqueue(fs_info->compressed_write_workers);
++
++      /*
+        * After we parked the cleaner kthread, ordered extents may have
+        * completed and created new delayed iputs. If one of the async reclaim
+        * tasks is running and in the RUN_DELAYED_IPUTS flush state, then we
diff --git a/queue-6.12/btrfs-tests-fix-chunk-map-leak-after-failure-to-add-it-to-the-tree.patch b/queue-6.12/btrfs-tests-fix-chunk-map-leak-after-failure-to-add-it-to-the-tree.patch
new file mode 100644 (file)
index 0000000..c08a2e5
--- /dev/null
@@ -0,0 +1,40 @@
+From 009ca358486ded9b4822eddb924009b6848d7271 Mon Sep 17 00:00:00 2001
+From: Filipe Manana <fdmanana@suse.com>
+Date: Tue, 11 Mar 2025 15:50:50 +0000
+Subject: btrfs: tests: fix chunk map leak after failure to add it to the tree
+
+From: Filipe Manana <fdmanana@suse.com>
+
+commit 009ca358486ded9b4822eddb924009b6848d7271 upstream.
+
+If we fail to add the chunk map to the fs mapping tree we exit
+test_rmap_block() without freeing the chunk map. Fix this by adding a
+call to btrfs_free_chunk_map() before exiting the test function if the
+call to btrfs_add_chunk_map() failed.
+
+Fixes: 7dc66abb5a47 ("btrfs: use a dedicated data structure for chunk maps")
+CC: stable@vger.kernel.org # 6.12+
+Reviewed-by: Boris Burkov <boris@bur.io>
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/btrfs/tests/extent-map-tests.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c
+index 56e61ac1cc64..609bb6c9c087 100644
+--- a/fs/btrfs/tests/extent-map-tests.c
++++ b/fs/btrfs/tests/extent-map-tests.c
+@@ -1045,6 +1045,7 @@ static int test_rmap_block(struct btrfs_fs_info *fs_info,
+       ret = btrfs_add_chunk_map(fs_info, map);
+       if (ret) {
+               test_err("error adding chunk map to mapping tree");
++              btrfs_free_chunk_map(map);
+               goto out_free;
+       }
+-- 
+2.49.0
+
diff --git a/queue-6.12/btrfs-zoned-fix-zone-activation-with-missing-devices.patch b/queue-6.12/btrfs-zoned-fix-zone-activation-with-missing-devices.patch
new file mode 100644 (file)
index 0000000..e5263ea
--- /dev/null
@@ -0,0 +1,41 @@
+From 2bbc4a45e5eb6b868357c1045bf6f38f6ba576e0 Mon Sep 17 00:00:00 2001
+From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Date: Mon, 17 Mar 2025 12:24:58 +0100
+Subject: btrfs: zoned: fix zone activation with missing devices
+
+From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+
+commit 2bbc4a45e5eb6b868357c1045bf6f38f6ba576e0 upstream.
+
+If btrfs_zone_activate() is called with a filesystem that has missing
+devices (e.g. a RAID file system mounted in degraded mode) it is accessing
+the btrfs_device::zone_info pointer, which will not be set if the device in
+question is missing.
+
+Check if the device is present (by checking if it has a valid block
+device pointer associated) and if not, skip zone activation for it.
+
+Fixes: f9a912a3c45f ("btrfs: zoned: make zone activation multi stripe capable")
+CC: stable@vger.kernel.org # 6.1+
+Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
+Reviewed-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/btrfs/zoned.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/fs/btrfs/zoned.c
++++ b/fs/btrfs/zoned.c
+@@ -2107,6 +2107,9 @@ bool btrfs_zone_activate(struct btrfs_bl
+               physical = map->stripes[i].physical;
+               zinfo = device->zone_info;
++              if (!device->bdev)
++                      continue;
++
+               if (zinfo->max_active_zones == 0)
+                       continue;
diff --git a/queue-6.12/btrfs-zoned-fix-zone-finishing-with-missing-devices.patch b/queue-6.12/btrfs-zoned-fix-zone-finishing-with-missing-devices.patch
new file mode 100644 (file)
index 0000000..1d26a20
--- /dev/null
@@ -0,0 +1,41 @@
+From 35fec1089ebb5617f85884d3fa6a699ce6337a75 Mon Sep 17 00:00:00 2001
+From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Date: Mon, 17 Mar 2025 12:24:59 +0100
+Subject: btrfs: zoned: fix zone finishing with missing devices
+
+From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+
+commit 35fec1089ebb5617f85884d3fa6a699ce6337a75 upstream.
+
+If do_zone_finish() is called with a filesystem that has missing devices
+(e.g. a RAID file system mounted in degraded mode) it is accessing the
+btrfs_device::zone_info pointer, which will not be set if the device
+in question is missing.
+
+Check if the device is present (by checking if it has a valid block device
+pointer associated) and if not, skip zone finishing for it.
+
+Fixes: 4dcbb8ab31c1 ("btrfs: zoned: make zone finishing multi stripe capable")
+CC: stable@vger.kernel.org # 6.1+
+Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
+Reviewed-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/btrfs/zoned.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/fs/btrfs/zoned.c
++++ b/fs/btrfs/zoned.c
+@@ -2271,6 +2271,9 @@ static int do_zone_finish(struct btrfs_b
+               struct btrfs_zoned_device_info *zinfo = device->zone_info;
+               unsigned int nofs_flags;
++              if (!device->bdev)
++                      continue;
++
+               if (zinfo->max_active_zones == 0)
+                       continue;
index 2ab8088a35df5d9d69e4464ed528343803c2795f..6493b28a61dc3aba3dfef3f4782d0e7b56b78e71 100644 (file)
@@ -287,3 +287,7 @@ arm64-mm-correct-the-update-of-max_pfn.patch
 arm64-dts-mediatek-mt8173-fix-disp-pwm-compatible-string.patch
 arm64-dts-exynos-gs101-disable-pinctrl_gsacore-node.patch
 backlight-led_bl-hold-led_access-lock-when-calling-led_sysfs_disable.patch
+btrfs-fix-non-empty-delayed-iputs-list-on-unmount-due-to-compressed-write-workers.patch
+btrfs-tests-fix-chunk-map-leak-after-failure-to-add-it-to-the-tree.patch
+btrfs-zoned-fix-zone-activation-with-missing-devices.patch
+btrfs-zoned-fix-zone-finishing-with-missing-devices.patch