2003-07-06 21:06:01

by Paul Clements

[permalink] [raw]
Subject: [PATCH 2.5.74-mm2] nbd: make nbd and block layer agree about device and block sizes

Andrew,

here's the revised patch for block and device size changes, using
set_blocksize() as Jeff suggested

Thanks,
Paul


Attachments:
nbd-block_layer_compat-2.diff (1.10 kB)

2003-07-06 21:24:25

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH 2.5.74-mm2] nbd: make nbd and block layer agree about device and block sizes

Paul Clements wrote:
> case NBD_SET_BLKSIZE:
> - if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE))
> - return -EINVAL;
> 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);
> return 0;
> 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);
> 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);
> set_capacity(lo->disk, lo->bytesize >> 9);
> return 0;
> case NBD_DO_IT:


Thanks. You forgot to check set_blocksize's return value for errors,
though.

Also, I wonder if you found a bug/oversight in set_blocksize -- it sets
bd_inode->i_blkbits but not bd_inode->i_size. I think it should set
i_size also. Maybe Andrew or Al can confirm/refute this assertion.

Jeff



2003-07-06 21:41:50

by Paul Clements

[permalink] [raw]
Subject: Re: [PATCH 2.5.74-mm2] nbd: make nbd and block layer agree about device and block sizes

On Sun, 6 Jul 2003, Jeff Garzik wrote:

> Paul Clements wrote:
> > case NBD_SET_BLKSIZE:
> > - if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE))
> > - return -EINVAL;
> > 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);
> > return 0;
> > 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);
> > 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);
> > set_capacity(lo->disk, lo->bytesize >> 9);
> > return 0;
> > case NBD_DO_IT:
>
>
> Thanks. You forgot to check set_blocksize's return value for errors,
> though.
>
> Also, I wonder if you found a bug/oversight in set_blocksize -- it sets
> bd_inode->i_blkbits but not bd_inode->i_size. I think it should set
> i_size also. Maybe Andrew or Al can confirm/refute this assertion.

OK, I'll wait for a response on this, and then redo the patch as appropriate...

--
Paul

2003-07-06 21:48:19

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH 2.5.74-mm2] nbd: make nbd and block layer agree about device and block sizes

Paul Clements wrote:
> On Sun, 6 Jul 2003, Jeff Garzik wrote:
>>Also, I wonder if you found a bug/oversight in set_blocksize -- it sets
>>bd_inode->i_blkbits but not bd_inode->i_size. I think it should set
>>i_size also. Maybe Andrew or Al can confirm/refute this assertion.
>
>
> OK, I'll wait for a response on this, and then redo the patch as appropriate...


No, nevermind. What I was said dumb ;-)

The inode's size should not be the block size.

Jeff



2003-07-06 21:49:40

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 2.5.74-mm2] nbd: make nbd and block layer agree about device and block sizes

Jeff Garzik <[email protected]> wrote:
>
> Also, I wonder if you found a bug/oversight in set_blocksize -- it sets
> bd_inode->i_blkbits but not bd_inode->i_size. I think it should set
> i_size also. Maybe Andrew or Al can confirm/refute this assertion.

set_blocksize() sets, err, the blocksize.

Lou was wanting to export bd_set_size() for setting i_size. But
bd_set_size() goes and tries to set the blocksize too.

So the patch as-is will do I think, unless someone feels there's a need to
go and rework these things.