Commit 82d4dc5a authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] sem2mutex: drivers/block/nbd.c

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f85221dd
...@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q) ...@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q)
req->errors = 0; req->errors = 0;
spin_unlock_irq(q->queue_lock); spin_unlock_irq(q->queue_lock);
down(&lo->tx_lock); mutex_lock(&lo->tx_lock);
if (unlikely(!lo->sock)) { if (unlikely(!lo->sock)) {
up(&lo->tx_lock); mutex_unlock(&lo->tx_lock);
printk(KERN_ERR "%s: Attempted send on closed socket\n", printk(KERN_ERR "%s: Attempted send on closed socket\n",
lo->disk->disk_name); lo->disk->disk_name);
req->errors++; req->errors++;
...@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q) ...@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q)
} }
lo->active_req = NULL; lo->active_req = NULL;
up(&lo->tx_lock); mutex_unlock(&lo->tx_lock);
wake_up_all(&lo->active_wq); wake_up_all(&lo->active_wq);
spin_lock_irq(q->queue_lock); spin_lock_irq(q->queue_lock);
...@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
case NBD_CLEAR_SOCK: case NBD_CLEAR_SOCK:
error = 0; error = 0;
down(&lo->tx_lock); mutex_lock(&lo->tx_lock);
lo->sock = NULL; lo->sock = NULL;
up(&lo->tx_lock); mutex_unlock(&lo->tx_lock);
file = lo->file; file = lo->file;
lo->file = NULL; lo->file = NULL;
nbd_clear_que(lo); nbd_clear_que(lo);
...@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
* FIXME: This code is duplicated from sys_shutdown, but * FIXME: This code is duplicated from sys_shutdown, but
* there should be a more generic interface rather than * there should be a more generic interface rather than
* calling socket ops directly here */ * calling socket ops directly here */
down(&lo->tx_lock); mutex_lock(&lo->tx_lock);
if (lo->sock) { if (lo->sock) {
printk(KERN_WARNING "%s: shutting down socket\n", printk(KERN_WARNING "%s: shutting down socket\n",
lo->disk->disk_name); lo->disk->disk_name);
...@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
SEND_SHUTDOWN|RCV_SHUTDOWN); SEND_SHUTDOWN|RCV_SHUTDOWN);
lo->sock = NULL; lo->sock = NULL;
} }
up(&lo->tx_lock); mutex_unlock(&lo->tx_lock);
file = lo->file; file = lo->file;
lo->file = NULL; lo->file = NULL;
nbd_clear_que(lo); nbd_clear_que(lo);
...@@ -683,7 +683,7 @@ static int __init nbd_init(void) ...@@ -683,7 +683,7 @@ static int __init nbd_init(void)
nbd_dev[i].flags = 0; nbd_dev[i].flags = 0;
spin_lock_init(&nbd_dev[i].queue_lock); spin_lock_init(&nbd_dev[i].queue_lock);
INIT_LIST_HEAD(&nbd_dev[i].queue_head); INIT_LIST_HEAD(&nbd_dev[i].queue_head);
init_MUTEX(&nbd_dev[i].tx_lock); mutex_init(&nbd_dev[i].tx_lock);
init_waitqueue_head(&nbd_dev[i].active_wq); init_waitqueue_head(&nbd_dev[i].active_wq);
nbd_dev[i].blksize = 1024; nbd_dev[i].blksize = 1024;
nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */
......
...@@ -38,6 +38,7 @@ enum { ...@@ -38,6 +38,7 @@ enum {
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/mutex.h>
/* values for flags field */ /* values for flags field */
#define NBD_READ_ONLY 0x0001 #define NBD_READ_ONLY 0x0001
...@@ -57,7 +58,7 @@ struct nbd_device { ...@@ -57,7 +58,7 @@ struct nbd_device {
struct request *active_req; struct request *active_req;
wait_queue_head_t active_wq; wait_queue_head_t active_wq;
struct semaphore tx_lock; struct mutex tx_lock;
struct gendisk *disk; struct gendisk *disk;
int blksize; int blksize;
u64 bytesize; u64 bytesize;
......
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