From 110748e8b67900ff0f91dbbf483a72e1d26ea880 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 23 Apr 2003 04:28:28 -0700 Subject: [PATCH] [PATCH] fix dasd open/release The invalidate_buffers in ->release is wrong, get a reference to the discipline in the beginning of ->open. --- drivers/s390/block/dasd.c | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index acefa5692a365..ea2372c922014 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1692,50 +1692,51 @@ dasd_flush_request_queue(struct dasd_device * device) static int dasd_open(struct inode *inp, struct file *filp) { - struct dasd_device *device; + struct gendisk *disk = inp->i_bdev->bd_disk; + struct dasd_device *device = disk->private_data; int rc; + + if (!try_module_get(device->discipline->owner)) + return -EINVAL; if (dasd_probeonly) { MESSAGE(KERN_INFO, - "No access to device (%d:%d) due to probeonly mode", - major(inp->i_rdev), minor(inp->i_rdev)); - return -EPERM; + "No access to device %s due to probeonly mode", + disk->disk_name); + rc = -EPERM; + goto out; } - device = inp->i_bdev->bd_disk->private_data; + rc = -ENODEV; if (device->state < DASD_STATE_BASIC) { DBF_DEV_EVENT(DBF_ERR, device, " %s", " Cannot open unrecognized device"); - return -ENODEV; + rc = -ENODEV; + goto out; } - rc = 0; - if (atomic_inc_return(&device->open_count) == 1) { - if (!try_module_get(device->discipline->owner)) { - /* Discipline is currently unloaded! */ - atomic_dec(&device->open_count); - rc = -ENODEV; - } - } + atomic_inc(&device->open_count); + return 0; + +out: + module_put(device->discipline->owner); return rc; } static int dasd_release(struct inode *inp, struct file *filp) { - struct dasd_device *device; - - device = inp->i_bdev->bd_disk->private_data; + struct gendisk *disk = inp->i_bdev->bd_disk; + struct dasd_device *device = isk->private_data; if (device->state < DASD_STATE_ACCEPT) { DBF_DEV_EVENT(DBF_ERR, device, " %s", " Cannot release unrecognized device"); return -EINVAL; } - if (atomic_dec_return(&device->open_count) == 0) { - invalidate_buffers(inp->i_rdev); - module_put(device->discipline->owner); - } + + atomic_dec(&device->open_count); + module_put(device->discipline->owner); return 0; } -- 2.53.0