public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nbd: clear wb_err in bd_inode on disconnect
@ 2021-09-07 12:14 Xie Yongji
  2021-09-09  6:31 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Xie Yongji @ 2021-09-07 12:14 UTC (permalink / raw)
  To: josef, axboe; +Cc: linux-block, nbd, yixingchen

When a nbd device encounters a writeback error, that error will
get propagated to the bd_inode's wb_err field. Then if this nbd
device's backend is disconnected and another is attached, we will
get back the previous writeback error on fsync, which is unexpected.
To fix it, let's clear out the wb_err on disconnect.

Reported-by: Yi Xingchen <yixingchen@bytedance.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 5170a630778d..e6aa804db541 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1233,6 +1233,7 @@ static void nbd_config_put(struct nbd_device *nbd)
 		struct nbd_config *config = nbd->config;
 		nbd_dev_dbg_close(nbd);
 		nbd_size_clear(nbd);
+		nbd->disk->part0->bd_inode->i_mapping->wb_err = 0;
 		if (test_and_clear_bit(NBD_RT_HAS_PID_FILE,
 				       &config->runtime_flags))
 			device_remove_file(disk_to_dev(nbd->disk), &pid_attr);
-- 
2.11.0


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

end of thread, other threads:[~2021-09-09 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-07 12:14 [PATCH] nbd: clear wb_err in bd_inode on disconnect Xie Yongji
2021-09-09  6:31 ` Christoph Hellwig
2021-09-09 12:34   ` Yongji Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox