Re: [PATCH] Remove unneded lock_kernel() in driver/block/loop.c
From: Andrew Morton
Date: Thu Jul 19 2007 - 20:39:15 EST
On Sun, 8 Jul 2007 22:57:01 -0300
Diego Woitasen <diego@xxxxxxxxxxxxxxx> wrote:
>
> Signed-off-by: Diego Woitasen <diego@xxxxxxxxxxxxxxx>
> ---
> drivers/block/loop.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 0ed5470..1cc004e 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1286,7 +1286,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
> struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
> int err;
>
> - lock_kernel();
> switch(cmd) {
> case LOOP_SET_STATUS:
> mutex_lock(&lo->lo_ctl_mutex);
> @@ -1312,7 +1311,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
> err = -ENOIOCTLCMD;
> break;
> }
> - unlock_kernel();
> return err;
> }
> #endif
I agree. And that means that we can move lo_ioctl over to being an
unlocked_ioctl handler.
--- a/drivers/block/loop.c~loop-use-unlocked_ioctl
+++ a/drivers/block/loop.c
@@ -1124,12 +1124,14 @@ loop_get_status64(struct loop_device *lo
return err;
}
-static int lo_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg)
+static long lo_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
+ struct inode *inode;
+ struct loop_device *lo;
int err;
+ inode = file->f_mapping->host;
+ lo = inode->i_bdev->bd_disk->private_data;
mutex_lock(&lo->lo_ctl_mutex);
switch (cmd) {
case LOOP_SET_FD:
@@ -1304,7 +1306,7 @@ static long lo_compat_ioctl(struct file
arg = (unsigned long) compat_ptr(arg);
case LOOP_SET_FD:
case LOOP_CHANGE_FD:
- err = lo_ioctl(inode, file, cmd, arg);
+ err = lo_ioctl(file, cmd, arg);
break;
default:
err = -ENOIOCTLCMD;
@@ -1340,7 +1342,7 @@ static struct block_device_operations lo
.owner = THIS_MODULE,
.open = lo_open,
.release = lo_release,
- .ioctl = lo_ioctl,
+ .unlocked_ioctl = lo_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = lo_compat_ioctl,
#endif
_
-
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/