From d73ac6fffccad1836394dd7e8783f51cccf70dc6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Aug 15 2022 11:23:00 +0000 Subject: RHEL-9.1: 2.37.4-8 (loop overlay test) Related: #2117203 Signed-off-by: Karel Zak --- diff --git a/0035-mount-Fix-race-in-loop-device-reuse-code.patch b/0035-mount-Fix-race-in-loop-device-reuse-code.patch deleted file mode 100644 index bfcf6ad..0000000 --- a/0035-mount-Fix-race-in-loop-device-reuse-code.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 99e5203da4bb8c4470f0c865add67b8151405bbc Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 20 Jan 2022 12:47:05 +0100 -Subject: mount: Fix race in loop device reuse code - -Small timing changes in the kernel loop device handling broke the -following loop: - -while :; do mount -o loop,ro isofs.iso isofs/; umount isofs/; done - -which quickly reports: -mount: /mnt: can't read superblock on /dev/loop0. -umount: /mnt: not mounted. - -And this loop is broken because of a subtle interaction with -systemd-udevd that also opens the loop device. The race seems to be in -mount(8) handling itself and the altered kernel timing makes it happen. -It look like: - -bash systemd-udevd - mount -o loop,ro isofs.iso isofs/ - /dev/loop0 is created and bound to isofs.iso, autoclear is set for - loop0 - opens /dev/loop0 - umount isofs/ - loop0 still lives because systemd-udev still has device open - mount -o loop,ro isofs.iso isofs/ - gets to mnt_context_setup_loopdev() - loopcxt_find_overlap() - sees loop0 is still valid and with proper parameters - reuse = true; - close /dev/loop0 - last fd closed => loop0 is - cleaned up - loopcxt_get_fd() - opens loop0 but it is no longer the device we wanted! - calls mount(2) which fails because we cannot read from the loop device - -Fix the problem by rechecking that loop device is still attached after -opening the device. This makes sure the kernel will not autoclear the -device anymore. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Jan Kara ---- - libmount/src/context_loopdev.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c -index 6462bfb62..73bcc01c1 100644 ---- a/libmount/src/context_loopdev.c -+++ b/libmount/src/context_loopdev.c -@@ -255,6 +255,25 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt) - DBG(LOOP, ul_debugobj(cxt, "re-using existing loop device %s", - loopcxt_get_device(&lc))); - -+ /* Open loop device to block device autoclear... */ -+ if (loopcxt_get_fd(&lc) < 0) { -+ DBG(LOOP, ul_debugobj(cxt, "failed to get loopdev FD")); -+ rc = -errno; -+ goto done; -+ } -+ -+ /* -+ * Now that we certainly have the loop device open, -+ * verify the loop device was not autocleared in the -+ * mean time. -+ */ -+ if (!loopcxt_get_info(&lc)) { -+ DBG(LOOP, ul_debugobj(cxt, "lost race with %s teardown", -+ loopcxt_get_device(&lc))); -+ loopcxt_deinit(&lc); -+ break; -+ } -+ - /* Once a loop is initialized RO, there is no - * way to change its parameters. */ - if (loopcxt_is_readonly(&lc) --- -2.37.1 - diff --git a/0035-tests-add-udevadm-settle-to-loop-overlap-test.patch b/0035-tests-add-udevadm-settle-to-loop-overlap-test.patch new file mode 100644 index 0000000..ac4fa70 --- /dev/null +++ b/0035-tests-add-udevadm-settle-to-loop-overlap-test.patch @@ -0,0 +1,48 @@ +From 723438ad02928d9614439def99b36e0758f62d26 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 12 Aug 2022 08:30:49 +0200 +Subject: tests: add udevadm settle to loop overlap test + +Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 +Signed-off-by: Karel Zak +--- + tests/ts/libmount/loop-overlay | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay +index 62874a182..c27f60d0f 100755 +--- a/tests/ts/libmount/loop-overlay ++++ b/tests/ts/libmount/loop-overlay +@@ -43,22 +43,29 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null + + echo "second should fail" >>$TS_OUTPUT + $TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG ++udevadm settle + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG ++udevadm settle + + echo "should succeed" >>$TS_OUTPUT + $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG ++udevadm settle + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG ++udevadm settle + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG + $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG ++udevadm settle + + echo "both should fail" >>$TS_OUTPUT + LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") ++udevadm settle + $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT + $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ + | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT ++udevadm settle + $TS_CMD_LOSETUP --detach $LOOPDEV + + ts_log "Success" +-- +2.37.2 + diff --git a/0036-loopdev-Properly-translate-errors-from-ul_path_read_.patch b/0036-loopdev-Properly-translate-errors-from-ul_path_read_.patch deleted file mode 100644 index dbf4040..0000000 --- a/0036-loopdev-Properly-translate-errors-from-ul_path_read_.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 432b5024cc40647ea0a541c70c31d00719b52652 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 20 Jan 2022 13:16:38 +0100 -Subject: loopdev: Properly translate errors from ul_path_read_*() - -A few callsites do not translate error from ul_path_read_*() and just -treat it as error code leading to confusing EPERM errors. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Jan Kara ---- - lib/loopdev.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index d9ea1d4a2..db3aab29f 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -739,7 +739,8 @@ int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset) - int rc = -EINVAL; - - if (sysfs) -- rc = ul_path_read_u64(sysfs, offset, "loop/offset"); -+ if (ul_path_read_u64(sysfs, offset, "loop/offset") == 0) -+ rc = 0; - - if (rc && loopcxt_ioctl_enabled(lc)) { - struct loop_info64 *lo = loopcxt_get_info(lc); -@@ -767,7 +768,8 @@ int loopcxt_get_blocksize(struct loopdev_cxt *lc, uint64_t *blocksize) - int rc = -EINVAL; - - if (sysfs) -- rc = ul_path_read_u64(sysfs, blocksize, "queue/logical_block_size"); -+ if (ul_path_read_u64(sysfs, blocksize, "queue/logical_block_size") == 0) -+ rc = 0; - - /* Fallback based on BLKSSZGET ioctl */ - if (rc) { -@@ -799,7 +801,8 @@ int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size) - int rc = -EINVAL; - - if (sysfs) -- rc = ul_path_read_u64(sysfs, size, "loop/sizelimit"); -+ if (ul_path_read_u64(sysfs, size, "loop/sizelimit") == 0) -+ rc = 0; - - if (rc && loopcxt_ioctl_enabled(lc)) { - struct loop_info64 *lo = loopcxt_get_info(lc); --- -2.37.1 - diff --git a/0037-loopdev-Do-not-treat-errors-when-detecting-overlap-a.patch b/0037-loopdev-Do-not-treat-errors-when-detecting-overlap-a.patch deleted file mode 100644 index b3955a7..0000000 --- a/0037-loopdev-Do-not-treat-errors-when-detecting-overlap-a.patch +++ /dev/null @@ -1,56 +0,0 @@ -From ea556ef1d9e26802842577597e3736528f54ee0f Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 20 Jan 2022 13:16:39 +0100 -Subject: loopdev: Do not treat errors when detecting overlap as fatal - -When looking for overlapping loop device we can fail getting some loop -device properties when we race with device autoclear. Just squelsh these -errors and try next loop device. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Jan Kara ---- - lib/loopdev.c | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index db3aab29f..511f8a0d6 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -1773,10 +1773,13 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename, - - rc = loopcxt_is_used(lc, hasst ? &st : NULL, - filename, offset, sizelimit, 0); -- if (!rc) -- continue; /* unused */ -- if (rc < 0) -- break; /* error */ -+ /* -+ * Either the loopdev is unused or we've got an error which can -+ * happen when we are racing with device autoclear. Just ignore -+ * this loopdev... -+ */ -+ if (rc <= 0) -+ continue; - - DBG(CXT, ul_debugobj(lc, "found %s backed by %s", - loopcxt_get_device(lc), filename)); -@@ -1785,13 +1788,13 @@ int loopcxt_find_overlap(struct loopdev_cxt *lc, const char *filename, - if (rc) { - DBG(CXT, ul_debugobj(lc, "failed to get offset for device %s", - loopcxt_get_device(lc))); -- break; -+ continue; - } - rc = loopcxt_get_sizelimit(lc, &lc_sizelimit); - if (rc) { - DBG(CXT, ul_debugobj(lc, "failed to get sizelimit for device %s", - loopcxt_get_device(lc))); -- break; -+ continue; - } - - /* full match */ --- -2.37.1 - diff --git a/0038-loopdev-add-retries-on-EAGAIN.patch b/0038-loopdev-add-retries-on-EAGAIN.patch deleted file mode 100644 index bce6199..0000000 --- a/0038-loopdev-add-retries-on-EAGAIN.patch +++ /dev/null @@ -1,87 +0,0 @@ -From a24905f03e90fb2f418bd5b8816378a99bb535b2 Mon Sep 17 00:00:00 2001 -From: Karel Zak -Date: Tue, 1 Mar 2022 12:07:07 +0100 -Subject: loopdev: add retries on EAGAIN - -* add limit to number of attempts for LOOP_SET_STATUS64 - -* use the same for LOOP_SET_BLOCK_SIZE ioctl - -Addresses: https://github.com/util-linux/util-linux/issues/1582 -Signed-off-by: Karel Zak ---- - lib/loopdev.c | 32 +++++++++++++++++++++++--------- - 1 file changed, 23 insertions(+), 9 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index 511f8a0d6..e8ccf6ae6 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -43,6 +43,9 @@ - #include "debug.h" - #include "fileutils.h" - -+ -+#define LOOPDEV_MAX_TRIES 10 -+ - /* - * Debug stuff (based on include/debug.h) - */ -@@ -1450,7 +1453,7 @@ err: - */ - int loopcxt_ioctl_status(struct loopdev_cxt *lc) - { -- int dev_fd, rc = -1, err, again; -+ int dev_fd, rc = -1, err, again, tries = 0; - - errno = 0; - dev_fd = loopcxt_get_fd(lc); -@@ -1464,9 +1467,12 @@ int loopcxt_ioctl_status(struct loopdev_cxt *lc) - do { - err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info); - again = err && errno == EAGAIN; -- if (again) -+ if (again) { - xusleep(250000); -- } while (again); -+ tries++; -+ } -+ } while (again && tries <= LOOPDEV_MAX_TRIES); -+ - if (err) { - rc = -errno; - DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); -@@ -1520,16 +1526,24 @@ int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio) - int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize) - { - int fd = loopcxt_get_fd(lc); -+ int err, again, tries = 0; - - if (fd < 0) - return -EINVAL; - -- /* Kernels prior to v4.14 don't support this ioctl */ -- if (ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) blocksize) < 0) { -- int rc = -errno; -- DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m")); -- return rc; -- } -+ do { -+ /* Kernels prior to v4.14 don't support this ioctl */ -+ err = ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) blocksize); -+ again = err && errno == EAGAIN; -+ if (again) { -+ xusleep(250000); -+ tries++; -+ } else if (err) { -+ int rc = -errno; -+ DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m")); -+ return rc; -+ } -+ } while (again && tries <= LOOPDEV_MAX_TRIES); - - DBG(CXT, ul_debugobj(lc, "logical block size set")); - return 0; --- -2.37.1 - diff --git a/0039-lib-loopdev-remove-duplicate-code.patch b/0039-lib-loopdev-remove-duplicate-code.patch deleted file mode 100644 index 0854bd0..0000000 --- a/0039-lib-loopdev-remove-duplicate-code.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 24a39bb8baf827133c1cc6445021170502c18b94 Mon Sep 17 00:00:00 2001 -From: Karel Zak -Date: Tue, 8 Mar 2022 13:02:38 +0100 -Subject: lib/loopdev: remove duplicate code - -Use loopcxt_ioctl_status() rather than duplicate code. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Karel Zak ---- - lib/loopdev.c | 18 ++++-------------- - 1 file changed, 4 insertions(+), 14 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index e8ccf6ae6..fda0e1210 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -1296,7 +1296,8 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd) - */ - int loopcxt_setup_device(struct loopdev_cxt *lc) - { -- int file_fd, dev_fd, mode = O_RDWR, rc = -1, cnt = 0, err, again; -+ int file_fd, dev_fd, mode = O_RDWR; -+ int rc = -1, cnt = 0; - int errsv = 0; - int fallback = 0; - -@@ -1400,21 +1401,10 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) - goto err; - } - -- do { -- err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info); -- again = err && errno == EAGAIN; -- if (again) -- xusleep(250000); -- } while (again); -- -- if (err) { -- rc = -errno; -- errsv = errno; -- DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); -+ if ((rc = loopcxt_ioctl_status(lc)) < 0) { -+ errsv = -rc; - goto err; - } -- -- DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64: OK")); - } - - if ((rc = loopcxt_check_size(lc, file_fd))) --- -2.37.1 - diff --git a/0040-lib-loopdev-consolidate-ioctls-calls-on-EAGAIN.patch b/0040-lib-loopdev-consolidate-ioctls-calls-on-EAGAIN.patch deleted file mode 100644 index bf8f0d3..0000000 --- a/0040-lib-loopdev-consolidate-ioctls-calls-on-EAGAIN.patch +++ /dev/null @@ -1,213 +0,0 @@ -From 53b543476d271cce71c4f5b66d9d6a28f1a75370 Mon Sep 17 00:00:00 2001 -From: Karel Zak -Date: Wed, 9 Mar 2022 11:28:07 +0100 -Subject: lib/loopdev: consolidate ioctls calls on EAGAIN - -Keep all logic to repeat ioctl calls in one macro rather than -duplicate code. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Karel Zak ---- - lib/loopdev.c | 97 ++++++++++++++++++++++++++++----------------------- - 1 file changed, 54 insertions(+), 43 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index fda0e1210..cceab2db1 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -43,7 +43,6 @@ - #include "debug.h" - #include "fileutils.h" - -- - #define LOOPDEV_MAX_TRIES 10 - - /* -@@ -77,6 +76,24 @@ static void loopdev_init_debug(void) - #define loopcxt_sysfs_available(_lc) (!((_lc)->flags & LOOPDEV_FL_NOSYSFS)) \ - && !loopcxt_ioctl_enabled(_lc) - -+/* -+ * Calls @x and repeat on EAGAIN -+ */ -+#define repeat_on_eagain(x) __extension__ ({ \ -+ int _c = 0, _e; \ -+ do { \ -+ errno = 0; \ -+ _e = x; \ -+ if (_e == 0 || errno != EAGAIN) \ -+ break; \ -+ if (_c >= LOOPDEV_MAX_TRIES) \ -+ break; \ -+ xusleep(250000); \ -+ _c++; \ -+ } while (1); \ -+ _e == 0 ? 0 : errno ? -errno : -1; \ -+ }) -+ - /* - * @lc: context - * @device: device name, absolute device path or NULL to reset the current setting -@@ -1276,6 +1293,7 @@ static int loopcxt_check_size(struct loopdev_cxt *lc, int file_fd) - return 0; - } - -+ - /* - * @lc: context - * -@@ -1364,8 +1382,9 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) - * -- since Linux v5.8-rc1, commit 3448914e8cc550ba792d4ccc74471d1ca4293aae - */ - lc->config.fd = file_fd; -- if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) { -- rc = -errno; -+ -+ rc = repeat_on_eagain( ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) ); -+ if (rc != 0) { - errsv = errno; - if (errno != EINVAL && errno != ENOTTY) { - DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m")); -@@ -1430,6 +1449,7 @@ err: - return rc; - } - -+ - /* - * @lc: context - * -@@ -1443,28 +1463,18 @@ err: - */ - int loopcxt_ioctl_status(struct loopdev_cxt *lc) - { -- int dev_fd, rc = -1, err, again, tries = 0; -+ int dev_fd, rc; - - errno = 0; - dev_fd = loopcxt_get_fd(lc); - -- if (dev_fd < 0) { -- rc = -errno; -- return rc; -- } -- DBG(SETUP, ul_debugobj(lc, "device open: OK")); -+ if (dev_fd < 0) -+ return -errno; - -- do { -- err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info); -- again = err && errno == EAGAIN; -- if (again) { -- xusleep(250000); -- tries++; -- } -- } while (again && tries <= LOOPDEV_MAX_TRIES); -+ DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_STATUS64")); - -- if (err) { -- rc = -errno; -+ rc = repeat_on_eagain( ioctl(dev_fd, LOOP_SET_STATUS64, &lc->config.info) ); -+ if (rc != 0) { - DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); - return rc; - } -@@ -1475,14 +1485,16 @@ int loopcxt_ioctl_status(struct loopdev_cxt *lc) - - int loopcxt_ioctl_capacity(struct loopdev_cxt *lc) - { -- int fd = loopcxt_get_fd(lc); -+ int rc, fd = loopcxt_get_fd(lc); - - if (fd < 0) - return -EINVAL; - -+ DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_CAPACITY")); -+ - /* Kernels prior to v2.6.30 don't support this ioctl */ -- if (ioctl(fd, LOOP_SET_CAPACITY, 0) < 0) { -- int rc = -errno; -+ rc = repeat_on_eagain( ioctl(fd, LOOP_SET_CAPACITY, 0) ); -+ if (rc != 0) { - DBG(CXT, ul_debugobj(lc, "LOOP_SET_CAPACITY failed: %m")); - return rc; - } -@@ -1493,14 +1505,16 @@ int loopcxt_ioctl_capacity(struct loopdev_cxt *lc) - - int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio) - { -- int fd = loopcxt_get_fd(lc); -+ int rc, fd = loopcxt_get_fd(lc); - - if (fd < 0) - return -EINVAL; - -+ DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_DIRECT_IO")); -+ - /* Kernels prior to v4.4 don't support this ioctl */ -- if (ioctl(fd, LOOP_SET_DIRECT_IO, use_dio) < 0) { -- int rc = -errno; -+ rc = repeat_on_eagain( ioctl(fd, LOOP_SET_DIRECT_IO, use_dio) ); -+ if (rc != 0) { - DBG(CXT, ul_debugobj(lc, "LOOP_SET_DIRECT_IO failed: %m")); - return rc; - } -@@ -1515,25 +1529,19 @@ int loopcxt_ioctl_dio(struct loopdev_cxt *lc, unsigned long use_dio) - */ - int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize) - { -- int fd = loopcxt_get_fd(lc); -- int err, again, tries = 0; -+ int rc, fd = loopcxt_get_fd(lc); - - if (fd < 0) - return -EINVAL; - -- do { -- /* Kernels prior to v4.14 don't support this ioctl */ -- err = ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) blocksize); -- again = err && errno == EAGAIN; -- if (again) { -- xusleep(250000); -- tries++; -- } else if (err) { -- int rc = -errno; -- DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m")); -- return rc; -- } -- } while (again && tries <= LOOPDEV_MAX_TRIES); -+ DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_BLOCK_SIZE")); -+ -+ rc = repeat_on_eagain( -+ ioctl(fd, LOOP_SET_BLOCK_SIZE, (unsigned long) blocksize) ); -+ if (rc != 0) { -+ DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m")); -+ return rc; -+ } - - DBG(CXT, ul_debugobj(lc, "logical block size set")); - return 0; -@@ -1541,14 +1549,17 @@ int loopcxt_ioctl_blocksize(struct loopdev_cxt *lc, uint64_t blocksize) - - int loopcxt_delete_device(struct loopdev_cxt *lc) - { -- int fd = loopcxt_get_fd(lc); -+ int rc, fd = loopcxt_get_fd(lc); - - if (fd < 0) - return -EINVAL; - -- if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { -+ DBG(SETUP, ul_debugobj(lc, "calling LOOP_SET_CLR_FD")); -+ -+ rc = repeat_on_eagain( ioctl(fd, LOOP_CLR_FD, 0) ); -+ if (rc != 0) { - DBG(CXT, ul_debugobj(lc, "LOOP_CLR_FD failed: %m")); -- return -errno; -+ return rc; - } - - DBG(CXT, ul_debugobj(lc, "device removed")); --- -2.37.1 - diff --git a/0041-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch b/0041-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch deleted file mode 100644 index 97d5dfd..0000000 --- a/0041-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch +++ /dev/null @@ -1,46 +0,0 @@ -From bb387c7bb2d9112362077d6ac275f1ebc7c24023 Mon Sep 17 00:00:00 2001 -From: Hideki EIRAKU -Date: Wed, 25 May 2022 12:23:16 +0900 -Subject: loopdev: set block_size when using LOOP_CONFIGURE - -LOOP_CONFIGURE ioctl was introduced by commit -d5fd456c88aba4fcf77d35fe38024a8d5c814686. Since the previous -implementation set partscan flag but did not set block_size with the -LOOP_CONFIGURE ioctl, an issue fixed by commit -422f0e9f206a145c59a71333dad20d38cbbfc0c4 was reappeared. Setting -block_size in the LOOP_CONFIGURE ioctl parameter fixes the issue. - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Hideki EIRAKU ---- - lib/loopdev.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/lib/loopdev.c b/lib/loopdev.c -index cceab2db1..d7184aba6 100644 ---- a/lib/loopdev.c -+++ b/lib/loopdev.c -@@ -1382,6 +1382,8 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) - * -- since Linux v5.8-rc1, commit 3448914e8cc550ba792d4ccc74471d1ca4293aae - */ - lc->config.fd = file_fd; -+ if (lc->blocksize > 0) -+ lc->config.block_size = lc->blocksize; - - rc = repeat_on_eagain( ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) ); - if (rc != 0) { -@@ -1392,11 +1394,6 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) - } - fallback = 1; - } else { -- if (lc->blocksize > 0 -- && (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) { -- errsv = -rc; -- goto err; -- } - DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK")); - } - --- -2.37.1 - diff --git a/0042-tests-add-udevadm-settle-to-loop-overlap-test.patch b/0042-tests-add-udevadm-settle-to-loop-overlap-test.patch deleted file mode 100644 index d390e34..0000000 --- a/0042-tests-add-udevadm-settle-to-loop-overlap-test.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 500aa7e702f87031a5390a3275f54097b2bc7f42 Mon Sep 17 00:00:00 2001 -From: Karel Zak -Date: Fri, 12 Aug 2022 08:30:49 +0200 -Subject: tests: add udevadm settle to loop overlap test - -Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203 -Signed-off-by: Karel Zak ---- - tests/ts/libmount/loop-overlay | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay -index 62874a182..c27f60d0f 100755 ---- a/tests/ts/libmount/loop-overlay -+++ b/tests/ts/libmount/loop-overlay -@@ -43,22 +43,29 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null - - echo "second should fail" >>$TS_OUTPUT - $TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG -+udevadm settle - $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ - | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT - $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG -+udevadm settle - - echo "should succeed" >>$TS_OUTPUT - $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG -+udevadm settle - $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG -+udevadm settle - $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG - $TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG -+udevadm settle - - echo "both should fail" >>$TS_OUTPUT - LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG") -+udevadm settle - $TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \ - | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT - $TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \ - | sed 's/:.*:/: /; s/for .*/for /' >> $TS_OUTPUT -+udevadm settle - $TS_CMD_LOSETUP --detach $LOOPDEV - - ts_log "Success" --- -2.37.1 - diff --git a/util-linux.spec b/util-linux.spec index 183f96e..93eebe2 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.37.4 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: http://en.wikipedia.org/wiki/Util-linux @@ -146,14 +146,8 @@ Patch33: 0033-lib-path-make-ul_path_read_buffer-more-robust-coveri.patch # 2094216 - lslogins reports incorrect "Password is locked" status Patch34: 0034-lslogins-improve-for-static-analyzer.patch # 2117203 - RHEL-9.1: loop-overlay test failed -Patch35: 0035-mount-Fix-race-in-loop-device-reuse-code.patch -Patch36: 0036-loopdev-Properly-translate-errors-from-ul_path_read_.patch -Patch37: 0037-loopdev-Do-not-treat-errors-when-detecting-overlap-a.patch -Patch38: 0038-loopdev-add-retries-on-EAGAIN.patch -Patch39: 0039-lib-loopdev-remove-duplicate-code.patch -Patch40: 0040-lib-loopdev-consolidate-ioctls-calls-on-EAGAIN.patch -Patch41: 0041-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch -Patch42: 0042-tests-add-udevadm-settle-to-loop-overlap-test.patch +Patch35: 0035-tests-add-udevadm-settle-to-loop-overlap-test.patch + %description The util-linux package contains a large variety of low-level system @@ -988,6 +982,9 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Mon Aug 15 2022 Karel Zak 2.37.4-8 +- remove unnecessary patches (#2117203) + * Fri Aug 12 2022 Karel Zak 2.37.4-7 - improve loop overlay test (#2117203)