| | |
|---|---|
| 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
| `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
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
- `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.
--- /dev/null
+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
+