Skip to contentSkip to conversation

Remove unneded lock_kernel() in driver/block/loop.c

PATCH In review Diego Woitasen 2 participants 2 messages Jul 9, 2007 – Jul 20, 2007 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove unneded lock_kernel() in driver/block/loop.c

---
 drivers/block/loop.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/block/loop.c +0 -2
index 0ed5470..1cc004e 100644
@@ -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
Signature · 1 line
1.5.2.3
#1 lore raw
Quoted 19 lines · On Sun, 8 Jul 2007 22:57:01 -0300 Diego Woitasen <[email protected]> wrote:
---
 drivers/block/loop.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/block/loop.c +0 -1
index 0ed5470..1cc004e 100644
@@ -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);

drivers/block/loop.c static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a · line 1316

Quoted 7 lines
drivers/block/loop.c +0 -1
@@ -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.

drivers/block/loop.c renamed from drivers/block/loop.c~loop-use-unlocked_ioctl +7 -5
@@ -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

_