aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2012-05-18 07:50:28 -0400
committerJiri Kosina <jkosina@suse.cz>2012-05-18 09:19:11 -0400
commitbfa10b8c98bb335bc3e401d3ec947d446f04d1aa (patch)
tree70c1ace62544811e7f4f39f8bab8b85ee9f89017 /drivers/block/floppy.c
parent070ad7e793dc6ff753ee682ef7790b3373b471f6 (diff)
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 open(/dev/fd0). 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 take over. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r--drivers/block/floppy.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 48e1d70740d..cce7df367b7 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3607,9 +3607,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
3607 3607
3608 mutex_lock(&floppy_mutex); 3608 mutex_lock(&floppy_mutex);
3609 mutex_lock(&open_lock); 3609 mutex_lock(&open_lock);
3610 if (UDRS->fd_ref < 0) 3610 if (!UDRS->fd_ref--) {
3611 UDRS->fd_ref = 0;
3612 else if (!UDRS->fd_ref--) {
3613 DPRINT("floppy_release with fd_ref == 0"); 3611 DPRINT("floppy_release with fd_ref == 0");
3614 UDRS->fd_ref = 0; 3612 UDRS->fd_ref = 0;
3615 } 3613 }
@@ -3645,13 +3643,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3645 set_bit(FD_VERIFY_BIT, &UDRS->flags); 3643 set_bit(FD_VERIFY_BIT, &UDRS->flags);
3646 } 3644 }
3647 3645
3648 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL))) 3646 UDRS->fd_ref++;
3649 goto out2;
3650
3651 if (mode & FMODE_EXCL)
3652 UDRS->fd_ref = -1;
3653 else
3654 UDRS->fd_ref++;
3655 3647
3656 opened_bdev[drive] = bdev; 3648 opened_bdev[drive] = bdev;
3657 3649
@@ -3714,10 +3706,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3714 mutex_unlock(&floppy_mutex); 3706 mutex_unlock(&floppy_mutex);
3715 return 0; 3707 return 0;
3716out: 3708out:
3717 if (UDRS->fd_ref < 0) 3709 UDRS->fd_ref--;
3718 UDRS->fd_ref = 0; 3710
3719 else
3720 UDRS->fd_ref--;
3721 if (!UDRS->fd_ref) 3711 if (!UDRS->fd_ref)
3722 opened_bdev[drive] = NULL; 3712 opened_bdev[drive] = NULL;
3723out2: 3713out2: