Bug 35832 - Attempt to mount floppy fails with mount: /dev/fd0 is not a valid block device
Attempt to mount floppy fails with mount: /dev/fd0 is not a valid block device
Status: CLOSED CODE_FIX
Product: IO/Storage
Classification: Unclassified
Component: Block Layer
All Linux
: P1 normal
Assigned To: Jens Axboe
:
Depends on:
Blocks: 32012
  Show dependency treegraph
 
Reported: 2011-05-25 15:30 UTC by Alex Villacis Lasso
Modified: 2011-06-07 08:02 UTC (History)
4 users (show)

See Also:
Kernel Version: 2.6.39
Tree: Mainline
Regression: Yes


Attachments
dont-check-events-on-disk_add_events.patch (449 bytes, patch)
2011-05-25 20:52 UTC, Tejun Heo
Details | Diff

Description Alex Villacis Lasso 2011-05-25 15:30:56 UTC
Up to and including 2.6.39-rc7, the root user can mount a floppy in a standard PC floppy drive by issuing "mount /dev/fd0 /mnt/floppy". An ordinary user cannot do this (even with a fstab mount entry) due to bug #28522.

Starting with 2.6.39, if root tries to do the same operation, this is the output:

[root@karlalex ~]# mount /dev/fd0 /mnt/floppy/
mount: /dev/fd0 is not a valid block device

No I/O is ever attempted on the floppy drive.

To reproduce:

1) Boot 2.6.39 in x86_64 machine with a standard floppy drive (not USB, not parport) and no floppy inserted in the drive.
2) After boot finishes, insert floppy in drive
3) Attempt (as root) to mount the floppy.

Actual results:
mount: /dev/fd0 is not a valid block device
No I/O attempted on drive.

Expected results:
Mount should be successful, or at least I/O should be attempted on the drive.

Any attempt to access /dev/fd0 (such as dd) is affected in the same way.

A strace on mount shows that the open() operation on /dev/fd0 fails with ENXIO, as well as the actual mount() operation.

Bisection on this bug points to the following commit:
commit 9fd097b14918875bd6f125ed699d7bbbba5893ee
Author: Tejun Heo <tj@kernel.org>
Date:   Thu Apr 21 21:32:55 2011 +0200

    block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers
    
    In-kernel disk event polling doesn't matter for legacy/fringe drivers
    and may lead to infinite event loop if ->check_events() implementation
    generates events on level condition instead of edge.
    
    Now that block layer supports suppressing exporting unlisted events,
    simply leaving disk->events cleared allows these drivers to keep the
    internal revalidation behavior intact while avoiding weird
    interactions with userland event handler.
    
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: Kay Sievers <kay.sievers@vrfy.org>
    Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Reverting this particular commit fixes the bug for me.
Comment 1 Tejun Heo 2011-05-25 20:52:40 UTC
Created attachment 59462 [details]
dont-check-events-on-disk_add_events.patch

Can you please test this patch?

Thanks.
Comment 2 Rafael J. Wysocki 2011-05-25 21:04:22 UTC
First-Bad-Commit : 9fd097b14918875bd6f125ed699d7bbbba5893ee
Comment 3 Alex Villacis Lasso 2011-05-26 15:16:32 UTC
The patch dont-check-events-on-disk_add_events.patch indeed fixes the bug.
Comment 4 Alex Villacis Lasso 2011-06-01 17:07:08 UTC
There is now a serious problem when mounting /dev/fd0u1440 in 3.0.0-rc1, described at bug #28522.
Comment 5 Florian Mickler 2011-06-07 08:01:01 UTC
Patch: https://bugzilla.kernel.org/attachment.cgi?id=59462
Comment 6 Florian Mickler 2011-06-07 08:02:20 UTC
Merged in 3.0-rc2:

commit 75e3f3ee3c64968d42f4843ec49e579f84b5aa0c
Author: Tejun Heo <tj@kernel.org>
Date:   Thu May 26 21:06:50 2011 +0200

    block: always allocate genhd->ev if check_events is implemented

Note You need to log in before you can comment on or make changes to this bug.