From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180413160334.5496-3-josef@toxicpanda.com> References: <20180413160334.5496-1-josef@toxicpanda.com> <20180413160334.5496-3-josef@toxicpanda.com> From: Alex Gorbachev Date: Fri, 13 Apr 2018 23:01:28 -0400 Message-ID: Subject: Re: [PATCH 3/3] nbd: use bd_set_size when updating disk size To: Josef Bacik Cc: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, Josef Bacik , stable@vger.kernel.org Content-Type: multipart/alternative; boundary="00000000000087cd8f0569c6343c" List-ID: --00000000000087cd8f0569c6343c Content-Type: text/plain; charset="UTF-8" On Fri, Apr 13, 2018 at 12:03 PM, Josef Bacik wrote: > From: Josef Bacik > > When we stopped relying on the bdev everywhere I broke updating the > block device size on the fly, which ceph relies on. We can't just do > set_capacity, we also have to do bd_set_size so things like parted will > notice the device size change. > The three patches Josef submitted today fix the problem with the online rbd-nbd expansion completely. Fixes: 29eaadc ("nbd: stop using the bdev everywhere") > cc: stable@vger.kernel.org Signed-off-by: Josef Bacik Tested-by: Alex Gorbachev > --- > drivers/block/nbd.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 1520383b12f6..61dd95aa47fa 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -231,9 +231,15 @@ static void nbd_size_clear(struct nbd_device *nbd) > static void nbd_size_update(struct nbd_device *nbd) > { > struct nbd_config *config = nbd->config; > + struct block_device *bdev = bdget_disk(nbd->disk, 0); > + > blk_queue_logical_block_size(nbd->disk->queue, config->blksize); > blk_queue_physical_block_size(nbd->disk->queue, config->blksize); > set_capacity(nbd->disk, config->bytesize >> 9); > + if (bdev) { > + bd_set_size(bdev, config->bytesize); > + bdput(bdev); > + } > kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); > } > @@ -1111,7 +1117,6 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b > if (ret) > return ret; > - bd_set_size(bdev, config->bytesize); > if (max_part) > bdev->bd_invalidated = 1; > mutex_unlock(&nbd->config_lock); > -- > 2.14.3 > > --00000000000087cd8f0569c6343c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On F= ri, Apr 13, 2018 at 12:03 PM, Josef Bacik <josef@toxicpanda.com>= wrote:
From: Josef Bacik <jbacik@fb.com>

When we stopped relying on the bdev everywhere I broke updating the
block device size on the fly, which ceph relies on.=C2=A0 We can't just= do
set_capacity, we also have to do bd_set_size so things like parted will
notice the device size change.

The thre= e patches Josef submitted today fix the problem with the online rbd-nbd exp= ansion completely.

=C2=A0
Fixes: 29eaadc (&qu= ot;nbd: stop using the bdev everywhere")
<= /blockquote>cc: stable@vger.kerne= l.org
Signed-off-by: Josef Bacik <jbacik@fb.c= om>
Tested-by: Alex Gorbachev <ag@iss-integration.com>
=C2=A0drivers/b= lock/nbd.c | 7 ++++++-
=C2=A01 fil= e changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers= /block/nbd.c b/drivers/block/nbd.c
index 1520383b12f6..61dd95aa47fa 100644
--- a/drivers/block/nbd.c
+= ++ b/drivers/block/nbd.c
@@ -231,9= +231,15 @@ static void nbd_size_clear(struct nbd_device *nbd)
=C2=A0static void nbd_size_update(struct nbd_d= evice *nbd)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct nbd_config *c= onfig =3D nbd->config;
+=C2=A0 = =C2=A0 =C2=A0 =C2=A0struct block_device *bdev =3D bdget_disk(nbd->disk, = 0);
+
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 blk_queue_logical_block_size(= nbd->disk->queue, config->blksize);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 blk_queue_physical_block_size(n= bd->disk->queue, config->blksize);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 set_capacity(nbd->disk, config->= ;bytesize >> 9);
+=C2=A0 =C2= =A0 =C2=A0 =C2=A0if (bdev) {
+=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bd_set_size(bdev, confi= g->bytesize);
+=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bdput(bdev);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 kobject_uevent(&nbd_to_dev= (nbd)->kobj, KOBJ_CHANGE);
=C2=A0}

@@ -1111,7 +1117,6 @= @ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_de= vice *b
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 if (ret)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ret;

-=C2=A0 =C2=A0 =C2= =A0 =C2=A0bd_set_size(bdev, config->bytesize);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (max_part)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 bdev->bd_invalidated =3D 1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mutex_unlock(&nbd->config_lock)= ;
--=C2=A0
2.= 14.3


--00000000000087cd8f0569c6343c-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: From: Josef Bacik To: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, alex@iss-integration.com Cc: Josef Bacik , stable@vger.kernel.org Subject: [PATCH 3/3] nbd: use bd_set_size when updating disk size Date: Fri, 13 Apr 2018 12:03:34 -0400 Message-Id: <20180413160334.5496-3-josef@toxicpanda.com> In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com> References: <20180413160334.5496-1-josef@toxicpanda.com> List-ID: From: Josef Bacik When we stopped relying on the bdev everywhere I broke updating the block device size on the fly, which ceph relies on. We can't just do set_capacity, we also have to do bd_set_size so things like parted will notice the device size change. Fixes: 29eaadc ("nbd: stop using the bdev everywhere") cc: stable@vger.kernel.org Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 1520383b12f6..61dd95aa47fa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -231,9 +231,15 @@ static void nbd_size_clear(struct nbd_device *nbd) static void nbd_size_update(struct nbd_device *nbd) { struct nbd_config *config = nbd->config; + struct block_device *bdev = bdget_disk(nbd->disk, 0); + blk_queue_logical_block_size(nbd->disk->queue, config->blksize); blk_queue_physical_block_size(nbd->disk->queue, config->blksize); set_capacity(nbd->disk, config->bytesize >> 9); + if (bdev) { + bd_set_size(bdev, config->bytesize); + bdput(bdev); + } kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); } @@ -1111,7 +1117,6 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b if (ret) return ret; - bd_set_size(bdev, config->bytesize); if (max_part) bdev->bd_invalidated = 1; mutex_unlock(&nbd->config_lock); -- 2.14.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com> References: <20180413160334.5496-1-josef@toxicpanda.com> From: Alex Gorbachev Date: Fri, 13 Apr 2018 23:03:12 -0400 Message-ID: Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue To: Josef Bacik Cc: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, Josef Bacik , stable@vger.kernel.org Content-Type: multipart/alternative; boundary="f4f5e80ecc14bbd6470569c63aa4" List-ID: --f4f5e80ecc14bbd6470569c63aa4 Content-Type: text/plain; charset="UTF-8" On Fri, Apr 13, 2018 at 12:03 PM, Josef Bacik wrote: > From: Josef Bacik > > This fixes a use after free bug, we need to do the del_gendisk after we > cleanup the queue on the device. > The three patches Josef submitted today fix the problem with the online rbd-nbd expansion completely. Fixes: c6a4759ea0c9 ("nbd: add device refcounting") > cc: stable@vger.kernel.org > Signed-off-by: Josef Bacik Tested-by: Alex Gorbachev > --- > drivers/block/nbd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 86258b00a1d4..e33da3e6aa20 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -174,8 +174,8 @@ static void nbd_dev_remove(struct nbd_device *nbd) > { > struct gendisk *disk = nbd->disk; > if (disk) { > - del_gendisk(disk); > blk_cleanup_queue(disk->queue); > + del_gendisk(disk); > blk_mq_free_tag_set(&nbd->tag_set); > disk->private_data = NULL; > put_disk(disk); > -- > 2.14.3 > > --f4f5e80ecc14bbd6470569c63aa4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
<= div dir=3D"ltr">
On Fri, Apr 13, 2018 at 12:03 PM, Josef Bacik <jose= f@toxicpanda.com> wrote:
From: Josef Bacik <jbacik@fb.com>

This fixes a use after free bug, we need to do the del_gendisk after we
cleanup the queue on the device.

The three patches Josef submitted today fix the = problem with the online rbd-nbd expansion completely.=C2=A0
=C2=A0 =C2=A0
Fixes: c6a4759ea0c9 ("nbd: add device refcounting")
cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@= fb.com>
Tested-by: Alex Gorbachev <ag@iss-integrat= ion.com>
---
<= /blockquote>=C2=A0drivers/block/nbd.c | 2 +-
=C2=A01 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers= /block/nbd.c b/drivers/block/nbd.c
index 86258b00a1d4..e33da3e6aa20 100644
--- a/drivers/block/nbd.c
+= ++ b/drivers/block/nbd.c
@@ -174,8= +174,8 @@ static void nbd_dev_remove(struct nbd_device *nbd)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct gendisk *disk =3D nbd->disk;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (disk) {<= br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0del_gendisk(disk);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 blk_cleanu= p_queue(disk->queue);
+=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0del_gendisk(disk);
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0.8ex;border-left:1px = solid rgb(204,204,204);border-right:1px solid rgb(204,204,204);padding-left= :1ex;padding-right:1ex">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 blk_mq_free_tag_set(&nbd->tag_set);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 disk->private_data =3D NULL;
<= /blockquote>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 put_dis= k(disk);
--=C2=A0
2.= 14.3


--f4f5e80ecc14bbd6470569c63aa4-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Bart Van Assche To: "josef@toxicpanda.com" CC: "kernel-team@fb.com" , "jbacik@fb.com" , "linux-block@vger.kernel.org" , "alex@iss-integration.com" , "nbd@other.debian.org" , "axboe@kernel.dk" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Date: Fri, 13 Apr 2018 16:25:33 +0000 Message-ID: <1f0ebe74a96c6515716a25b49ea588f9ee28e137.camel@wdc.com> References: <20180413160334.5496-1-josef@toxicpanda.com> <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> <20180413162132.xudowhvxyijbzqqa@destiny> In-Reply-To: <20180413162132.xudowhvxyijbzqqa@destiny> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 List-ID: T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GluZyBpdCB0byB0aGUg d2F5DQo+IGV2ZXJ5Ym9keSBlbHNlIGRpZCBpdCBmaXhlZCB0aGUgcHJvYmxlbS4gIFRoYW5rcywN Cg0KSGVsbG8gSm9zZWYsDQoNCk9vcHMsIEkgc3dhcHBlZCAiYmxrX2NsZWFudXBfcXVldWUoKSIg YW5kICJkZWxfZ2VuZGlzaygpIiBpbiBteSBlLW1haWwuDQoNCkNhbiB5b3Ugc2hhcmUgdGhlIGNh bGwgc3RhY2sgb2YgdGhlIE5VTEwgcG9pbnRlciBkZXJlZiBhbmQgYWxzbyB0aGUgdHJhbnNsYXRp b24NCm9mIHRoZSBjcmFzaCBhZGRyZXNzIGludG8gYSBzb3VyY2UgY29kZSBsaW5lPw0KDQpUaGFu a3MsDQoNCkJhcnQuDQoNCg0K From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: Date: Fri, 13 Apr 2018 12:21:33 -0400 From: Josef Bacik To: Bart Van Assche Cc: "kernel-team@fb.com" , "linux-block@vger.kernel.org" , "josef@toxicpanda.com" , "nbd@other.debian.org" , "axboe@kernel.dk" , "alex@iss-integration.com" , "jbacik@fb.com" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Message-ID: <20180413162132.xudowhvxyijbzqqa@destiny> References: <20180413160334.5496-1-josef@toxicpanda.com> <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> List-ID: On Fri, Apr 13, 2018 at 04:16:18PM +0000, Bart Van Assche wrote: > On Fri, 2018-04-13 at 12:03 -0400, Josef Bacik wrote: > > This fixes a use after free bug, we need to do the del_gendisk after we > > cleanup the queue on the device. > > Hello Josef, > > Which use-after-free bug does this patch fix? Are you aware that most block > drivers call blk_cleanup_queue() before calling del_gendisk()? Why do you > think that the nbd driver should use the opposite order? > I'm confused, that's what this patch does. Before I had del_gendisk() first and then the blk_cleanup_queue(), which was bugging out when I was testing stuff with a null pointer deref whenever I rmmod'ed the nbd. Swapping it to the way everybody else did it fixed the problem. Thanks, Josef From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Bart Van Assche To: "kernel-team@fb.com" , "linux-block@vger.kernel.org" , "josef@toxicpanda.com" , "nbd@other.debian.org" , "axboe@kernel.dk" , "alex@iss-integration.com" CC: "jbacik@fb.com" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Date: Fri, 13 Apr 2018 16:16:18 +0000 Message-ID: <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> References: <20180413160334.5496-1-josef@toxicpanda.com> In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 List-ID: T24gRnJpLCAyMDE4LTA0LTEzIGF0IDEyOjAzIC0wNDAwLCBKb3NlZiBCYWNpayB3cm90ZToNCj4g VGhpcyBmaXhlcyBhIHVzZSBhZnRlciBmcmVlIGJ1Zywgd2UgbmVlZCB0byBkbyB0aGUgZGVsX2dl bmRpc2sgYWZ0ZXIgd2UNCj4gY2xlYW51cCB0aGUgcXVldWUgb24gdGhlIGRldmljZS4NCg0KSGVs bG8gSm9zZWYsDQoNCldoaWNoIHVzZS1hZnRlci1mcmVlIGJ1ZyBkb2VzIHRoaXMgcGF0Y2ggZml4 PyBBcmUgeW91IGF3YXJlIHRoYXQgbW9zdCBibG9jaw0KZHJpdmVycyBjYWxsIGJsa19jbGVhbnVw X3F1ZXVlKCkgYmVmb3JlIGNhbGxpbmcgZGVsX2dlbmRpc2soKT8gV2h5IGRvIHlvdQ0KdGhpbmsg dGhhdCB0aGUgbmJkIGRyaXZlciBzaG91bGQgdXNlIHRoZSBvcHBvc2l0ZSBvcmRlcj8NCg0KVGhh bmtzLA0KDQpCYXJ0Lg0KDQo= From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: From: Josef Bacik To: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, alex@iss-integration.com Cc: Josef Bacik , stable@vger.kernel.org Subject: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Date: Fri, 13 Apr 2018 12:03:32 -0400 Message-Id: <20180413160334.5496-1-josef@toxicpanda.com> List-ID: From: Josef Bacik This fixes a use after free bug, we need to do the del_gendisk after we cleanup the queue on the device. Fixes: c6a4759ea0c9 ("nbd: add device refcounting") cc: stable@vger.kernel.org Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 86258b00a1d4..e33da3e6aa20 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -174,8 +174,8 @@ static void nbd_dev_remove(struct nbd_device *nbd) { struct gendisk *disk = nbd->disk; if (disk) { - del_gendisk(disk); blk_cleanup_queue(disk->queue); + del_gendisk(disk); blk_mq_free_tag_set(&nbd->tag_set); disk->private_data = NULL; put_disk(disk); -- 2.14.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180413160334.5496-2-josef@toxicpanda.com> References: <20180413160334.5496-1-josef@toxicpanda.com> <20180413160334.5496-2-josef@toxicpanda.com> From: Alex Gorbachev Date: Fri, 13 Apr 2018 23:02:33 -0400 Message-ID: Subject: Re: [PATCH 2/3] nbd: update size when connected To: Josef Bacik Cc: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, Josef Bacik , stable@vger.kernel.org Content-Type: multipart/alternative; boundary="0000000000006172df0569c63832" List-ID: --0000000000006172df0569c63832 Content-Type: text/plain; charset="UTF-8" On Fri, Apr 13, 2018 at 12:03 PM, Josef Bacik wrote: > From: Josef Bacik > > I messed up changing the size of an NBD device while it was connected by > not actually updating the device or doing the uevent. Fix this by > updating everything if we're connected and we change the size. > The three patches Josef submitted today fix the problem with the online rbd-nbd expansion completely. cc: stable@vger.kernel.org > Fixes: 639812a ("nbd: don't set the device size until we're connected") > Signed-off-by: Josef Bacik Tested-by: Alex Gorbachev > --- > drivers/block/nbd.c | 2 ++ > 1 file changed, 2 insertions(+) > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index e33da3e6aa20..1520383b12f6 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -243,6 +243,8 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize, > struct nbd_config *config = nbd->config; > config->blksize = blocksize; > config->bytesize = blocksize * nr_blocks; > + if (nbd->task_recv != NULL) > + nbd_size_update(nbd); > } > static void nbd_complete_rq(struct request *req) > -- > 2.14.3 > > --0000000000006172df0569c63832 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On F= ri, Apr 13, 2018 at 12:03 PM, Josef Bacik <josef@toxicpanda.com>= wrote:
From: J= osef Bacik <jbacik@fb.com>

I messed up changing the size of an NBD device while it was connected by not actually updating the device or doing the uevent.=C2=A0 Fix this by
updating everything if we're connected and we change the size.

The three patches Josef submitted today fix the = problem with the online rbd-nbd expansion completely.
=C2=A0

cc: stable@vger.kernel.org
Fixes: 639812a ("nbd: don't set t= he device size until we're connected")
Signed-off-by: Josef Bacik <jbacik@fb.com>
Tested-by: Alex Gorbachev <ag@iss-integration.com>
---
<= /blockquote>=C2=A0drivers/block/nbd.c | 2 ++
=C2=A01 file changed, 2 insertions(+)

diff --git a/drivers= /block/nbd.c b/drivers/block/nbd.c
index e33da3e6aa20..1520383b12f6 100644
--- a/drivers/block/nbd.c
+= ++ b/drivers/block/nbd.c
@@ -243,6= +243,8 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksiz= e,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 str= uct nbd_config *config =3D nbd->config;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 config->blksize =3D blocksize;
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0.8ex;border-left:1px = solid rgb(204,204,204);border-right:1px solid rgb(204,204,204);padding-left= :1ex;padding-right:1ex">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 config->= ;bytesize =3D blocksize * nr_blocks;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (nbd->task_recv !=3D NULL)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0nbd_size_update(nbd);
=C2=A0}

=C2=A0static void nb= d_complete_rq(struct request *req)
--=C2=A0
2.= 14.3


--0000000000006172df0569c63832-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: From: Josef Bacik To: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com, alex@iss-integration.com Cc: Josef Bacik , stable@vger.kernel.org Subject: [PATCH 2/3] nbd: update size when connected Date: Fri, 13 Apr 2018 12:03:33 -0400 Message-Id: <20180413160334.5496-2-josef@toxicpanda.com> In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com> References: <20180413160334.5496-1-josef@toxicpanda.com> List-ID: From: Josef Bacik I messed up changing the size of an NBD device while it was connected by not actually updating the device or doing the uevent. Fix this by updating everything if we're connected and we change the size. cc: stable@vger.kernel.org Fixes: 639812a ("nbd: don't set the device size until we're connected") Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index e33da3e6aa20..1520383b12f6 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -243,6 +243,8 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize, struct nbd_config *config = nbd->config; config->blksize = blocksize; config->bytesize = blocksize * nr_blocks; + if (nbd->task_recv != NULL) + nbd_size_update(nbd); } static void nbd_complete_rq(struct request *req) -- 2.14.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa5.hgst.iphmx.com ([216.71.153.144]:50695 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752339AbeDMQZk (ORCPT ); Fri, 13 Apr 2018 12:25:40 -0400 From: Bart Van Assche To: "josef@toxicpanda.com" CC: "kernel-team@fb.com" , "jbacik@fb.com" , "linux-block@vger.kernel.org" , "alex@iss-integration.com" , "nbd@other.debian.org" , "axboe@kernel.dk" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Date: Fri, 13 Apr 2018 16:25:33 +0000 Message-ID: <1f0ebe74a96c6515716a25b49ea588f9ee28e137.camel@wdc.com> References: <20180413160334.5496-1-josef@toxicpanda.com> <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> <20180413162132.xudowhvxyijbzqqa@destiny> In-Reply-To: <20180413162132.xudowhvxyijbzqqa@destiny> Content-Language: en-US Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: T24gRnJpLCAyMDE4LTA0LTEzIGF0IDEyOjIxIC0wNDAwLCBKb3NlZiBCYWNpayB3cm90ZToNCj4g T24gRnJpLCBBcHIgMTMsIDIwMTggYXQgMDQ6MTY6MThQTSArMDAwMCwgQmFydCBWYW4gQXNzY2hl IHdyb3RlOg0KPiA+IE9uIEZyaSwgMjAxOC0wNC0xMyBhdCAxMjowMyAtMDQwMCwgSm9zZWYgQmFj aWsgd3JvdGU6DQo+ID4gPiBUaGlzIGZpeGVzIGEgdXNlIGFmdGVyIGZyZWUgYnVnLCB3ZSBuZWVk IHRvIGRvIHRoZSBkZWxfZ2VuZGlzayBhZnRlciB3ZQ0KPiA+ID4gY2xlYW51cCB0aGUgcXVldWUg b24gdGhlIGRldmljZS4NCj4gPiANCj4gPiBIZWxsbyBKb3NlZiwNCj4gPiANCj4gPiBXaGljaCB1 c2UtYWZ0ZXItZnJlZSB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.com ([216.71.153.141]:54888 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbeDMQQY (ORCPT ); Fri, 13 Apr 2018 12:16:24 -0400 From: Bart Van Assche To: "kernel-team@fb.com" , "linux-block@vger.kernel.org" , "josef@toxicpanda.com" , "nbd@other.debian.org" , "axboe@kernel.dk" , "alex@iss-integration.com" CC: "jbacik@fb.com" , "stable@vger.kernel.org" Subject: Re: [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Date: Fri, 13 Apr 2018 16:16:18 +0000 Message-ID: <0a8b3a85910e7bbe0103120e85844e96341d73ec.camel@wdc.com> References: <20180413160334.5496-1-josef@toxicpanda.com> In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com> Content-Language: en-US Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: T24gRnJpLCAyMDE4LTA0LTEzIGF0IDEyOjAzIC0wNDAwLCBKb3NlZiBCYWNpayB3cm90ZToNCj4g VGhpcyBmaXhlcyBhIHVzZSBhZnRlciBmcmVlIGJ1Zywgd2UgbmVlZCB0byBkbyB0aGUgZGVsX2dl bmRpc2sgYWZ0ZXIgd2UNCj4gY2xlYW51cCB0aGUgcXVldWUgb24gdGhlIGRldmljZS4NCg0KSGVs bG8gSm9zZWYsDQoNCldoaWNoIHVzZS1hZnRlci1mcmVlIGJ1ZyBkb2VzIHRoaXMgcGF0Y2ggZml4 PyBBcmUgeW91IGF3YXJlIHRoYXQgbW9zdCBibG9jaw0KZHJpdmVycyBjYWxsIGJsa19jbGVhbnVw X3F1ZXVlKCkgYmVmb3JlIGNhbGxpbmcgZGVsX2dlbmRpc2soKT8gV2h5IGRvIHlvdQ0KdGhpbmsg dGhhdCB0aGUgbmJkIGRyaXZlciBzaG91bGQgdXNlIHRoZSBvcHBvc2l0ZSBvcmRlcj8NCg0KVGhh bmtzLA0KDQpCYXJ0Lg0KDQo=