nvmet: fix tmpfs-based backstores support
Subsystems (2)
RFC PATCH 1/1 nvmet: fix tmpfs-based backstores support
commit 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O") optimized the read command behaviour when buffered file-ns configurations are used.
It issues the read commands with the IOCB_NOWAIT flag set to try to access the data from the cache.
However, the patch was buggy because both read and write commands are issued with IOCB_NOWAIT, this broke tmpfs-based backstores because tmpfs doesn't accept write commands with IOCB_NOWAIT.
Fix this bug by restricting IOCB_NOWAIT to read commands only.
--- drivers/nvme/target/io-cmd-file.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/target/io-cmd-file.c +1 -0
@@ -266,6 +266,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)if (req->ns->buffered_io) {if (likely (!req->f.mpool_alloc) && + req->cmd->rw.opcode == nvme_cmd_read &&nvmet_file_execute_io (req,IOCB_NOWAIT ))return ;nvmet_file_submit_buffered_io (req);
Signature · 1 line
2.27.0
Quoted 5 lines · Maurizio Lombardi
External email: Use caution opening links or attachments
commit
50a909db36f2("nvmet: useIOCB_NOWAITfor file-ns buffered I/O") optimized the read command behaviour when buffered file-ns
s/behaviour/behavior
Quoted 8 lines
configurations are used.
It issues the read commands with theIOCB_NOWAITflag set to try to access the data from the cache.However, the patch was buggy because both read and write commands are issued with
IOCB_NOWAIT, this broke tmpfs-based backstores because tmpfs doesn't accept write commands withIOCB_NOWAIT.
Quoted 5 lines
Fix this bug by restricting
IOCB_NOWAITto read commands only.Fixes 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O")Signed-off-by Maurizio Lombardi <[email protected]>
We will need blktests for this.
Also, can you share performance numbers with this patch and the errors that you are getting without this patch ?
Quoted 19 lines
--- drivers/nvme/target/io-cmd-file.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/target/io-cmd-file.c +1
-1@@ -266,6 +266,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)if (req->ns->buffered_io) {if (likely (!req->f.mpool_alloc) && + req->cmd->rw.opcode == nvme_cmd_read &&nvmet_file_execute_io (req,IOCB_NOWAIT ))return ;nvmet_file_submit_buffered_io (req); --2.27.0
Quoted 4 lines · Chaitanya Kulkarni
We will need blktests for this.
Also, can you share performance numbers with this patch and the errors that you are getting without this patch ?
Ok, I will try to run blktests and provide some performance numbers.
Without this patch, writes get lost:
[root@kvm-02-guest03 ~]# nvme connect -t tcp -a 10.37.153.75 -n test-nqn -s 4080 [root@kvm-02-guest03 ~]# dd if=/dev/urandom of=/dev/nvme0n1 bs=1M count=1 1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0604551 s, 17.3 MB/s [root@kvm-02-guest03 ~]# hexdump -C /dev/nvme0n1
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| *
06400000
dmesg output:
[81489.687548] blk_update_request: critical target error, dev nvme0c0n1, sector 0 op 0x1:(WRITE) flags 0x2000800 phys_seg 256 prio class 0 [81489.691139] buffer_io_error: 246 callbacks suppressed [81489.691141] Buffer I/O error on dev nvme0n1, logical block 0, lost async page write [81489.695013] Buffer I/O error on dev nvme0n1, logical block 1, lost async page write [81489.697183] Buffer I/O error on dev nvme0n1, logical block 2, lost async page write [81489.699239] Buffer I/O error on dev nvme0n1, logical block 3, lost async page write [81489.701297] Buffer I/O error on dev nvme0n1, logical block 4, lost async page write [81489.703374] Buffer I/O error on dev nvme0n1, logical block 5, lost async page write [81489.705459] Buffer I/O error on dev nvme0n1, logical block 6, lost async page write [81489.707511] Buffer I/O error on dev nvme0n1, logical block 7, lost async page write [81489.709438] Buffer I/O error on dev nvme0n1, logical block 8, lost async page write [81489.711364] Buffer I/O error on dev nvme0n1, logical block 9, lost async page write
Maurizio
Quoted 38 lines · Maurizio Lombardi
External email: Use caution opening links or attachments
Quoted 4 lines · Chaitanya Kulkarni
We will need blktests for this.
Also, can you share performance numbers with this patch and the errors that you are getting without this patch ?
Ok, I will try to run blktests and provide some performance numbers.
Without this patch, writes get lost:
[root@kvm-02-guest03 ~]# nvme connect -t tcp -a 10.37.153.75 -n test-nqn -s 4080 [root@kvm-02-guest03 ~]# dd if=/dev/urandom of=/dev/nvme0n1 bs=1M count=1 1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0604551 s, 17.3 MB/s [root@kvm-02-guest03 ~]# hexdump -C/dev/nvme0n1
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| *
06400000dmesg output:
[81489.687548] blk_update_request: critical target error, dev nvme0c0n1, sector 0 op 0x1:(WRITE) flags 0x2000800 phys_seg 256 prio class 0 [81489.691139] buffer_io_error: 246 callbacks suppressed [81489.691141] Buffer I/O error on dev nvme0n1, logical block 0, lost async page write [81489.695013] Buffer I/O error on dev nvme0n1, logical block 1, lost async page write [81489.697183] Buffer I/O error on dev nvme0n1, logical block 2, lost async page write [81489.699239] Buffer I/O error on dev nvme0n1, logical block 3, lost async page write [81489.701297] Buffer I/O error on dev nvme0n1, logical block 4, lost async page write [81489.703374] Buffer I/O error on dev nvme0n1, logical block 5, lost async page write [81489.705459] Buffer I/O error on dev nvme0n1, logical block 6, lost async page write [81489.707511] Buffer I/O error on dev nvme0n1, logical block 7, lost async page write [81489.709438] Buffer I/O error on dev nvme0n1, logical block 8, lost async page write [81489.711364] Buffer I/O error on dev nvme0n1, logical block 9, lost async page write
Quoted 2 lines
Maurizio
Thanks for the prompt reply and sharing this ..
Please send a formal-patch (non-RFC) with the testing done.
Quoted 6 lines · Maurizio Lombardi
External email: Use caution opening links or attachments
Quoted 2 lines · Chaitanya Kulkarni
We will need blktests for this.
One more thing you need to add a new block tests with the configuration that you have used to find this problem so it will get tested every release.
Quoted 4 lines · Chaitanya Kulkarni
One more thing you need to add a new block tests with the configuration that you have used to find this problem so it will get tested every release.
Ok, will do.
Maurizio
Christoph Hellwig
maintainerThe proper fix is to check if the file has FMODE_NOWAIT is set before using FMODE_NOWAIT for reads or writes, not to blindly disable it for reads.
Quoted 4 lines · Christoph Hellwig
The proper fix is to check if the file has
FMODE_NOWAITis set before usingFMODE_NOWAITfor reads or writes, not to blindly disable it for reads.
Ah thanks for the info!
Now I see that filesystems that support NOWAIT set the FMODE_NOWAIT flag in their open() functions.
So the correct patch should be the following:
drivers/nvme/target/io-cmd-file.c +1 -0
@@ -266,6 +266,7 @@ static void nvmet_file_execute_rw(struct nvmet_req *req)if (req->ns->buffered_io) {if (likely (!req->f.mpool_alloc) && + (req->ns->file->f_mode &FMODE_NOWAIT ) &&nvmet_file_execute_io (req,IOCB_NOWAIT ))return ;nvmet_file_submit_buffered_io (req);
I'm going to test it.
Maurizio