]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] switch nbd
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 2 Mar 2008 14:33:33 +0000 (09:33 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 21 Oct 2008 11:47:53 +0000 (07:47 -0400)
NB: nbd_ioctl() appears to be racy; BKL is held, but doesn't really
help, AFAICS.  Left as-is for now, but it'll need fixing.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/block/nbd.c

index 36015e0945b1a0fdf95c21f137a59e573d7a6f03..d3a91cacee8c6aff410bc9a8567ce89cb1ae477f 100644 (file)
@@ -557,10 +557,11 @@ static void do_nbd_request(struct request_queue * q)
        }
 }
 
-static int nbd_ioctl(struct inode *inode, struct file *file,
+static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
                     unsigned int cmd, unsigned long arg)
 {
-       struct nbd_device *lo = inode->i_bdev->bd_disk->private_data;
+       struct nbd_device *lo = bdev->bd_disk->private_data;
+       struct file *file;
        int error;
        struct request sreq ;
        struct task_struct *thread;
@@ -612,8 +613,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                error = -EINVAL;
                file = fget(arg);
                if (file) {
-                       struct block_device *bdev = inode->i_bdev;
-                       inode = file->f_path.dentry->d_inode;
+                       struct inode *inode = file->f_path.dentry->d_inode;
                        if (S_ISSOCK(inode->i_mode)) {
                                lo->file = file;
                                lo->sock = SOCKET_I(inode);
@@ -628,14 +628,14 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
        case NBD_SET_BLKSIZE:
                lo->blksize = arg;
                lo->bytesize &= ~(lo->blksize-1);
-               inode->i_bdev->bd_inode->i_size = lo->bytesize;
-               set_blocksize(inode->i_bdev, lo->blksize);
+               bdev->bd_inode->i_size = lo->bytesize;
+               set_blocksize(bdev, lo->blksize);
                set_capacity(lo->disk, lo->bytesize >> 9);
                return 0;
        case NBD_SET_SIZE:
                lo->bytesize = arg & ~(lo->blksize-1);
-               inode->i_bdev->bd_inode->i_size = lo->bytesize;
-               set_blocksize(inode->i_bdev, lo->blksize);
+               bdev->bd_inode->i_size = lo->bytesize;
+               set_blocksize(bdev, lo->blksize);
                set_capacity(lo->disk, lo->bytesize >> 9);
                return 0;
        case NBD_SET_TIMEOUT:
@@ -643,8 +643,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                return 0;
        case NBD_SET_SIZE_BLOCKS:
                lo->bytesize = ((u64) arg) * lo->blksize;
-               inode->i_bdev->bd_inode->i_size = lo->bytesize;
-               set_blocksize(inode->i_bdev, lo->blksize);
+               bdev->bd_inode->i_size = lo->bytesize;
+               set_blocksize(bdev, lo->blksize);
                set_capacity(lo->disk, lo->bytesize >> 9);
                return 0;
        case NBD_DO_IT:
@@ -666,10 +666,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                if (file)
                        fput(file);
                lo->bytesize = 0;
-               inode->i_bdev->bd_inode->i_size = 0;
+               bdev->bd_inode->i_size = 0;
                set_capacity(lo->disk, 0);
                if (max_part > 0)
-                       ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0);
+                       ioctl_by_bdev(bdev, BLKRRPART, 0);
                return lo->harderror;
        case NBD_CLEAR_QUE:
                /*
@@ -680,7 +680,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
                return 0;
        case NBD_PRINT_DEBUG:
                printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n",
-                       inode->i_bdev->bd_disk->disk_name,
+                       bdev->bd_disk->disk_name,
                        lo->queue_head.next, lo->queue_head.prev,
                        &lo->queue_head);
                return 0;
@@ -691,7 +691,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
 static struct block_device_operations nbd_fops =
 {
        .owner =        THIS_MODULE,
-       .__ioctl =      nbd_ioctl,
+       .locked_ioctl = nbd_ioctl,
 };
 
 /*