From: Franck Bui Date: Thu, 25 Jan 2024 08:53:21 +0000 (+0100) Subject: loop-util: drop unused .uevent_seqnum_not_before and .timestamp_not_before fields X-Git-Tag: v256-rc1~1042 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ba1816dfe747199cd30c95476ec354240397f69;p=thirdparty%2Fsystemd.git loop-util: drop unused .uevent_seqnum_not_before and .timestamp_not_before fields --- diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index 8434587286c..c6dfff43197 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -57,21 +57,6 @@ static int loop_is_bound(int fd) { return true; /* bound! */ } -static int get_current_uevent_seqnum(uint64_t *ret) { - _cleanup_free_ char *p = NULL; - int r; - - r = read_full_virtual_file("/sys/kernel/uevent_seqnum", &p, NULL); - if (r < 0) - return log_debug_errno(r, "Failed to read current uevent sequence number: %m"); - - r = safe_atou64(strstrip(p), ret); - if (r < 0) - return log_debug_errno(r, "Failed to parse current uevent sequence number: %s", p); - - return 0; -} - static int open_lock_fd(int primary_fd, int operation) { _cleanup_close_ int lock_fd = -EBADF; @@ -266,8 +251,7 @@ static int loop_configure( _cleanup_(cleanup_clear_loop_close) int loop_with_fd = -EBADF; /* This must be declared before lock_fd. */ _cleanup_close_ int fd = -EBADF, lock_fd = -EBADF; _cleanup_free_ char *node = NULL; - uint64_t diskseq = 0, seqnum = UINT64_MAX; - usec_t timestamp = USEC_INFINITY; + uint64_t diskseq = 0; dev_t devno; int r; @@ -327,18 +311,6 @@ static int loop_configure( "Removed partitions on the loopback block device."); if (!loop_configure_broken) { - /* Acquire uevent seqnum immediately before attaching the loopback device. This allows - * callers to ignore all uevents with a seqnum before this one, if they need to associate - * uevent with this attachment. Doing so isn't race-free though, as uevents that happen in - * the window between this reading of the seqnum, and the LOOP_CONFIGURE call might still be - * mistaken as originating from our attachment, even though might be caused by an earlier - * use. But doing this at least shortens the race window a bit. */ - r = get_current_uevent_seqnum(&seqnum); - if (r < 0) - return log_device_debug_errno(dev, r, "Failed to get the current uevent seqnum: %m"); - - timestamp = now(CLOCK_MONOTONIC); - if (ioctl(fd, LOOP_CONFIGURE, c) < 0) { /* Do fallback only if LOOP_CONFIGURE is not supported, propagate all other * errors. Note that the kernel is weird: non-existing ioctls currently return EINVAL @@ -370,13 +342,6 @@ static int loop_configure( } if (loop_configure_broken) { - /* Let's read the seqnum again, to shorten the window. */ - r = get_current_uevent_seqnum(&seqnum); - if (r < 0) - return log_device_debug_errno(dev, r, "Failed to get the current uevent seqnum: %m"); - - timestamp = now(CLOCK_MONOTONIC); - if (ioctl(fd, LOOP_SET_FD, c->fd) < 0) return log_device_debug_errno(dev, errno, "ioctl(LOOP_SET_FD) failed: %m"); @@ -423,8 +388,6 @@ static int loop_configure( .devno = devno, .dev = TAKE_PTR(dev), .diskseq = diskseq, - .uevent_seqnum_not_before = seqnum, - .timestamp_not_before = timestamp, .sector_size = c->block_size, .device_size = device_size, .created = true, @@ -986,8 +949,6 @@ int loop_device_open( .relinquished = true, /* It's not ours, don't try to destroy it when this object is freed */ .devno = devnum, .diskseq = diskseq, - .uevent_seqnum_not_before = UINT64_MAX, - .timestamp_not_before = USEC_INFINITY, .sector_size = sector_size, .device_size = device_size, .created = false, diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h index 94357bba717..4f563172b6d 100644 --- a/src/shared/loop-util.h +++ b/src/shared/loop-util.h @@ -26,8 +26,6 @@ struct LoopDevice { dev_t backing_devno; /* The backing file's dev_t */ ino_t backing_inode; /* The backing file's ino_t */ uint64_t diskseq; /* Block device sequence number, monothonically incremented by the kernel on create/attach, or 0 if we don't know */ - uint64_t uevent_seqnum_not_before; /* uevent sequm right before we attached the loopback device, or UINT64_MAX if we don't know */ - usec_t timestamp_not_before; /* CLOCK_MONOTONIC timestamp taken immediately before attaching the loopback device, or USEC_INFINITY if we don't know */ uint32_t sector_size; uint64_t device_size; };