Commit 68b89f61 authored by Pavel Machek's avatar Pavel Machek Committed by Christoph Hellwig

[PATCH] Clean up nbd.c

I've never seen any of those errors, so I guess its okay to convert them
to BUG_ONs.  It makes code look better.
parent 65458629
...@@ -65,10 +65,8 @@ static spinlock_t nbd_lock = SPIN_LOCK_UNLOCKED; ...@@ -65,10 +65,8 @@ static spinlock_t nbd_lock = SPIN_LOCK_UNLOCKED;
/* #define DEBUG( s ) printk( s ) /* #define DEBUG( s ) printk( s )
*/ */
#ifdef PARANOIA
static int requests_in; static int requests_in;
static int requests_out; static int requests_out;
#endif
static int nbd_open(struct inode *inode, struct file *file) static int nbd_open(struct inode *inode, struct file *file)
{ {
...@@ -261,18 +259,8 @@ void nbd_do_it(struct nbd_device *lo) ...@@ -261,18 +259,8 @@ void nbd_do_it(struct nbd_device *lo)
printk(KERN_ALERT "req should never be null\n" ); printk(KERN_ALERT "req should never be null\n" );
goto out; goto out;
} }
#ifdef PARANOIA BUG_ON(lo->magic != LO_MAGIC);
if (lo != req->rq_disk->private_data) {
printk(KERN_ALERT "NBD: request corrupted!\n");
continue;
}
if (lo->magic != LO_MAGIC) {
printk(KERN_ALERT "NBD: nbd_dev[] corrupted: Not enough magic\n");
goto out;
}
#endif
nbd_end_request(req); nbd_end_request(req);
} }
out: out:
return; return;
...@@ -282,12 +270,7 @@ void nbd_clear_que(struct nbd_device *lo) ...@@ -282,12 +270,7 @@ void nbd_clear_que(struct nbd_device *lo)
{ {
struct request *req; struct request *req;
#ifdef PARANOIA BUG_ON(lo->magic != LO_MAGIC);
if (lo->magic != LO_MAGIC) {
printk(KERN_ERR "NBD: nbd_dev[] corrupted: Not enough magic when clearing!\n");
return;
}
#endif
do { do {
req = NULL; req = NULL;
...@@ -333,11 +316,9 @@ static void do_nbd_request(request_queue_t * q) ...@@ -333,11 +316,9 @@ static void do_nbd_request(request_queue_t * q)
if (lo->flags & NBD_READ_ONLY) if (lo->flags & NBD_READ_ONLY)
FAIL("Write on read-only"); FAIL("Write on read-only");
} }
#ifdef PARANOIA BUG_ON(lo->magic != LO_MAGIC);
if (lo->magic != LO_MAGIC)
FAIL("nbd[] is not magical!");
requests_in++; requests_in++;
#endif
req->errors = 0; req->errors = 0;
blkdev_dequeue_request(req); blkdev_dequeue_request(req);
spin_unlock_irq(q->queue_lock); spin_unlock_irq(q->queue_lock);
......
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