Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
This is nothing unusual, if there is some reader of the loop device than kernel does not destroy the device, but mark by LO_FLAGS_AUTOCLEAR. The device will be
detached later when reference counting will be zero.
As you can see from the strace than
ioctl(3, LOOP_CLR_FD) = 0
kernel returns success, in this case losetup cannot do anything more.
man losetup (upstream):
-d, --detach loopdev...
Detach the file or device associated with the specified loop device(s). Note that since Linux v3.7 kernel uses "lazy device destruction". The detach operation does not
return EBUSY error anymore if device is actively used by system, but it is marked by autoclear flag and destroyed later.
Maybe we can add this note to RHEL7.6 too.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2018:3178
Description of problem: [RHEL-7.5] losetup can not detach all loop devices Version-Release number of selected component (if applicable): util-linux-2.23.2-52.el7.x86_64 How reproducible: often Steps to Reproduce: 1. losetup /dev/loopx -f /tmp/tfile_loopx 2. losetup -d 3. losetup -a Actual results: # losetup --all /dev/loop0: [64768]:1001699 (/tmp/tfile_loop0) /dev/loop2: [64768]:1001699 (/tmp/tfile_loop0) /dev/loop8: [64768]:1001681 (/tmp/tfile_loop1) # losetup -D # losetup --all /dev/loop0: [64768]:1001699 (/tmp/tfile_loop0) /dev/loop2: [64768]:1001699 (/tmp/tfile_loop0) # strace losetup -d /dev/loop2 execve("/usr/sbin/losetup", ["losetup", "-d", "/dev/loop2"], [/* 39 vars */]) = 0 brk(NULL) = 0x1f88000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f72200dc000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44171, ...}) = 0 mmap(NULL, 44171, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f72200d1000 close(3) = 0 open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340$\2\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=2151832, ...}) = 0 mmap(NULL, 3981792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f721faef000 mprotect(0x7f721fcb2000, 2093056, PROT_NONE) = 0 mmap(0x7f721feb1000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c2000) = 0x7f721feb1000 mmap(0x7f721feb7000, 16864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f721feb7000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f72200d0000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f72200ce000 arch_prctl(ARCH_SET_FS, 0x7f72200ce740) = 0 mprotect(0x7f721feb1000, 16384, PROT_READ) = 0 mprotect(0x611000, 4096, PROT_READ) = 0 mprotect(0x7f72200dd000, 4096, PROT_READ) = 0 munmap(0x7f72200d1000, 44171) = 0 brk(NULL) = 0x1f88000 brk(0x1fa9000) = 0x1fa9000 brk(NULL) = 0x1fa9000 open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0 mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f72195c6000 close(3) = 0 stat("/sys/block", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 uname({sysname="Linux", nodename="storageqe-52.rhts.eng.pek2.redhat.com", ...}) = 0 stat("/dev/loop-control", {st_mode=S_IFCHR|0660, st_rdev=makedev(10, 237), ...}) = 0 open("/dev/loop2", O_RDONLY|O_CLOEXEC) = 3 ioctl(3, LOOP_CLR_FD) = 0 close(3) = 0 close(1) = 0 close(2) = 0 exit_group(0) = ? +++ exited with 0 +++ # losetup --all /dev/loop0: [64768]:1001699 (/tmp/tfile_loop0) /dev/loop2: [64768]:1001699 (/tmp/tfile_loop0) Expected results: Additional info: