Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-serial
[pandora-kernel.git] / drivers / block / nbd.c
index 39662f0..9d1035e 100644 (file)
@@ -50,9 +50,9 @@
 #define DBG_RX          0x0200
 #define DBG_TX          0x0400
 static unsigned int debugflags;
-static unsigned int nbds_max = 16;
 #endif /* NDEBUG */
 
+static unsigned int nbds_max = 16;
 static struct nbd_device nbd_dev[MAX_NBD];
 
 /*
@@ -300,6 +300,15 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
                                lo->disk->disk_name, result);
                goto harderror;
        }
+
+       if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
+               printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
+                               lo->disk->disk_name,
+                               (unsigned long)ntohl(reply.magic));
+               result = -EPROTO;
+               goto harderror;
+       }
+
        req = nbd_find_request(lo, reply.handle);
        if (unlikely(IS_ERR(req))) {
                result = PTR_ERR(req);
@@ -312,13 +321,6 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
                goto harderror;
        }
 
-       if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
-               printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
-                               lo->disk->disk_name,
-                               (unsigned long)ntohl(reply.magic));
-               result = -EPROTO;
-               goto harderror;
-       }
        if (ntohl(reply.error)) {
                printk(KERN_ERR "%s: Other side returned error (%d)\n",
                                lo->disk->disk_name, ntohl(reply.error));
@@ -339,7 +341,8 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
                                        printk(KERN_ERR "%s: Receive data failed (result %d)\n",
                                                        lo->disk->disk_name,
                                                        result);
-                                       goto harderror;
+                                       req->errors++;
+                                       return req;
                                }
                                dprintk(DBG_RX, "%s: request %p: got %d bytes data\n",
                                        lo->disk->disk_name, req, bvec->bv_len);
@@ -404,10 +407,10 @@ static void do_nbd_request(request_queue_t * q)
                struct nbd_device *lo;
 
                blkdev_dequeue_request(req);
-               dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%lx)\n",
-                               req->rq_disk->disk_name, req, req->flags);
+               dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n",
+                               req->rq_disk->disk_name, req, req->cmd_type);
 
-               if (!(req->flags & REQ_CMD))
+               if (!blk_fs_request(req))
                        goto error_out;
 
                lo = req->rq_disk->private_data;
@@ -486,7 +489,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
        switch (cmd) {
        case NBD_DISCONNECT:
                printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name);
-               sreq.flags = REQ_SPECIAL;
+               sreq.cmd_type = REQ_TYPE_SPECIAL;
                nbd_cmd(&sreq) = NBD_CMD_DISC;
                /*
                 * Set these to sane values in case server implementation