X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fblock%2Fnbd.c;h=090796bef78f16374f8c94f2bf70e23e602deabd;hb=fb16596997ded3e70d308bec58e32c1e2c5cf9b0;hp=0a1b1ea36ddcdc3064ba4daa35567a01e0f5b72d;hpb=b4b9034132c7e1e4474999e688dd7d03b7d97a99;p=powerpc.git diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 0a1b1ea36d..090796bef7 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -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); @@ -352,14 +355,30 @@ harderror: return NULL; } +static ssize_t pid_show(struct gendisk *disk, char *page) +{ + return sprintf(page, "%ld\n", + (long) ((struct nbd_device *)disk->private_data)->pid); +} + +static struct disk_attribute pid_attr = { + .attr = { .name = "pid", .mode = S_IRUGO }, + .show = pid_show, +}; + static void nbd_do_it(struct nbd_device *lo) { struct request *req; BUG_ON(lo->magic != LO_MAGIC); + lo->pid = current->pid; + sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); + while ((req = nbd_read_stat(lo)) != NULL) nbd_end_request(req); + + sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); return; } @@ -404,10 +423,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 +505,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 @@ -518,7 +537,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, error = -EINVAL; file = fget(arg); if (file) { - inode = file->f_dentry->d_inode; + inode = file->f_path.dentry->d_inode; if (S_ISSOCK(inode->i_mode)) { lo->file = file; lo->sock = SOCKET_I(inode);