Re: [PATCH] floppy: remove floppy-specific O_EXCL handling
From: Jiri Kosina
Date: Mon May 14 2012 - 17:38:31 EST
On Mon, 14 May 2012, Tejun Heo wrote:
> > Because since
> > commit e525fd89d380c4a94c0d63913a1dd1a593ed25e7
> > Author: Tejun Heo <tj@xxxxxxxxxx>
> > Date: Sat Nov 13 11:55:17 2010 +0100
> > block: make blkdev_get/put() handle exclusive access
> > mount of /dev/fd0 actually causes the fd0 block device be claimed with
> > _EXCL. Before this commit, you are able to mount /dev/fd0 and then open()
> > it afterward. After this commit you can't any more, because mounting
> > /dev/fd0 already passes O_EXCL to floppy_open(), and thus noone else can
> > open(/dev/fd0) any more.
> > My commit brings things back into shape, i.e. you can, equally to other
> > block devices, both mount it and open() it afterwards.
> Ah, that makes sense. Maybe it's a good idea to note why the change
> is necessary in the commit message too?
Makes sense. Please find the updated patch below. Andrew, Jens, are you
going to pick it up, please?
From: Jiri Kosina <jkosina@xxxxxxx>
Subject: [PATCH] floppy: remove floppy-specific O_EXCL handling
Block layer now handles O_EXCL in a generic way for block devices.
The semantics is however different for floppy and all other block devices,
as floppy driver contains its own O_EXCL handling.
The semantics for all-but-floppy bdevs is "there can be at most one O_EXCL
open of this file", while for floppy bdev the semantics is "if someone has
the bdev open with O_EXCL, noone else can open it".
There is actual userspace-observable change in behavior because of this
since commit e525fd89d380c ("block: make blkdev_get/put() handle exclusive
access") -- on kernels containing this commit, mount of /dev/fd0 causes
the fd0 block device be claimed with _EXCL, preventing subsequent
Bring things back into shape, i.e. make it possible, analogically to other
block devices, to mount the floppy and open() it afterwards -- remove the
floppy-specific handling and let the generic bdev code O_EXCL handling
Signed-off-by: Jiri Kosina <jkosina@xxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
drivers/block/floppy.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index b0b00d7..fe694f8 100644
@@ -3650,13 +3650,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
- if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL)))
- goto out2;
- if (mode & FMODE_EXCL)
- UDRS->fd_ref = -1;
opened_bdev[drive] = bdev;
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/