Modify

Opened 4 years ago

Last modified 2 years ago

#12043 reopened defect

USB block device hotplug action for removal (umount) does not work

Reported by: hnyman Owned by: developers
Priority: normal Milestone: Barrier Breaker 14.07
Component: base system Version: Trunk
Keywords: USB hotplug umount Cc: hannu.nyman@…

Description

I have in the past few weeks noticed that removing and reattaching an USB memory stick does not always work. After removing the stick, there may still be item for it in 'df' output or in /proc/self/mountinfo, and system log may start to show block device related errors:

Aug 19 20:44:18 OpenWrt kern.err kernel: [ 4506.610000] FAT-fs (sda1): FAT read failed (blocknr 992)
Aug 19 20:44:43 OpenWrt kern.err kernel: [ 4531.410000] FAT-fs (sda1): FAT read failed (blocknr 992)

Removing a stick used to work well in the past.

I investigated a bit and it looks like the current util-linux umount does not work well when the device name is used, but works when the directory name is used. Hotplug script uses the device name (https://dev.openwrt.org/browser/trunk/package/block-mount/files/40-mount#L84 ).

util-linux was updated about 2 months ago: https://dev.openwrt.org/log/trunk/package/util-linux

There is already ticket #11618 talking about display issues shown also in my logs, but I have been no other tickets.

I am wondering if this is a generic incompatibity between current 3.3.8 and util-linux tools, or impact from the netifd/ubus etc. changes or something specific to my device config.

root@OpenWrt:~# logger "ATTACHING USB STICK"
root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                   10688       536     10152   5% /
/dev/root                 4352      4352         0 100% /rom
tmpfs                    30976       488     30488   2% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock4           10688       536     10152   5% /overlay
overlayfs:/overlay       10688       536     10152   5% /
/dev/sda1              3940288     43820   3896468   1% /mnt
root@OpenWrt:~# cat /proc/self/mountinfo
11 19 31:3 / /rom ro,relatime - squashfs /dev/root ro
12 19 0:3 / /proc rw,noatime - proc proc rw
13 19 0:11 / /sys rw,noatime - sysfs sysfs rw
14 19 0:12 / /tmp rw,nosuid,nodev,noatime - tmpfs tmpfs rw
15 19 0:13 / /dev rw,noatime - tmpfs tmpfs rw,size=512k,mode=755
16 15 0:9 / /dev/pts rw,noatime - devpts devpts rw,mode=600
17 19 31:4 / /overlay rw,noatime - jffs2 /dev/mtdblock4 rw
19 1 0:15 / / rw,relatime - overlayfs overlayfs:/overlay rw,lowerdir=/,upperdir=/overlay
22 13 0:6 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
23 12 0:14 / /proc/bus/usb rw,relatime - usbfs none rw
24 19 8:1 / /mnt rw,relatime - vfat /dev/sda1 rw,sync,fmask=0022,dmask=0022,codepage=cp437...


root@OpenWrt:~# which umount
/bin/umount

root@OpenWrt:~# umount -V
umount from util-linux 2.21.2 (libmount 2.21.0: debug)

root@OpenWrt:~# logger "REMOVING USB STICK"
root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                   10688       536     10152   5% /
/dev/root                 4352      4352         0 100% /rom
tmpfs                    30976       488     30488   2% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock4           10688       536     10152   5% /overlay
overlayfs:/overlay       10688       536     10152   5% /
/dev/sda1              3940288     43820   3896468   1% /mnt
root@OpenWrt:~# cat /proc/self/mountinfo
11 19 31:3 / /rom ro,relatime - squashfs /dev/root ro
12 19 0:3 / /proc rw,noatime - proc proc rw
13 19 0:11 / /sys rw,noatime - sysfs sysfs rw
14 19 0:12 / /tmp rw,nosuid,nodev,noatime - tmpfs tmpfs rw
15 19 0:13 / /dev rw,noatime - tmpfs tmpfs rw,size=512k,mode=755
16 15 0:9 / /dev/pts rw,noatime - devpts devpts rw,mode=600
17 19 31:4 / /overlay rw,noatime - jffs2 /dev/mtdblock4 rw
19 1 0:15 / / rw,relatime - overlayfs overlayfs:/overlay rw,lowerdir=/,upperdir=/overlay
22 13 0:6 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
23 12 0:14 / /proc/bus/usb rw,relatime - usbfs none rw
24 19 8:1 / /mnt rw,relatime - vfat /dev/sda1 rw,sync,fmask=0022,dmask=0022,codepage=cp437...

AFTER HOTPLUG ACTION IT IS STILL THERE.
LETS TRY MANUAL UMOUNT FOR /dev/sda1

root@OpenWrt:~# umount /dev/sda1
umount: /proc/self/mountinfo: parse error: ignore entry at line 1.
umount: /proc/self/mountinfo: parse error: ignore entry at line 2.
umount: /proc/self/mountinfo: parse error: ignore entry at line 3.
umount: /proc/self/mountinfo: parse error: ignore entry at line 4.
umount: /proc/self/mountinfo: parse error: ignore entry at line 5.
umount: /proc/self/mountinfo: parse error: ignore entry at line 6.
umount: /proc/self/mountinfo: parse error: ignore entry at line 7.
umount: /proc/self/mountinfo: parse error: ignore entry at line 8.
umount: /proc/self/mountinfo: parse error: ignore entry at line 9.
umount: /proc/self/mountinfo: parse error: ignore entry at line 10.
umount: /proc/self/mountinfo: parse error: ignore entry at line 11.
umount: /dev/sda1: not found
root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                   10688       536     10152   5% /
/dev/root                 4352      4352         0 100% /rom
tmpfs                    30976       488     30488   2% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock4           10688       536     10152   5% /overlay
overlayfs:/overlay       10688       536     10152   5% /
/dev/sda1              3940288     43820   3896468   1% /mnt
root@OpenWrt:~# cat /proc/self/mountinfo
11 19 31:3 / /rom ro,relatime - squashfs /dev/root ro
12 19 0:3 / /proc rw,noatime - proc proc rw
13 19 0:11 / /sys rw,noatime - sysfs sysfs rw
14 19 0:12 / /tmp rw,nosuid,nodev,noatime - tmpfs tmpfs rw
15 19 0:13 / /dev rw,noatime - tmpfs tmpfs rw,size=512k,mode=755
16 15 0:9 / /dev/pts rw,noatime - devpts devpts rw,mode=600
17 19 31:4 / /overlay rw,noatime - jffs2 /dev/mtdblock4 rw
19 1 0:15 / / rw,relatime - overlayfs overlayfs:/overlay rw,lowerdir=/,upperdir=/overlay
22 13 0:6 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
23 12 0:14 / /proc/bus/usb rw,relatime - usbfs none rw
24 19 8:1 / /mnt rw,relatime - vfat /dev/sda1 rw,sync,fmask=0022,dmask=0022,codepage=cp437...

...STILL THERE.
LETS TRY MANUAL UMOUNT FOR /mnt

root@OpenWrt:~# umount /mnt
umount: /proc/self/mountinfo: parse error: ignore entry at line 1.
umount: /proc/self/mountinfo: parse error: ignore entry at line 2.
umount: /proc/self/mountinfo: parse error: ignore entry at line 3.
umount: /proc/self/mountinfo: parse error: ignore entry at line 4.
umount: /proc/self/mountinfo: parse error: ignore entry at line 5.
umount: /proc/self/mountinfo: parse error: ignore entry at line 6.
umount: /proc/self/mountinfo: parse error: ignore entry at line 7.
umount: /proc/self/mountinfo: parse error: ignore entry at line 8.
umount: /proc/self/mountinfo: parse error: ignore entry at line 9.
umount: /proc/self/mountinfo: parse error: ignore entry at line 10.
umount: /proc/self/mountinfo: parse error: ignore entry at line 11.
root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                   10688       536     10152   5% /
/dev/root                 4352      4352         0 100% /rom
tmpfs                    30976       488     30488   2% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock4           10688       536     10152   5% /overlay
overlayfs:/overlay       10688       536     10152   5% /
root@OpenWrt:~# cat /proc/self/mountinfo
11 19 31:3 / /rom ro,relatime - squashfs /dev/root ro
12 19 0:3 / /proc rw,noatime - proc proc rw
13 19 0:11 / /sys rw,noatime - sysfs sysfs rw
14 19 0:12 / /tmp rw,nosuid,nodev,noatime - tmpfs tmpfs rw
15 19 0:13 / /dev rw,noatime - tmpfs tmpfs rw,size=512k,mode=755
16 15 0:9 / /dev/pts rw,noatime - devpts devpts rw,mode=600
17 19 31:4 / /overlay rw,noatime - jffs2 /dev/mtdblock4 rw
19 1 0:15 / / rw,relatime - overlayfs overlayfs:/overlay rw,lowerdir=/,upperdir=/overlay
22 13 0:6 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
23 12 0:14 / /proc/bus/usb rw,relatime - usbfs none rw
root@OpenWrt:~#

FINALLY IT GETS REMOVED

System log shows the extra log line (user.notice root: umount /dev/sda1) about the hotplug action, as I added logging to the hotplug script to see if the hotplug gets properly. But there is no error or anything about the failed umount action.

Aug 19 20:47:17 OpenWrt user.notice root: ATTACHING USB STICK
Aug 19 20:47:21 OpenWrt kern.info kernel: [ 4690.100000] usb 1-1: new high-speed USB device number 15 using ehci-platform
Aug 19 20:47:21 OpenWrt kern.info kernel: [ 4690.250000] scsi13 : usb-storage 1-1:1.0
Aug 19 20:47:22 OpenWrt kern.notice kernel: [ 4691.260000] scsi 13:0:0:0: Direct-Access     Pretec   UltimateGuard    2.00 PQ: 0 ANSI: 2
Aug 19 20:47:22 OpenWrt kern.notice kernel: [ 4691.270000] sd 13:0:0:0: [sda] 7897088 512-byte logical blocks: (4.04 GB/3.76 GiB)
Aug 19 20:47:22 OpenWrt kern.notice kernel: [ 4691.280000] sd 13:0:0:0: [sda] Write Protect is off
Aug 19 20:47:22 OpenWrt kern.debug kernel: [ 4691.280000] sd 13:0:0:0: [sda] Mode Sense: 00 00 00 00
Aug 19 20:47:22 OpenWrt kern.err kernel: [ 4691.280000] sd 13:0:0:0: [sda] Asking for cache data failed
Aug 19 20:47:22 OpenWrt kern.err kernel: [ 4691.290000] sd 13:0:0:0: [sda] Assuming drive cache: write through
Aug 19 20:47:22 OpenWrt kern.err kernel: [ 4691.300000] sd 13:0:0:0: [sda] Asking for cache data failed
Aug 19 20:47:22 OpenWrt kern.err kernel: [ 4691.310000] sd 13:0:0:0: [sda] Assuming drive cache: write through
Aug 19 20:47:23 OpenWrt kern.info kernel: [ 4691.480000]  sda: sda1
Aug 19 20:47:23 OpenWrt kern.err kernel: [ 4691.650000] sd 13:0:0:0: [sda] Asking for cache data failed
Aug 19 20:47:23 OpenWrt kern.err kernel: [ 4691.660000] sd 13:0:0:0: [sda] Assuming drive cache: write through
Aug 19 20:47:23 OpenWrt kern.notice kernel: [ 4691.670000] sd 13:0:0:0: [sda] Attached SCSI removable disk

Aug 19 20:48:16 OpenWrt user.notice root: REMOVING USB STICK
Aug 19 20:48:22 OpenWrt kern.info kernel: [ 4750.620000] usb 1-1: USB disconnect, device number 15
Aug 19 20:48:22 OpenWrt user.notice root: umount /dev/sda1

Attachments (0)

Change History (6)

comment:1 Changed 4 years ago by hnyman <hannu.nyman@…>

#12056 talks about the same issue with other words:

Plug in the USB stick and it will come up as /dev/sda. The issue is when unplugging it and plugging it back in, instead of going back to /dev/sda, /dev/sdb is created. This breaks automounting and therefore the automatic use the the USB drive.

comment:2 Changed 4 years ago by hnyman <hannu.nyman@…>

This should be fixed with r33357

comment:3 Changed 4 years ago by jow

  • Resolution set to fixed
  • Status changed from new to closed

comment:4 Changed 2 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:5 Changed 2 years ago by anonymous

I am using WD passport drive for some media stuff to share on router. But it happens that after 1 day it just switches from /dev/sda to /dev/sdb. I don't know if its something wrong with my drive.

comment:6 Changed 2 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as reopened .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.