* [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
* Re: [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
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
1 sibling, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2019-07-12 23:03 UTC (permalink / raw)
To: Logan Gunthorpe, linux-kernel; +Cc: Christoph Hellwig, Chaitanya Kulkarni
Looks good,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
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
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2019-07-13 7:26 UTC (permalink / raw)
To: Logan Gunthorpe
Cc: linux-kernel, Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni
On Fri, Jul 12, 2019 at 04:42:07PM -0600, Logan Gunthorpe wrote:
> 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.
Might it make more sense to handle 0 in errno_to_nvme_status to avoid
future problems like this one as well? That would also match the
similar blk_to_nvme_status function better.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmet-file: fix nvmet_file_flush() always returning an error
2019-07-13 7:26 ` Christoph Hellwig
@ 2019-07-13 20:10 ` Logan Gunthorpe
0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2019-07-13 20:10 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, Sagi Grimberg, Chaitanya Kulkarni
On 2019-07-13 1:26 a.m., Christoph Hellwig wrote:
> On Fri, Jul 12, 2019 at 04:42:07PM -0600, Logan Gunthorpe wrote:
>> 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.
>
> Might it make more sense to handle 0 in errno_to_nvme_status to avoid
> future problems like this one as well? That would also match the
> similar blk_to_nvme_status function better.
Sure, I'll send a v2 with that approach next week.
I had assumed that it was done this way for performance reasons so I
followed the way it was done in the other call sites.
Logan
^ permalink raw reply [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;
as well as URLs for NNTP newsgroup(s).