[dm-crypt] force luksClose

yac yac at blesmrt.net
Sun Nov 29 19:42:15 CET 2015


Hello

I believe I have the same problem as described here:
http://comments.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/6250

Here are the last requested commands:

# dmsetup table dlt
0 4096 crypt aes-xts-plain64 0000000000000000000000000000000000000000000000000000000000000000 0 254:8 4096
# dmsetup info -c dlt
Name             Maj Min Stat Open Targ Event  UUID                                            
dlt              254   9 L--w    1    1      0 CRYPT-LUKS1-731df69c78e94882982899390c71bb3b-dlt
# lsblk 
lsblk: dm-0: failed to get device path
lsblk: dm-0: failed to get device path
NAME                MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda                   8:0    0  1.8T  0 disk  
└─sda1                8:1    0  1.8T  0 part  
sdb                   8:16   0  2.7T  0 disk  
└─sdb1                8:17   0  2.7T  0 part  
sdc                   8:32   0  2.7T  0 disk  
└─sdc1                8:33   0  2.7T  0 part  
sdd                   8:48   0  2.7T  0 disk  
└─sdd1                8:49   0  2.7T  0 part  
sde                   8:64   0  2.7T  0 disk  
└─sde1                8:65   0  2.7T  0 part  
sdf                   8:80   0  1.8T  0 disk  
sdg                   8:96   1  3.8G  0 disk  
└─sdg1                8:97   1  3.8G  0 part  
loop8                 7:8    0   10M  0 loop  
├─lt-lvol0_rmeta_0  254:4    0    4M  0 lvm   
│ └─lt-lvol0        254:8    0    4M  0 lvm   
│   └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt
└─lt-lvol0_rimage_0 254:5    0   12M  0 lvm   
  └─lt-lvol0        254:8    0    4M  0 lvm   
    └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt
loop9                 7:9    0   10M  0 loop  
├─lt-lvol0_rmeta_1  254:6    0    4M  0 lvm   
│ └─lt-lvol0        254:8    0    4M  0 lvm   
│   └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt
└─lt-lvol0_rimage_1 254:7    0   12M  0 lvm   
  └─lt-lvol0        254:8    0    4M  0 lvm   
    └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt
loop10                7:10   0   10M  0 loop  
└─lt-lvol0_rimage_0 254:5    0   12M  0 lvm   
  └─lt-lvol0        254:8    0    4M  0 lvm   
    └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt
loop11                7:11   0   10M  0 loop  
└─lt-lvol0_rimage_1 254:7    0   12M  0 lvm   
  └─lt-lvol0        254:8    0    4M  0 lvm   
    └─dlt           254:9    0    2M  0 crypt /root/lvm-crypt-test/mnt



This happened to me after I was trying out lvm and then crypt on top
lvm. First, let's have a workspace

# cd /root; mkdir lvm-crypt-test; cd lvm-crypt-test

Fake some block devs

# mknod /dev/lta b 7 8
# mknod /dev/ltb b 7 9
# mknod /dev/ltc b 7 10 
# mknod /dev/ltd b 7 11
# for i in a b c d; do fallocate -l 10M sd$i; losetup /dev/lt$i sd$i; done

Make an LVM raid1

# pvcreate /dev/lt{a,b,c,d}
# vgcreate lt /dev/lt{a,b,c,d}
# lvcreate -m1 -l 100%VG lt /dev/lt{a,b}

Encrypt it

# echo "aaa" > key
# cryptsetup luksFormat /dev/lt/lvol0 -d key

Format and mount

# cryptsetup luksOpen /dev/lt/lvol0 -d key dlt
# mkfs.ext4 /dev/mapper/dlt
# mkdir ./mnt; mount /dev/mapper/dlt ./mnt

Now comes the part where I broke it

# lvextend /dev/lt/lvol0 /dev/lt{c,d} -l 100%VG

I tried to umount mnt but it got stuck in uninterruptible sleep. But
umount -l worked for me.

# cat /proc/mounts  | grep dlt
# cat /proc/mounts  | grep mnt
# 

But I am not able to anything about dlt and the underlying devices. Not
even turn the system off normally as that gets stuck on sync().

# ps auxf | grep D
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     15193  0.0  0.0  27488  4436 ?        D    01:03   0:00 lvs
root     15196  0.0  0.0  27472  4432 ?        D    01:04   0:00 lvdisplay
root     15201  0.0  0.0  12612  2300 ?        D    01:04   0:00 umount mnt/
root     15237  0.0  0.0  12564  1740 ?        D    01:06   0:00 shutdown -h 0 w
root     15372  0.0  0.0   5840   748 ?        D    01:12   0:00 sync
root     17287  0.0  0.0   4016   640 ?        D    01:50   0:00 /sbin/reboot -f
root     17296  0.0  0.0  12576  2512 ?        D    01:51   0:00 dmsetup remove -f dlt
root     25471  0.0  0.0  27480  4532 ?        D    02:05   0:00 lvchange -an /dev/lt/lvol0
root     25529  0.0  0.0  24008  5576 ?        D<L  02:15   0:00 cryptsetup luksClose dlt
root     26114  0.0  0.0  24008  5576 ?        D<L  03:21   0:00 cryptsetup loopaesClose dlt

# lsof /root/lvm-crypt-test/mnt/
# fuser /root/lvm-crypt-test/mnt/
# find /proc/ -maxdepth 2 -type l -name cwd -exec readlink {} \; | sort | uniq
/
/proc/26289
/root
/root/lvm-crypt-test
/sys


Luckily I was able to umount and luksClose all the real block devices
there and now it appears my only option is to go pull the plug.

Best regards
Jan Matejka


More information about the dm-crypt mailing list