Commit 110748e8 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] fix dasd open/release

The invalidate_buffers in ->release is wrong, get a reference to the
discipline in the beginning of ->open.
parent 8bdd4c06
...@@ -1692,50 +1692,51 @@ dasd_flush_request_queue(struct dasd_device * device) ...@@ -1692,50 +1692,51 @@ dasd_flush_request_queue(struct dasd_device * device)
static int static int
dasd_open(struct inode *inp, struct file *filp) 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; int rc;
if (!try_module_get(device->discipline->owner))
return -EINVAL;
if (dasd_probeonly) { if (dasd_probeonly) {
MESSAGE(KERN_INFO, MESSAGE(KERN_INFO,
"No access to device (%d:%d) due to probeonly mode", "No access to device %s due to probeonly mode",
major(inp->i_rdev), minor(inp->i_rdev)); disk->disk_name);
return -EPERM; rc = -EPERM;
goto out;
} }
device = inp->i_bdev->bd_disk->private_data; rc = -ENODEV;
if (device->state < DASD_STATE_BASIC) { if (device->state < DASD_STATE_BASIC) {
DBF_DEV_EVENT(DBF_ERR, device, " %s", DBF_DEV_EVENT(DBF_ERR, device, " %s",
" Cannot open unrecognized device"); " Cannot open unrecognized device");
return -ENODEV; rc = -ENODEV;
goto out;
} }
rc = 0;
if (atomic_inc_return(&device->open_count) == 1) { atomic_inc(&device->open_count);
if (!try_module_get(device->discipline->owner)) { return 0;
/* Discipline is currently unloaded! */
atomic_dec(&device->open_count); out:
rc = -ENODEV; module_put(device->discipline->owner);
}
}
return rc; return rc;
} }
static int static int
dasd_release(struct inode *inp, struct file *filp) dasd_release(struct inode *inp, struct file *filp)
{ {
struct dasd_device *device; struct gendisk *disk = inp->i_bdev->bd_disk;
struct dasd_device *device = isk->private_data;
device = inp->i_bdev->bd_disk->private_data;
if (device->state < DASD_STATE_ACCEPT) { if (device->state < DASD_STATE_ACCEPT) {
DBF_DEV_EVENT(DBF_ERR, device, " %s", DBF_DEV_EVENT(DBF_ERR, device, " %s",
" Cannot release unrecognized device"); " Cannot release unrecognized device");
return -EINVAL; return -EINVAL;
} }
if (atomic_dec_return(&device->open_count) == 0) {
invalidate_buffers(inp->i_rdev); atomic_dec(&device->open_count);
module_put(device->discipline->owner); module_put(device->discipline->owner);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment