Commit 20c52ab8 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] nbd: make nbd and block layer agree about device and

From: Paul Clements <Paul.Clements@SteelEye.com>

Ensure that nbd and the block layer agree about device block sizes and total
device sizes.
parent 627c0412
...@@ -588,18 +588,22 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -588,18 +588,22 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
} }
return error; return error;
case NBD_SET_BLKSIZE: case NBD_SET_BLKSIZE:
if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE))
return -EINVAL;
lo->blksize = arg; lo->blksize = arg;
lo->bytesize &= ~(lo->blksize-1); lo->bytesize &= ~(lo->blksize-1);
inode->i_bdev->bd_inode->i_size = lo->bytesize;
set_blocksize(inode->i_bdev, lo->blksize);
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
case NBD_SET_SIZE: case NBD_SET_SIZE:
lo->bytesize = arg & ~(lo->blksize-1); lo->bytesize = arg & ~(lo->blksize-1);
inode->i_bdev->bd_inode->i_size = lo->bytesize;
set_blocksize(inode->i_bdev, lo->blksize);
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
case NBD_SET_SIZE_BLOCKS: case NBD_SET_SIZE_BLOCKS:
lo->bytesize = ((u64) arg) * lo->blksize; lo->bytesize = ((u64) arg) * lo->blksize;
inode->i_bdev->bd_inode->i_size = lo->bytesize;
set_blocksize(inode->i_bdev, lo->blksize);
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
case NBD_DO_IT: case NBD_DO_IT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment