linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nbd: do not update block size if file system is mounted
@ 2018-02-28  9:54 Michael Tretter
  2018-03-15 10:00 ` Michael Tretter
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Tretter @ 2018-02-28  9:54 UTC (permalink / raw)
  To: linux-block; +Cc: Josef Bacik, kernel, Michael Tretter

If a file system is mounted on the nbd during a disconnect, resetting
the size to 0, might change the block size and destroy the buffer_head
mappings. This will cause a infinite loop when the file system looks for
the buffer_heads for flushing.

Only set the file size to 0, if we are the only opener of the nbd.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/block/nbd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 5f2a4240a204..0d1dbb60430b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1118,7 +1118,8 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
 	if (ret)
 		sock_shutdown(nbd);
 	mutex_lock(&nbd->config_lock);
-	bd_set_size(bdev, 0);
+	if (bdev->bd_openers <= 1)
+		bd_set_size(bdev, 0);
 	/* user requested, ignore socket errors */
 	if (test_bit(NBD_DISCONNECT_REQUESTED, &config->runtime_flags))
 		ret = 0;
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-15  8:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28  9:54 [PATCH] nbd: do not update block size if file system is mounted Michael Tretter
2018-03-15 10:00 ` Michael Tretter
2018-03-16 16:36   ` Jens Axboe
2018-04-13 14:25     ` Michael Tretter
2018-04-14  1:10       ` Josef Bacik
2018-04-17  9:15         ` Michael Tretter
2018-05-15  8:44           ` Michael Tretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).