You are not logged in.

#1 2013-07-28 03:47:05

Bolche
Member
Registered: 2013-07-28
Posts: 10

Problem shutting down with bcache+LUKS+btrfs

Hello all! I've a little problem that I hope someone can help me with.
A have a fresh Arch Install fully upgraded on a Dell Inpiron 15R SE 7520. In this setup, my root partition uses bcache (from kernel 3.10.3-1, not from the AUR package) for SSD caching. On top of bcache I use LUKS and finally on top of all that, btfs.
The setup boots, runs and works, but there is a problem: it won't shutdown.
When I try to shutdown with "halt" or "shutdown -h now" I get:

Detaching DM devices.
Detaching DM 253:0.
Could not detach DM /dev/dm-0: Device or resource busy
Cannot finalize remaining file systems and devices, giving up.
...
[ 1309.417073] mei_me 0000:00:16.0: stop
[ 1341.773926] ata3.00: exception Emask 0x0 SErr 0x0 action 0x6 frozen
[ 1341.773978] ata3.00: cmd a0/00:00:00:08:00/00:00:00:00:00/a0 tag 0 pio 16392 in
[ 1341.773978]              res 40/00:03:00:00:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
[ 1341.774038] ata3.00: status: { DRDY }
[ 1341.811061] ata3: COMRESET failed (errno=-16)
[ 1341.848244] ata3: COMRESET failed (errno=-16)
[ 1341.924857] ata3: COMRESET failed (errno=-16)
[ 1341.943453] ata3: COMRESET failed (errno=-16)
[ 1341.943498] ata3: reset failed, giving up

After that it just stays there, complaining from time to time that "poweroff:857" is blocked for more than 120 seconds and never shutdown if i don't hold the power button.

I'm using the shutdown hook on mkinitcpio. To debug the issue I put "/bin/ash" on /run/initramfs/shutdown and dropped into a shell. In the shell I can't "umount" or "crypsetup luksClose" the root partition, all of them accusing "Device or resource busy", even though lsof says there is nothing using it.

It does not appear to cause any form of file system corruption. I noticed that btrfs identifies the partition as a ssd and automatically mounts with that option, even tough only the cache is ssd. I thought maybe that is the problem, but couldn't find an option to disable btrfs from doing this automagically.

Any help is appreciated.

Offline

#2 2013-07-28 16:01:50

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Problem shutting down with bcache+LUKS+btrfs

Bolche wrote:

all of them accusing "Device or resource busy", even though lsof says there is nothing using it.

Might be a kernel bug. Perhaps dirty pages on the cache device prevent the backing device from being unmounted.

Bolche wrote:

I noticed that btrfs identifies the partition as a ssd and automatically mounts with that option, even tough only the cache is ssd. I thought maybe that is the problem, but couldn't find an option to disable btrfs from doing this automagically.

You should be able to invert the option by passing 'nossd', but this definitely shouldn't be related to the problem.

Offline

#3 2013-07-29 18:00:05

Bolche
Member
Registered: 2013-07-28
Posts: 10

Re: Problem shutting down with bcache+LUKS+btrfs

Thanks for the answer. I'll open a bug report.

Offline

#4 2013-07-31 17:23:56

Bolche
Member
Registered: 2013-07-28
Posts: 10

Re: Problem shutting down with bcache+LUKS+btrfs

I found a workaround. Running:
# echo 0 > /sys/block/bcache0/bcache/writeback_running
before umounting solves the issue (forgot to say I was using bcache in writeback mode).

This makes sense: the disk was being used for writing back. But I shouldn't have to disable it manually. The documentation says this option is for benchmarking only.
Anyway, I could make a patch for the shutdown hook. But I'm not sure where to submit it and whether that's the preferred solution.

Offline

#5 2013-08-07 16:30:18

shanmuha
Member
Registered: 2013-08-07
Posts: 4

Re: Problem shutting down with bcache+LUKS+btrfs

Hi Bolche,
I am also facing the exact same problem, where exactly did you add the last line?
I tried adding it in /usr/lib/initcpio/hooks/shutdown and the recreating the image, it didnot work.

Can you please help?

Thanks,
Shanmu.

Offline

#6 2013-08-07 23:54:57

Bolche
Member
Registered: 2013-07-28
Posts: 10

Re: Problem shutting down with bcache+LUKS+btrfs

You should edit the file /usr/lib/initcpio/shutdown (outside of the "hooks" directory)
On my system I changed this:

...
   [ -e "$part" ] && disassemble "${part%%/*}"
done

for bc in */bcache/writeback_running; do
    echo 0 > $bc
done

case $1 in
    poweroff|shutdown|halt)
...

Comment your setup on bug #36323.

Offline

#7 2013-08-08 21:19:33

shanmuha
Member
Registered: 2013-08-07
Posts: 4

Re: Problem shutting down with bcache+LUKS+btrfs

Hi,
I have edited and it did not work.
I added some print statements and they never got printed as well.
I have the shutdown hook in my mkinitcpio.conf and have regenerated the init image after this change.

Is there something that needs to be done to make this code run during shutdown?

I tried poweroff, reboot and shutdown to no avail.

Thanks,
Shanmu.

Offline

#8 2013-08-08 21:28:14

Bolche
Member
Registered: 2013-07-28
Posts: 10

Re: Problem shutting down with bcache+LUKS+btrfs

Try to put /bin/ash somewhere in /run/initramfs/shutdown. This will drop you on a shell when shutdown. If this does not happens, then systemd is hanging and it's a different bug.

Offline

#9 2013-08-09 17:15:02

Bolche
Member
Registered: 2013-07-28
Posts: 10

Re: Problem shutting down with bcache+LUKS+btrfs

From the bug comment, I take that it didn't solve. What happens?

Offline

#10 2013-08-10 10:11:31

shanmuha
Member
Registered: 2013-08-07
Posts: 4

Re: Problem shutting down with bcache+LUKS+btrfs

I donot have a /run/initramfs/shutdown, I am not sure if the mkinitcpio is including the shutdown hook?

Offline

#11 2013-08-10 11:25:10

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Problem shutting down with bcache+LUKS+btrfs

I would strongly advise against modifying the shutdown hook. Something like this is better suited to tmpfiles.d.

Offline

Board footer

Powered by FluxBB