Bug 1480006

Summary: noisy "remove ioctl failed" messages when attempting to luksClose a still mounted device
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: cryptsetupAssignee: Ondrej Kozina <okozina>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.4CC: agk, mbroz, okozina, prajnoha
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: cryptsetup-1.7.4-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 16:38:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Corey Marthaler 2017-08-09 22:18:47 UTC
Description of problem:

[root@host-093 ~]# cryptsetup -v status virt2_luksvolume
/dev/mapper/virt2_luksvolume is active and is in use.
  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 256 bits
  device:  /dev/mapper/snapper_thinp-online_resize
  offset:  4096 sectors
  size:    2093056 sectors
  mode:    read/write
Command successful.

[root@host-093 ~]# mount
/dev/mapper/virt2_luksvolume on /mnt/snap1 type ext4 (rw,relatime,seclabel,stripe=32,data=ordered)

[root@host-093 ~]# cryptsetup luksClose virt2_luksvolume 
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
device-mapper: remove ioctl on virt2_luksvolume  failed: Device or resource busy
Device virt2_luksvolume is still in use.

[root@host-093 ~]# umount /mnt/snap1
[root@host-093 ~]# cryptsetup luksClose virt2_luksvolume


Version-Release number of selected component (if applicable):
3.10.0-693.el7.x86_64

cryptsetup-1.7.4-3.el7   BUILT: Tue 25 Apr 2017 10:08:30 AM CDT
lvm2-2.02.171-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
lvm2-libs-2.02.171-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
lvm2-cluster-2.02.171-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
device-mapper-1.02.140-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
device-mapper-libs-1.02.140-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
device-mapper-event-1.02.140-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
device-mapper-event-libs-1.02.140-8.el7    BUILT: Wed Jun 28 13:28:58 CDT 2017
device-mapper-persistent-data-0.7.0-0.1.rc6.el7    BUILT: Mon Mar 27 10:15:46 CDT 2017


How reproducible:
Everytime

Comment 2 Milan Broz 2017-08-10 07:17:21 UTC
> /dev/mapper/virt2_luksvolume is active and is in use.

If you see "in use" in this status, it means that device-mapper open count is not zero. So something still keeps it open (mapped device, filesystem)...

Please paste lsblk -f or similar command that shows what it is...

Cryptsetup cannot remove open devices, messages are just consequence of repeated tries to remove the device (and these are kernel messages - not sure why we print them in fact, should'n be be debug only?...)

Comment 3 Corey Marthaler 2017-08-10 17:57:04 UTC
This bug is only about removing those ioctl errors when still in use. The "Device virt2_luksvolume is still in use." should be all that needs to be printed.

Comment 4 Milan Broz 2017-08-10 18:18:51 UTC
Ah, ok. This is actually error message (error level) from device mapper library.

You can get exactly the same errors when running
  dmsetup remove --retry virt2_luksvolume

I am not sure if I should hide these messages in cryptsetup. I would prefer libdevmapper to print them in debug level (not _LOG_ERR) with the last unsuccessful message in error level.

Comment 5 Zdenek Kabelac 2017-08-14 11:32:16 UTC
lvm2 detects  in-use device.

See  lvm2 source code function lib/activate/actviate.c  lv_check_not_in_use()
for full details to avoid trying to remove device in-use
(and print nice messages instead).

It does call 2 libdm API calls:

dm_device_has_holders()
dm_device_has_mounted_fs()

so in the end this 'retry' is ONLY used when there is some kind of very unlikely race with udev WATCH rule.

Comment 9 Corey Marthaler 2017-10-26 14:29:04 UTC
Fix verified in the latest build.

cryptsetup-1.7.4-4.el7.x86_64 Built: Thu 19 Oct 2017 08:44:30 AM CDT


[root@host-005 ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/raid_luksvolume      5.9G  5.9G     0 100% /mnt/open_LUKS_fsadm_resize

[root@host-005 ~]# cryptsetup -v status raid_luksvolume
/dev/mapper/raid_luksvolume is active and is in use.
  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 256 bits
  device:  /dev/mapper/raid_sanity-open_LUKS_fsadm_resize
  offset:  4096 sectors
  size:    12578816 sectors
  mode:    read/write
Command successful.

[root@host-005 ~]# cryptsetup luksClose raid_luksvolume
Device raid_luksvolume is still in use.

Comment 12 errata-xmlrpc 2018-04-10 16:38:50 UTC
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:0915