]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: work around EBUSY discard returns from dm-thinp
authorDarrick J. Wong <djwong@kernel.org>
Fri, 5 Sep 2025 22:25:34 +0000 (15:25 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 17 Oct 2025 23:34:22 +0000 (16:34 -0700)
generic/500 has this interesting failure mode when fuse2fs is running in
fuseblk mode:

 --- /run/fstests/bin/tests/generic/500.out      2025-07-15 14:45:15.092576090 -0700
 +++ /var/tmp/fstests/generic/500.out.bad        2025-09-05 15:09:35.211499883 -0700
 @@ -1,2 +1,22 @@
  QA output created by 500
 +fstrim: /opt: FITRIM ioctl failed: Device or resource busy

Apparently you can overwhelm dm-thinp with a large number of discard
requests, at which point it starts returning EBUSY.  This is unexpected
behavior but let's mask that off because discard is advisory anyways.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
misc/fuse2fs.c

index b8db298cde202f09d97b88813de526638e5f9519..6864466435abfbfeb29171a603493e23e9b82646 100644 (file)
@@ -4038,6 +4038,14 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
 
                if (b - start >= minlen) {
                        err = io_channel_discard(fs->io, start, b - start);
+                       if (err == EBUSY) {
+                               /*
+                                * Apparently dm-thinp can return EBUSY when
+                                * it's too busy deallocating thinp units to
+                                * deallocate more.  Swallow these errors.
+                                */
+                               err = 0;
+                       }
                        if (err)
                                return translate_error(fs, fh->ino, err);
                        cleared += b - start;