public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
@ 2019-07-12 22:42 Logan Gunthorpe
  2019-07-12 23:03 ` Sagi Grimberg
  2019-07-13  7:26 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2019-07-12 22:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: Christoph Hellwig, Sagi Grimberg, Logan Gunthorpe,
	Chaitanya Kulkarni

errno_to_nvme_status() doesn't take into account the case
when errno=0, all other use cases only call it if there is actually
an error.

Presently, nvmet_file_flush() always returns a call to
errno_to_nvme_status() so, even if it is successful, it will
return NVME_SC_INTERNAL.

This bug was found while trying to get the existing blktests to pass.

Fixes: c6aa3542e010 ("nvmet: add error log support for file backend")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/io-cmd-file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 05453f5d1448..fec17c66b8cd 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -261,7 +261,13 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)
 
 u16 nvmet_file_flush(struct nvmet_req *req)
 {
-	return errno_to_nvme_status(req, vfs_fsync(req->ns->file, 1));
+	int ret;
+
+	ret = vfs_fsync(req->ns->file, 1);
+	if (ret)
+		return errno_to_nvme_status(req, ret);
+
+	return NVME_SC_SUCCESS;
 }
 
 static void nvmet_file_flush_work(struct work_struct *w)
-- 
2.20.1


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

end of thread, other threads:[~2019-07-14 23:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-12 22:42 [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error Logan Gunthorpe
2019-07-12 23:03 ` Sagi Grimberg
2019-07-13  7:26 ` Christoph Hellwig
2019-07-13 20:10   ` Logan Gunthorpe

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