Opened 2 months ago

Last modified 2 months ago

#19105 closed bug

FAT: KDLs on device removal without unmount — at Version 23

Reported by: Catmengi Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: File Systems/FAT Version: R1/beta5
Keywords: r1beta5-fixes Cc: Jim906
Blocked By: Blocking:
Platform: All

Description (last modified by Catmengi)

After disconnecting pen drive it leaves phantom /dev/disk/usb/* node. Partition isn't unmounting which leads to "general protection exception" 0x0 Tested on: x64 laptop (i3 6006u "acer travelmate p259")

Steps to recreate: connect pendrive, let haiku mount partition, disconnect pendrive, /dev/disk/usb/* will stay. If you didn't open mounted partition before and try to open it you will have kernel panic(at least in gui)

FAT driver possible not catch some kind of "detach" event for unmounting. Or it dont have proper checks for existence of the mounted device. beFs handle this properly and unmounts when usb is detached

Change History (25)

by Catmengi, 2 months ago

Attachment: IMG_20240917_142227.jpg added

Panic log

comment:1 by Catmengi, 2 months ago

Description: modified (diff)

comment:2 by Catmengi, 2 months ago

Description: modified (diff)

comment:3 by waddlesplash, 2 months ago

Component: DriversFile Systems/FAT
Priority: highnormal

If you didn't Unmount/"Eject" before disconnecting the pendrive, then some misbehavior is expected because there may be writes that weren't flushed to the disk, and you may get data loss. The system shouldn't crash, of course, but disconnecting disks without unmounting them isn't good behavior regardless.

comment:4 by Catmengi, 2 months ago

Note that crash is going even without writing anything to it. It crashes on attempt to read this phantom device

comment:5 by Catmengi, 2 months ago

Also phantom /dev/disk/usb nodes is quite bad for tty users (and maybe system)

comment:6 by waddlesplash, 2 months ago

The "phantom nodes" should go away if you unmount the disk properly before removing it. If you don't mount the device at all after plugging it in, they should also go away when you remove it in that case too.

comment:7 by Catmengi, 2 months ago

Attempt to open right click button leads to gui freeze, then kernel panic. I'll add an attachment

by Catmengi, 2 months ago

comment:8 by waddlesplash, 2 months ago

This is with the disk still inserted?

comment:9 by Catmengi, 2 months ago

Without. With inserted is everything ok, BUT /dev/disk/usb/* still exist

comment:10 by Catmengi, 2 months ago

NEW INFO: device nodes is deleting but /dev/disk/usb/* is not deleted

comment:11 by Catmengi, 2 months ago

Additional info: partition disappeared now, in 5 seconds ± but /dev path still exists, kernel's device nodes in this path is deleted

comment:12 by waddlesplash, 2 months ago

I would expect the /dev file to disappear only after both unmount and then removal of the device, I think.

comment:13 by Catmengi, 2 months ago

Files in /dev/disk/usb/*/* path is deleting after hot unplug drive. This is ok) path/directory isn't deleting itself

comment:14 by Catmengi, 2 months ago

This somehow leading that every pen-drive reconnection create new /dev/disk/usb entry. Leading to garbage in /dev after time

comment:15 by Catmengi, 2 months ago

Please, can you change ticket to kernel/other suitable? This bug isnt related to FAT FS, its related to /dev

comment:16 by waddlesplash, 2 months ago

Summary: /dev/disk/usb phantom nodes after disconnecting pen driveFAT: KDLs on device removal without unmount

All the images you have posted are kernel panics in the FAT driver, so it definitely is. Whether or not the node "disappears" is probably related to this.

comment:17 by Catmengi, 2 months ago

Ok, i agree with this. Currently the issue that this phantom disk crashes kernel. It's not unmounted on hot unplug. /dev/disk/usb/* path isnt deleted leading to useless garbage in it. Possible, the part of kernel that work with pen drive know that it disconnected, but there isnt any automatic unmounting mechanism(or it is) for hot unplug in FAT driver (befs driver possible have this, it isnt crashing os and partition content is not visible after hot unplug). I think this issue can be solved in this way(adding some kind of signaling from device driver, usb drive in this case to fat driver to force unmount partitions that was on this device). But im not an expert in os architecture and haiku's codebase, so this may not be an ideal solution.

comment:18 by Catmengi, 2 months ago

Even attempt to open right click menu of this fat partition crashing the whole system. This isnt the case with BeFS, so this possible really fat issue. Befs unmount property automatically.

comment:19 by waddlesplash, 2 months ago

If you are pulling the device without unmounting it in the right-click menu, you are definitely going to lose data whether you're on BFS or FAT.

comment:20 by Catmengi, 2 months ago

Doesn't matter system shouldn't crash

comment:21 by waddlesplash, 2 months ago

Sure, which is why this ticket exists. But I'm just noting that even once the kernel crashes are fixed, pulling devices isn't good behavior anyway and will certainly get you in trouble.

comment:22 by Catmengi, 2 months ago

Description: modified (diff)

comment:23 by Catmengi, 2 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.