]> git.hungrycats.org Git - linux/commitdiff
resize-missing: export the new series and add it to the README
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 21 Oct 2026 21:47:30 +0000 (17:47 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 21 Oct 2026 21:47:30 +0000 (17:47 -0400)
topics/resize-missing is one patch, Qu Wenruo's 2019 "shrink a missing
device" resize change, rewritten: growth of a missing device is now
rejected for +size and absolute sizes too, and every rejection returns.
It merges into misc-next/testing 723245adb5c1 with no conflict, so
fixups/post-merge.patch is unchanged.  No cover letter yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6wxsJn1aY7PwnhgXdz6Ec

README.md
topics/resize-missing/0001-btrfs-resize-allow-shrinking-a-missing-device.patch [new file with mode: 0644]

index e7167f4845b5cc07786ef4c4e982e784461eebac..360ac35b0373100718475b8e0cd4f5ed0cd8c292 100644 (file)
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@ upstream at all (see the table).
 | | |
 |---|---|
 | base of every series | `0c48d26d46bd` ("btrfs: stop reading free space inodes from the commit root"), the misc-next lane base (`misc-next/testing^1`) |
-| integration branch | `misc-next/testing` `318dec80d29b` (octopus of all 18 topics) |
-| lane head | `zygo-misc-next-zb64` `9c343098c7ea`; its own commits on top of `testing` (kernel configs, `covers/`) are not exported |
+| integration branch | `misc-next/testing` `723245adb5c1` (octopus of all 19 topics) |
+| lane head | `zygo-misc-next-zb64` `2550544f9c6e`; its own commits on top of `testing` (kernel configs, `covers/`) are not exported |
 
 The base is not a published commit: the lane rebuilds it from
 btrfs/for-next plus David Sterba's queue.  It lives in the
@@ -77,6 +77,7 @@ the integration recipe below uses.
 | `read-policies` | 9 | `18680c6045be` | Kai Krakow | new | Kai's series; his postings are authoritative |
 | `replace-fixes` | 7 | `43c8a1e60a5a` | Zygo | new | patch 7 has a btrfs-progs counterpart (`topics/replace-abort-uncorrectable`) |
 | `dev-stats` | 1 | `55ade1cf195c` | Zygo | new, 0/1 (2026-10-21) | behaviour change, offered for rejection; independent of every other series |
+| `resize-missing` | 1 | `8763f9e2126d` | Qu Wenruo, rewritten by Zygo | none yet (single patch) | Qu's 2019 patch reworked: grow checks now return, absolute sizes checked; Zygo's Signed-off-by to be added before sending |
 
 ## Applying one series
 
@@ -111,7 +112,7 @@ B=0c48d26d46bd
 ORDER="logical-ino-costs balance-resume compress-fixes deadlock-fixes dedupe-fixes
        delalloc-fixes dev-extent-defrag prealloc-size raid56-fixes raid56-scrub-replace
        stripe-alloc low-space dedupe-mtime dm-stripfault allocator-hints read-policies
-       replace-fixes dev-stats"
+       replace-fixes dev-stats resize-missing"
 
 for t in $ORDER; do
        git checkout -q -b up/$t $B
@@ -203,5 +204,5 @@ The fixup adds 640 lines and removes 16, in 10 files.
 - `balance-resume` patch 3 is offered for rejection, as its cover letter
   says.
 - Re-export with `scripts/export.sh` after any lane change.  The
-  directories reflect the lane at `misc-next/testing` `318dec80d29b`.
+  directories reflect the lane at `misc-next/testing` `723245adb5c1`.
   Commit the result with the misc-next SHAs that the script prints.
diff --git a/topics/resize-missing/0001-btrfs-resize-allow-shrinking-a-missing-device.patch b/topics/resize-missing/0001-btrfs-resize-allow-shrinking-a-missing-device.patch
new file mode 100644 (file)
index 0000000..0e08e96
--- /dev/null
@@ -0,0 +1,100 @@
+From 8763f9e2126d43bc4504612d63f08807aec86a7e Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Mon, 18 Nov 2019 15:05:25 +0800
+Subject: [PATCH] btrfs: resize: allow shrinking a missing device
+To: linux-btrfs@vger.kernel.org
+
+One user reported a case where a device couldn't be replaced because the
+replacement was slightly smaller than the device it replaces.
+
+Since it's a RAID10 fs, "btrfs device remove missing" would take a long
+time and might not be possible at all for lack of space.
+
+Work around this by allowing the resize ioctl to shrink a missing
+device.  The user can shrink the missing device to the size of the
+replacement first, then replace it.  Dev-replace compares the target's
+size with the source's total_bytes, so the shrunk device fits.
+
+A missing device has no block device to measure, so it can't grow:
+"max", "+size" and an absolute size larger than the current size are
+all rejected with -EINVAL.  A device counts as missing when it has
+BTRFS_DEV_STATE_MISSING set or no bdev.  A device that is present but
+not writeable is still rejected with -EPERM, as before.
+
+Reported-by: Nathan Dehnel <ncdehnel@gmail.com>
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Assisted-by: Claude:claude-opus-5-5
+---
+ fs/btrfs/ioctl.c | 32 ++++++++++++++++++++++++++++----
+ 1 file changed, 28 insertions(+), 4 deletions(-)
+
+diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
+index dec015e6bd29a..ceec0d43123c7 100644
+--- a/fs/btrfs/ioctl.c
++++ b/fs/btrfs/ioctl.c
+@@ -1033,6 +1033,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
+       int ret = 0;
+       int mod = 0;
+       bool cancel;
++      bool missing;
+ 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+@@ -1085,7 +1086,15 @@ static noinline int btrfs_ioctl_resize(struct file *file,
+               goto out_finish;
+       }
+ 
+-      if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
++      /*
++       * A missing device can be shrunk, so that a replacement smaller than
++       * its recorded size can take its place, but there is no block device
++       * to measure, so it can't grow.
++       */
++      missing = test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state) ||
++                !device->bdev;
++      if (!missing &&
++          !test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
+               btrfs_info(fs_info,
+                          "resizer unable to apply on readonly device %llu",
+                      devid);
+@@ -1093,9 +1102,16 @@ static noinline int btrfs_ioctl_resize(struct file *file,
+               goto out_finish;
+       }
+ 
+-      if (!strcmp(sizestr, "max"))
++      if (!strcmp(sizestr, "max")) {
++              if (missing) {
++                      btrfs_info(fs_info,
++                      "resizer unable to apply 'max' on missing device %llu",
++                                 devid);
++                      ret = -EINVAL;
++                      goto out_finish;
++              }
+               new_size = bdev_nr_bytes(device->bdev);
+-      else {
++      } else {
+               char *retptr;
+ 
+               if (sizestr[0] == '-') {
+@@ -1137,7 +1153,15 @@ static noinline int btrfs_ioctl_resize(struct file *file,
+               ret = -EINVAL;
+               goto out_finish;
+       }
+-      if (new_size > bdev_nr_bytes(device->bdev)) {
++      if (missing) {
++              if (new_size > old_size) {
++                      btrfs_info(fs_info,
++                      "resizer unable to grow missing device %llu",
++                                 devid);
++                      ret = -EINVAL;
++                      goto out_finish;
++              }
++      } else if (new_size > bdev_nr_bytes(device->bdev)) {
+               ret = -EFBIG;
+               goto out_finish;
+       }
+
+base-commit: 0c48d26d46bdd6422bb91ba7f1c519a2993116dc
+-- 
+2.47.3
+