[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>
This commit is contained in:
Al Viro 2008-03-02 09:33:33 -05:00
parent bb21488482
commit a8cdc308c0
1 changed files with 14 additions and 14 deletions

View 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,
};
/*