Message ID | 6b97348b06a238c982560ba789a75e03234f48aa.1527005026.git.joseph.salisbury@canonical.com |
---|---|
State | New |
Headers | show |
Series | nbd: use loff_t for blocksize and nbd_set_size args | expand |
On 05/23/18 10:48, Joseph Salisbury wrote: > From: Josef Bacik <jbacik@fb.com> > > BugLink: http://bugs.launchpad.net/bugs/1772575 > > If we have large devices (say like the 40t drive I was trying to test with) we > will end up overflowing the int arguments to nbd_set_size and not get the right > size for our device. Fix this by using loff_t everywhere so I don't have to > think about this again. Thanks, > > Signed-off-by: Josef Bacik <jbacik@fb.com> > Signed-off-by: Jens Axboe <axboe@fb.com> > (back ported from commit ef77b515243b3499d62cf446eda6ca7e0a0b079c) > Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> > --- > drivers/block/nbd.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 5f807a6..673632c 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -54,7 +54,7 @@ struct nbd_device { > > struct mutex tx_lock; > struct gendisk *disk; > - int blksize; > + loff_t blksize; > loff_t bytesize; > int xmit_timeout; > bool disconnect; /* a disconnect has been requested by user */ > @@ -135,7 +135,7 @@ static void nbd_size_update(struct nbd_device *nbd, struct block_device *bdev) > } > > static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, > - int blocksize, int nr_blocks) > + loff_t blocksize, loff_t nr_blocks) > { > int ret; > > @@ -144,7 +144,7 @@ static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, > return ret; > > nbd->blksize = blocksize; > - nbd->bytesize = (loff_t)blocksize * (loff_t)nr_blocks; > + nbd->bytesize = blocksize * nr_blocks; > > nbd_size_update(nbd, bdev); > > @@ -959,7 +959,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd) > return PTR_ERR(f); > } > > - f = debugfs_create_u32("blocksize", 0444, dir, &nbd->blksize); > + f = debugfs_create_u64("blocksize", 0444, dir, &nbd->blksize); > if (IS_ERR_OR_NULL(f)) { > dev_err(nbd_to_dev(nbd), "Failed to create debugfs file 'blocksize', %ld\n", > PTR_ERR(f)); >
On 05/23/2018 07:48 PM, Joseph Salisbury wrote: > From: Josef Bacik <jbacik@fb.com> > > BugLink: http://bugs.launchpad.net/bugs/1772575 > > If we have large devices (say like the 40t drive I was trying to test with) we > will end up overflowing the int arguments to nbd_set_size and not get the right > size for our device. Fix this by using loff_t everywhere so I don't have to > think about this again. Thanks, > > Signed-off-by: Josef Bacik <jbacik@fb.com> > Signed-off-by: Jens Axboe <axboe@fb.com> > (back ported from commit ef77b515243b3499d62cf446eda6ca7e0a0b079c) > Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com> Acked-by: Juerg Haefliger <juergh@canonical.com> Applied to xenial/master-next. ...Juerg > --- > drivers/block/nbd.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 5f807a6..673632c 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -54,7 +54,7 @@ struct nbd_device { > > struct mutex tx_lock; > struct gendisk *disk; > - int blksize; > + loff_t blksize; > loff_t bytesize; > int xmit_timeout; > bool disconnect; /* a disconnect has been requested by user */ > @@ -135,7 +135,7 @@ static void nbd_size_update(struct nbd_device *nbd, struct block_device *bdev) > } > > static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, > - int blocksize, int nr_blocks) > + loff_t blocksize, loff_t nr_blocks) > { > int ret; > > @@ -144,7 +144,7 @@ static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, > return ret; > > nbd->blksize = blocksize; > - nbd->bytesize = (loff_t)blocksize * (loff_t)nr_blocks; > + nbd->bytesize = blocksize * nr_blocks; > > nbd_size_update(nbd, bdev); > > @@ -959,7 +959,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd) > return PTR_ERR(f); > } > > - f = debugfs_create_u32("blocksize", 0444, dir, &nbd->blksize); > + f = debugfs_create_u64("blocksize", 0444, dir, &nbd->blksize); > if (IS_ERR_OR_NULL(f)) { > dev_err(nbd_to_dev(nbd), "Failed to create debugfs file 'blocksize', %ld\n", > PTR_ERR(f)); >
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 5f807a6..673632c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -54,7 +54,7 @@ struct nbd_device { struct mutex tx_lock; struct gendisk *disk; - int blksize; + loff_t blksize; loff_t bytesize; int xmit_timeout; bool disconnect; /* a disconnect has been requested by user */ @@ -135,7 +135,7 @@ static void nbd_size_update(struct nbd_device *nbd, struct block_device *bdev) } static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, - int blocksize, int nr_blocks) + loff_t blocksize, loff_t nr_blocks) { int ret; @@ -144,7 +144,7 @@ static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, return ret; nbd->blksize = blocksize; - nbd->bytesize = (loff_t)blocksize * (loff_t)nr_blocks; + nbd->bytesize = blocksize * nr_blocks; nbd_size_update(nbd, bdev); @@ -959,7 +959,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd) return PTR_ERR(f); } - f = debugfs_create_u32("blocksize", 0444, dir, &nbd->blksize); + f = debugfs_create_u64("blocksize", 0444, dir, &nbd->blksize); if (IS_ERR_OR_NULL(f)) { dev_err(nbd_to_dev(nbd), "Failed to create debugfs file 'blocksize', %ld\n", PTR_ERR(f));