Skip to contentSkip to conversation

Why is my block device busy?

DISCUSSION Adam Trhon 2 participants 3 messages Jan 21, 2020 – Jan 24, 2020

lore
Share & tools
lore

Adam Trhon

author
#0 lore raw

Hello,

I have an embedded x86 machine with Linux 5.2.21. The system is built using OpenEmbedded. When I update the machine from a live USB (/dev/sda), I override the whole internal memory (/dev/mmcblk1), and then I get this error:

fdisk: WARNING: rereading partition table failed, kernel still uses old table: Device or resource busy

(I use fdisk for notifying kernel about the changes).

To find out where it is mounted I run

mount | grep mmc

before overwriting /dev/mmcblk1, but it prints nothing. So I run

dmesg | grep mmc

and I see this:

(... a lot of kernel prints ...)
Freeing unused kernel image memory: 1000K
Write protecting kernel text and read-only data: 14468k NX-protecting the kernel data: 7000k
Run /init as init process
EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null) (... a lot of kernel prints ...)

Next I modified the ext driver to print stack when mounting, and I got:

Call Trace:
 ? ext4_calculate_overhead+0x520/0x520
 mount_bdev+0x15a/0x180
 ? mount_bdev+0x15a/0x180
 ? ext4_nfs_get_inode+0x50/0x50
 ext4_mount+0x15/0x20
 ? ext4_calculate_overhead+0x520/0x520
 legacy_get_tree+0x22/0x50
 vfs_get_tree+0x24/0xe0
 do_mount+0x5e3/0x880
 ksys_mount+0xa1/0xb0
 sys_mount+0x1c/0x20
 do_fast_syscall_32+0x82/0x230
 entry_SYSENTER_32+0x6b/0xbe

but I don't see anything that makes sense to me. What causes the device to be busy?

Thank you
Adam

Signature · 8 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz
_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
#1 lore raw
Quoted 1 line · Adam Trhon

mount | grep mmc

You might want to dump the *entire* output of the mount command, and see if something is mounted via an alias or devmapper entry, or if you're using busybox and getting a stripped-down mount output.

You should also check with 'cat /proc/mounts'.

Quoted 1 line

EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)

Looks like something did mount a filesystem on the device. You probably should figure out who/what did it before you scribble on the device.

Quoted 5 lines

Next I modified the ext driver to print stack when mounting, and I got:

Call Trace:
 ? ext4_calculate_overhead+0x520/0x520
 mount_bdev+0x15a/0x180

Looks like what I'd expect to see when in the mount syscall. What were you expecting to see here?

If you're trying to figure out who did the mount, the kernel stack trace probably won't help.

More often, you'll need to resort to something like this:

mv /bin/mount /bin/mount.real

cat > /bin/mount
#!/bin/sh
ps lax
exec /bin/mount.real $*
^D

chmod +x /bin/mount

and then look at the parent process chain of the call in the ps output.

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

author
#2 lore raw

Hello,

thank you, I figured out that the partition is mounted in initramfs and not unmounted before the main system is started. When I manually unmount the partition in initramfs, the problem goes away.

Quoted 1 line · On Tue, 21 Jan 2020 12:50:41 -0500 "Valdis Klētnieks"…

You should also check with 'cat /proc/mounts'.

I checked and it is not there.

Quoted 8 lines
Quoted 5 lines

Next I modified the ext driver to print stack when mounting, and I got:

Call Trace:
 ? ext4_calculate_overhead+0x520/0x520
 mount_bdev+0x15a/0x180  

Looks like what I'd expect to see when in the mount syscall. What were you expecting to see here?

I expected the mount to be done by kernel itself, as I forgot about initramfs, and that the stack trace would point me to the procedure that does it in the kernel. Wrong guess :)

One more question, since I have another project that seldomly behaves similarly, and I have had no luck with diagnostics so far. Is there a way how to detect this problem (partition mounted, but not shown in /proc/mounts) from the main system?

Thank you and best regards
Adam

Signature · 8 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz
_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies