aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-03-02 09:33:33 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2008-10-21 07:47:53 -0400
commita8cdc308c0ca3809e37e2be62174906a45b92670 (patch)
treee3c70ebf74d885c059cb32f4217216f44a4202d3 /drivers/block/nbd.c
parentbb21488482bd36eae6b30b014d93619063773fd4 (diff)
[PATCH] switch nbd
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>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 36015e0945b1..d3a91cacee8c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -557,10 +557,11 @@ static void do_nbd_request(struct request_queue * q)
557 } 557 }
558} 558}
559 559
560static int nbd_ioctl(struct inode *inode, struct file *file, 560static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
561 unsigned int cmd, unsigned long arg) 561 unsigned int cmd, unsigned long arg)
562{ 562{
563 struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; 563 struct nbd_device *lo = bdev->bd_disk->private_data;
564 struct file *file;
564 int error; 565 int error;
565 struct request sreq ; 566 struct request sreq ;
566 struct task_struct *thread; 567 struct task_struct *thread;
@@ -612,8 +613,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
612 error = -EINVAL; 613 error = -EINVAL;
613 file = fget(arg); 614 file = fget(arg);
614 if (file) { 615 if (file) {
615 struct block_device *bdev = inode->i_bdev; 616 struct inode *inode = file->f_path.dentry->d_inode;
616 inode = file->f_path.dentry->d_inode;
617 if (S_ISSOCK(inode->i_mode)) { 617 if (S_ISSOCK(inode->i_mode)) {
618 lo->file = file; 618 lo->file = file;
619 lo->sock = SOCKET_I(inode); 619 lo->sock = SOCKET_I(inode);
@@ -628,14 +628,14 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
628 case NBD_SET_BLKSIZE: 628 case NBD_SET_BLKSIZE:
629 lo->blksize = arg; 629 lo->blksize = arg;
630 lo->bytesize &= ~(lo->blksize-1); 630 lo->bytesize &= ~(lo->blksize-1);
631 inode->i_bdev->bd_inode->i_size = lo->bytesize; 631 bdev->bd_inode->i_size = lo->bytesize;
632 set_blocksize(inode->i_bdev, lo->blksize); 632 set_blocksize(bdev, lo->blksize);
633 set_capacity(lo->disk, lo->bytesize >> 9); 633 set_capacity(lo->disk, lo->bytesize >> 9);
634 return 0; 634 return 0;
635 case NBD_SET_SIZE: 635 case NBD_SET_SIZE:
636 lo->bytesize = arg & ~(lo->blksize-1); 636 lo->bytesize = arg & ~(lo->blksize-1);
637 inode->i_bdev->bd_inode->i_size = lo->bytesize; 637 bdev->bd_inode->i_size = lo->bytesize;
638 set_blocksize(inode->i_bdev, lo->blksize); 638 set_blocksize(bdev, lo->blksize);
639 set_capacity(lo->disk, lo->bytesize >> 9); 639 set_capacity(lo->disk, lo->bytesize >> 9);
640 return 0; 640 return 0;
641 case NBD_SET_TIMEOUT: 641 case NBD_SET_TIMEOUT:
@@ -643,8 +643,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
643 return 0; 643 return 0;
644 case NBD_SET_SIZE_BLOCKS: 644 case NBD_SET_SIZE_BLOCKS:
645 lo->bytesize = ((u64) arg) * lo->blksize; 645 lo->bytesize = ((u64) arg) * lo->blksize;
646 inode->i_bdev->bd_inode->i_size = lo->bytesize; 646 bdev->bd_inode->i_size = lo->bytesize;
647 set_blocksize(inode->i_bdev, lo->blksize); 647 set_blocksize(bdev, lo->blksize);
648 set_capacity(lo->disk, lo->bytesize >> 9); 648 set_capacity(lo->disk, lo->bytesize >> 9);
649 return 0; 649 return 0;
650 case NBD_DO_IT: 650 case NBD_DO_IT:
@@ -666,10 +666,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
666 if (file) 666 if (file)
667 fput(file); 667 fput(file);
668 lo->bytesize = 0; 668 lo->bytesize = 0;
669 inode->i_bdev->bd_inode->i_size = 0; 669 bdev->bd_inode->i_size = 0;
670 set_capacity(lo->disk, 0); 670 set_capacity(lo->disk, 0);
671 if (max_part > 0) 671 if (max_part > 0)
672 ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0); 672 ioctl_by_bdev(bdev, BLKRRPART, 0);
673 return lo->harderror; 673 return lo->harderror;
674 case NBD_CLEAR_QUE: 674 case NBD_CLEAR_QUE:
675 /* 675 /*
@@ -680,7 +680,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
680 return 0; 680 return 0;
681 case NBD_PRINT_DEBUG: 681 case NBD_PRINT_DEBUG:
682 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", 682 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n",
683 inode->i_bdev->bd_disk->disk_name, 683 bdev->bd_disk->disk_name,
684 lo->queue_head.next, lo->queue_head.prev, 684 lo->queue_head.next, lo->queue_head.prev,
685 &lo->queue_head); 685 &lo->queue_head);
686 return 0; 686 return 0;
@@ -691,7 +691,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
691static struct block_device_operations nbd_fops = 691static struct block_device_operations nbd_fops =
692{ 692{
693 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
694 .__ioctl = nbd_ioctl, 694 .locked_ioctl = nbd_ioctl,
695}; 695};
696 696
697/* 697/*