Commit 369a4632 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Martin Schwidefsky

[S390] tape: remove BKL from tape driver

Replace BLK with a per device mutex.
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 8fd138c3
...@@ -212,6 +212,9 @@ struct tape_device { ...@@ -212,6 +212,9 @@ struct tape_device {
struct tape_class_device * nt; struct tape_class_device * nt;
struct tape_class_device * rt; struct tape_class_device * rt;
/* Device mutex to serialize tape commands. */
struct mutex mutex;
/* Device discipline information. */ /* Device discipline information. */
struct tape_discipline * discipline; struct tape_discipline * discipline;
void * discdata; void * discdata;
......
...@@ -54,7 +54,7 @@ static const struct block_device_operations tapeblock_fops = { ...@@ -54,7 +54,7 @@ static const struct block_device_operations tapeblock_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = tapeblock_open, .open = tapeblock_open,
.release = tapeblock_release, .release = tapeblock_release,
.locked_ioctl = tapeblock_ioctl, .ioctl = tapeblock_ioctl,
.media_changed = tapeblock_medium_changed, .media_changed = tapeblock_medium_changed,
.revalidate_disk = tapeblock_revalidate_disk, .revalidate_disk = tapeblock_revalidate_disk,
}; };
......
...@@ -33,8 +33,7 @@ static ssize_t tapechar_read(struct file *, char __user *, size_t, loff_t *); ...@@ -33,8 +33,7 @@ static ssize_t tapechar_read(struct file *, char __user *, size_t, loff_t *);
static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *); static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *);
static int tapechar_open(struct inode *,struct file *); static int tapechar_open(struct inode *,struct file *);
static int tapechar_release(struct inode *,struct file *); static int tapechar_release(struct inode *,struct file *);
static int tapechar_ioctl(struct inode *, struct file *, unsigned int, static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
unsigned long);
static long tapechar_compat_ioctl(struct file *, unsigned int, static long tapechar_compat_ioctl(struct file *, unsigned int,
unsigned long); unsigned long);
...@@ -43,7 +42,7 @@ static const struct file_operations tape_fops = ...@@ -43,7 +42,7 @@ static const struct file_operations tape_fops =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = tapechar_read, .read = tapechar_read,
.write = tapechar_write, .write = tapechar_write,
.ioctl = tapechar_ioctl, .unlocked_ioctl = tapechar_ioctl,
.compat_ioctl = tapechar_compat_ioctl, .compat_ioctl = tapechar_compat_ioctl,
.open = tapechar_open, .open = tapechar_open,
.release = tapechar_release, .release = tapechar_release,
...@@ -284,26 +283,20 @@ tapechar_open (struct inode *inode, struct file *filp) ...@@ -284,26 +283,20 @@ tapechar_open (struct inode *inode, struct file *filp)
if (imajor(filp->f_path.dentry->d_inode) != tapechar_major) if (imajor(filp->f_path.dentry->d_inode) != tapechar_major)
return -ENODEV; return -ENODEV;
lock_kernel();
minor = iminor(filp->f_path.dentry->d_inode); minor = iminor(filp->f_path.dentry->d_inode);
device = tape_find_device(minor / TAPE_MINORS_PER_DEV); device = tape_find_device(minor / TAPE_MINORS_PER_DEV);
if (IS_ERR(device)) { if (IS_ERR(device)) {
DBF_EVENT(3, "TCHAR:open: tape_find_device() failed\n"); DBF_EVENT(3, "TCHAR:open: tape_find_device() failed\n");
rc = PTR_ERR(device); return PTR_ERR(device);
goto out;
} }
rc = tape_open(device); rc = tape_open(device);
if (rc == 0) { if (rc == 0) {
filp->private_data = device; filp->private_data = device;
rc = nonseekable_open(inode, filp); nonseekable_open(inode, filp);
} } else
else
tape_put_device(device); tape_put_device(device);
out:
unlock_kernel();
return rc; return rc;
} }
...@@ -350,16 +343,11 @@ tapechar_release(struct inode *inode, struct file *filp) ...@@ -350,16 +343,11 @@ tapechar_release(struct inode *inode, struct file *filp)
* Tape device io controls. * Tape device io controls.
*/ */
static int static int
tapechar_ioctl(struct inode *inp, struct file *filp, __tapechar_ioctl(struct tape_device *device,
unsigned int no, unsigned long data) unsigned int no, unsigned long data)
{ {
struct tape_device *device;
int rc; int rc;
DBF_EVENT(6, "TCHAR:ioct\n");
device = (struct tape_device *) filp->private_data;
if (no == MTIOCTOP) { if (no == MTIOCTOP) {
struct mtop op; struct mtop op;
...@@ -451,6 +439,21 @@ tapechar_ioctl(struct inode *inp, struct file *filp, ...@@ -451,6 +439,21 @@ tapechar_ioctl(struct inode *inp, struct file *filp,
return device->discipline->ioctl_fn(device, no, data); return device->discipline->ioctl_fn(device, no, data);
} }
static long
tapechar_ioctl(struct file *filp, unsigned int no, unsigned long data)
{
struct tape_device *device;
long rc;
DBF_EVENT(6, "TCHAR:ioct\n");
device = (struct tape_device *) filp->private_data;
mutex_lock(&device->mutex);
rc = __tapechar_ioctl(device, no, data);
mutex_unlock(&device->mutex);
return rc;
}
static long static long
tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
{ {
...@@ -458,9 +461,9 @@ tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) ...@@ -458,9 +461,9 @@ tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
int rval = -ENOIOCTLCMD; int rval = -ENOIOCTLCMD;
if (device->discipline->ioctl_fn) { if (device->discipline->ioctl_fn) {
lock_kernel(); mutex_lock(&device->mutex);
rval = device->discipline->ioctl_fn(device, no, data); rval = device->discipline->ioctl_fn(device, no, data);
unlock_kernel(); mutex_unlock(&device->mutex);
if (rval == -EINVAL) if (rval == -EINVAL)
rval = -ENOIOCTLCMD; rval = -ENOIOCTLCMD;
} }
......
...@@ -492,6 +492,7 @@ tape_alloc_device(void) ...@@ -492,6 +492,7 @@ tape_alloc_device(void)
kfree(device); kfree(device);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
mutex_init(&device->mutex);
INIT_LIST_HEAD(&device->req_queue); INIT_LIST_HEAD(&device->req_queue);
INIT_LIST_HEAD(&device->node); INIT_LIST_HEAD(&device->node);
init_waitqueue_head(&device->state_change_wq); init_waitqueue_head(&device->state_change_wq);
......
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