diff --git a/0075-lib-loopdev-retry-LOOP_SET_STATUS64-and-LOOP_SET_BLO.patch b/0075-lib-loopdev-retry-LOOP_SET_STATUS64-and-LOOP_SET_BLO.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6e1ea1e8e358b9ca2cfa119e3dd7266033ec226 --- /dev/null +++ b/0075-lib-loopdev-retry-LOOP_SET_STATUS64-and-LOOP_SET_BLO.patch @@ -0,0 +1,109 @@ +From 97a5abd36eeab4e07a31b27f6a2c2078d42e2e33 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 8 Mar 2022 11:40:58 +0100 +Subject: lib/loopdev: retry LOOP_SET_STATUS64 and LOOP_SET_BLOCK_SIZE on + EAGAIN + +Upstream: http://github.com/util-linux/util-linux/commit/0ae7bb11c29aa11c8ef25b1ef2f82ee4701b856d +Upstream: http://github.com/util-linux/util-linux/commit/eab90ef8d4f66394285e0cff1dfc0a27242c05aa +Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=2058176 +Signed-off-by: Karel Zak +--- + lib/loopdev.c | 42 +++++++++++++++++++++++++++++++++++++----- + 1 file changed, 37 insertions(+), 5 deletions(-) + +diff --git a/lib/loopdev.c b/lib/loopdev.c +index 54d337ea3..48af82aef 100644 +--- a/lib/loopdev.c ++++ b/lib/loopdev.c +@@ -42,6 +42,8 @@ + #include "blkdev.h" + #include "debug.h" + ++#define LOOPDEV_MAX_TRIES 10 ++ + /* + * Debug stuff (based on include/debug.h) + */ +@@ -1260,6 +1262,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) + { + int file_fd, dev_fd, mode = O_RDWR, rc = -1, cnt = 0; + int errsv = 0; ++ int err, again; + + if (!lc || !*lc->device || !lc->filename) + return -EINVAL; +@@ -1331,7 +1334,17 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) + + DBG(SETUP, ul_debugobj(lc, "LOOP_SET_FD: OK")); + +- if (ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info)) { ++ cnt = 0; ++ do { ++ err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info); ++ again = err && errno == EAGAIN; ++ if (again) { ++ xusleep(250000); ++ cnt++; ++ } ++ } while (again && cnt <= LOOPDEV_MAX_TRIES); ++ ++ if (err) { + rc = -errno; + errsv = errno; + DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); +@@ -1376,7 +1389,7 @@ err: + */ + int loopcxt_set_status(struct loopdev_cxt *lc) + { +- int dev_fd, rc = -1; ++ int dev_fd, rc = -1, err, again, tries = 0; + + errno = 0; + dev_fd = loopcxt_get_fd(lc); +@@ -1387,7 +1400,16 @@ int loopcxt_set_status(struct loopdev_cxt *lc) + } + DBG(SETUP, ul_debugobj(lc, "device open: OK")); + +- if (ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info)) { ++ do { ++ err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info); ++ again = err && errno == EAGAIN; ++ if (again) { ++ xusleep(250000); ++ tries++; ++ } ++ } while (again && tries <= LOOPDEV_MAX_TRIES); ++ ++ if (err) { + rc = -errno; + DBG(SETUP, ul_debugobj(lc, "LOOP_SET_STATUS64 failed: %m")); + return rc; +@@ -1440,12 +1462,22 @@ int loopcxt_set_dio(struct loopdev_cxt *lc, unsigned long use_dio) + int loopcxt_set_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) { ++ 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++; ++ } ++ } while (again && tries <= LOOPDEV_MAX_TRIES); ++ ++ if (err) { + int rc = -errno; + DBG(CXT, ul_debugobj(lc, "LOOP_SET_BLOCK_SIZE failed: %m")); + return rc; +-- +2.34.1 + diff --git a/1001-hwclock-make-glibc-2.31-compatible.patch b/1001-hwclock-make-glibc-2.31-compatible.patch deleted file mode 100644 index d4908a69fb5b2a0c20f29fa13826f818d4f976f6..0000000000000000000000000000000000000000 --- a/1001-hwclock-make-glibc-2.31-compatible.patch +++ /dev/null @@ -1,161 +0,0 @@ -From e42f9f05a96c9e0129722b15fc638d4133ac1ecb Mon Sep 17 00:00:00 2001 -From: J William Piggott -Date: Tue, 19 Apr 2022 23:22:11 -0400 -Subject: [PATCH] hwclock: make glibc 2.31 compatible -______________________________________________________ -GNU C Library NEWS -- history of user-visible changes. -Version 2.31 -Deprecated and removed features, and other changes affecting compatibility: - -* The settimeofday function can still be used to set a system-wide time - zone when the operating system supports it. This is because the Linux - kernel reused the API, on some architectures, to describe a system-wide - time-zone-like offset between the software clock maintained by the kernel, - and the "RTC" clock that keeps time when the system is shut down. - - However, to reduce the odds of this offset being set by accident, - settimeofday can no longer be used to set the time and the offset - simultaneously. If both of its two arguments are non-null, the call - will fail (setting errno to EINVAL). - - Callers attempting to set this offset should also be prepared for the call - to fail and set errno to ENOSYS; this already happens on the Hurd and on - some Linux architectures. The Linux kernel maintainers are discussing a - more principled replacement for the reused API. After a replacement - becomes available, we will change settimeofday to fail with ENOSYS on all - platforms when its 'tzp' argument is not a null pointer. - - settimeofday itself is obsolescent according to POSIX. Programs that set - the system time should use clock_settime and/or the adjtime family of - functions instead. We may cease to make settimeofday available to newly - linked binaries after there is a replacement for Linux's time-zone-like - offset API. -______________________________________________________ - -hwclock(8) had one settimeofday(2) call where both args were set for ---hctosys when the RTC was ticking UTC. This allowed setting the system -time, timezone, and locking the warp_clock function with a single call. -That operation now takes 3 calls of settimeofday(2). - -Although this common operation now takes three calls, the overall logic -for the set_system_clock() function was simplified. - -Co-Author: Karel Zak -Signed-off-by: J William Piggott ---- - sys-utils/hwclock.c | 70 ++++++++++++++++++++++----------------------- - 1 file changed, 35 insertions(+), 35 deletions(-) - -diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c -index b83e710..19e7410 100644 ---- a/sys-utils/hwclock.c -+++ b/sys-utils/hwclock.c -@@ -583,28 +583,28 @@ display_time(struct timeval hwctime) - * tz.tz_minuteswest argument and sets PCIL (see below). At boot settimeofday(2) - * has one-shot access to this function as shown in the table below. - * -- * +-------------------------------------------------------------------+ -- * | settimeofday(tv, tz) | -- * |-------------------------------------------------------------------| -- * | Arguments | System Time | PCIL | | warp_clock | -- * | tv | tz | set | warped | set | firsttime | locked | -- * |---------|---------|---------------|------|-----------|------------| -- * | pointer | NULL | yes | no | no | 1 | no | -- * | pointer | pointer | yes | no | no | 0 | yes | -- * | NULL | ptr2utc | no | no | no | 0 | yes | -- * | NULL | pointer | no | yes | yes | 0 | yes | -- * +-------------------------------------------------------------------+ -+ * +-------------------------------------------------------------------------+ -+ * | settimeofday(tv, tz) | -+ * |-------------------------------------------------------------------------| -+ * | Arguments | System Time | TZ | PCIL | | warp_clock | -+ * | tv | tz | set | warped | set | set | firsttime | locked | -+ * |---------|---------|---------------|-----|------|-----------|------------| -+ * | pointer | NULL | yes | no | no | no | 1 | no | -+ * | NULL | ptr2utc | no | no | yes | no | 0 | yes | -+ * | NULL | pointer | no | yes | yes | yes | 0 | yes | -+ * +-------------------------------------------------------------------------+ - * ptr2utc: tz.tz_minuteswest is zero (UTC). - * PCIL: persistent_clock_is_local, sets the "11 minute mode" timescale. - * firsttime: locks the warp_clock function (initialized to 1 at boot). -+ * Since glibc v2.31 settimeofday() will fail if both args are non NULL - * - * +---------------------------------------------------------------------------+ - * | op | RTC scale | settimeofday calls | - * |---------|-----------|-----------------------------------------------------| - * | systz | Local | 1) warps system time*, sets PCIL* and kernel tz | - * | systz | UTC | 1st) locks warp_clock* 2nd) sets kernel tz | -- * | hctosys | Local | 1st) sets PCIL* 2nd) sets system time and kernel tz | -- * | hctosys | UTC | 1) sets system time and kernel tz | -+ * | hctosys | Local | 1st) sets PCIL* & kernel tz 2nd) sets system time | -+ * | hctosys | UTC | 1st) locks warp* 2nd) sets tz 3rd) sets system time | - * +---------------------------------------------------------------------------+ - * * only on first call after boot - */ -@@ -615,41 +615,41 @@ set_system_clock(const struct hwclock_control *ctl, - struct tm broken; - int minuteswest; - int rc = 0; -- const struct timezone tz_utc = { 0 }; - - localtime_r(&newtime.tv_sec, &broken); - minuteswest = -get_gmtoff(&broken) / 60; - - if (ctl->verbose) { -- if (ctl->hctosys && !ctl->universal) -- printf(_("Calling settimeofday(NULL, %d) to set " -- "persistent_clock_is_local.\n"), minuteswest); -- if (ctl->systz && ctl->universal) -+ if (ctl->universal) { - puts(_("Calling settimeofday(NULL, 0) " -- "to lock the warp function.")); -+ "to lock the warp_clock function.")); -+ if (!( ctl->universal && !minuteswest )) -+ printf(_("Calling settimeofday(NULL, %d) " -+ "to set the kernel timezone.\n"), -+ minuteswest); -+ } else -+ printf(_("Calling settimeofday(NULL, %d) to warp " -+ "System time, set PCIL and the kernel tz.\n"), -+ minuteswest); -+ - if (ctl->hctosys) -- printf(_("Calling settimeofday(%ld.%06ld, %d)\n"), -- newtime.tv_sec, newtime.tv_usec, minuteswest); -- else { -- printf(_("Calling settimeofday(NULL, %d) "), minuteswest); -- if (ctl->universal) -- puts(_("to set the kernel timezone.")); -- else -- puts(_("to warp System time.")); -- } -+ printf(_("Calling settimeofday(%ld.%06ld, NULL) " -+ "to set the System time.\n"), -+ newtime.tv_sec, newtime.tv_usec); - } - - if (!ctl->testing) { -+ const struct timezone tz_utc = { 0 }; - const struct timezone tz = { minuteswest }; -- -- if (ctl->hctosys && !ctl->universal) /* set PCIL */ -- rc = settimeofday(NULL, &tz); -- if (ctl->systz && ctl->universal) /* lock warp_clock */ -+ /* If UTC RTC: lock warp_clock and PCIL */ -+ if (ctl->universal) - rc = settimeofday(NULL, &tz_utc); -- if (!rc && ctl->hctosys) -- rc = settimeofday(&newtime, &tz); -- else if (!rc) -+ /* Set kernel tz; if localtime RTC: warp_clock and set PCIL */ -+ if (!rc && !( ctl->universal && !minuteswest )) - rc = settimeofday(NULL, &tz); -+ /* Set the System Clock */ -+ if ((!rc || errno == ENOSYS) && ctl->hctosys) -+ rc = settimeofday(&newtime, NULL); - - if (rc) { - warn(_("settimeofday() failed")); --- -2.27.0 - diff --git a/util-linux.spec b/util-linux.spec index 6e6d996f7d564d921fdc9148d5a9e6e2ab8e245a..9c96a4207525a3128b6476d3e6e61c45ab961637 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,9 +1,8 @@ -%define anolis_release .0.1 ### Header Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 34%{anolis_release}%{?dist} +Release: 35%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -242,11 +241,9 @@ Patch72: 0072-blkid-check-device-type-and-name-before-probe.patch Patch73: 0073-blkid-don-t-print-all-devices-if-only-garbage-specif.patch # 1950187 - Ambient capabilities failed to applied to non-root user even when correct rules are in /etc/security/capability.conf Patch74: 0074-Complete-Linux-PAM-compliance-for-forked-child-in-su.patch +# 2058176 - losetup Retry LOOP_SET_STATUS64 on EAGAIN +Patch75: 0075-lib-loopdev-retry-LOOP_SET_STATUS64-and-LOOP_SET_BLO.patch -# Begin: Anolis customized patches -# hwclock: make glibc 2.31 compatible -Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch -# End: Anolis customized patches %description The util-linux package contains a large variety of low-level system @@ -1112,8 +1109,8 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog -* Wed Apr 20 2022 Weitao Zhou 2.32.1-34.0.1 -- [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 +* Tue Mar 08 2022 Karel Zak 2.32.1-35 +- fix #2058176 - losetup Retry LOOP_SET_STATUS64 on EAGAIN * Mon Jan 17 2022 Karel Zak 2.32.1-34 - rebuild after revert