Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: adobriyan@gmail.com
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH] null_blk: initialize cmd->error before use
Date: Fri, 14 Feb 2020 19:19:50 -0800
Message-ID: <20200215031950.6688-1-chaitanya.kulkarni@wdc.com> (raw)

[-- Warning: decoded text below may be mangled --]
[-- Attachment #0: Type: text/plain; charset=y, Size: 7832 bytes --]

From : Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>

null_blk driver supports bio and request mode. For each mode when
processing a new request initialize cmd->error to BLK_STS_OK so that in 
the completion function it will indicate success by default instead of
using previously recorded error if any.

Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
Simple test log :-

1. Without Patch :- 
 # dd if=/dev/zero of=/dev/nullb0 bs=4k count=4096
 4096+0 records in
 4096+0 records out
 16777216 bytes (17 MB) copied, 0.262258 s, 64.0 MB/s
 # dmesg  -c 
1.1 Now write again to generate an error :-
 # dd if=/dev/zero of=/dev/nullb0 bs=4k count=4096
 4096+0 records in
 4096+0 records out
 16777216 bytes (17 MB) copied, 0.283751 s, 59.1 MB/s
 # dmesg  -c 
 [  600.946406] print_req_error: 3512 callbacks suppressed
 [   600.946409] blk_update_request: I/O error, dev nullb0, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  600.947701] buffer_io_error: 4086 callbacks suppressed
 [  600.947703] Buffer I/O error on dev nullb0, logical block 0, lost async page write
 [  600.949694] blk_update_request: I/O error, dev nullb0, sector 8 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.952283] Buffer I/O error on dev nullb0, logical block 1, lost async page write
 [  600.954002] Buffer I/O error on dev nullb0, logical block 2, lost async page write
 [  600.955722] Buffer I/O error on dev nullb0, logical block 3, lost async page write
 [  600.957472] Buffer I/O error on dev nullb0, logical block 4, lost async page write
 [  600.959228] Buffer I/O error on dev nullb0, logical block 5, lost async page write
 [  600.960622] Buffer I/O error on dev nullb0, logical block 6, lost async page write
 [  600.961587] Buffer I/O error on dev nullb0, logical block 7, lost async page write
 [  600.962529] Buffer I/O error on dev nullb0, logical block 8, lost async page write
 [  600.963473] Buffer I/O error on dev nullb0, logical block 9, lost async page write
 [  600.964574] blk_update_request: I/O error, dev nullb0, sector 256 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.966079] blk_update_request: I/O error, dev nullb0, sector 504 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.967897] blk_update_request: I/O error, dev nullb0, sector 752 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.969464] blk_update_request: I/O error, dev nullb0, sector 1000 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.972423] blk_update_request: I/O error, dev nullb0, sector 1248 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.975262] blk_update_request: I/O error, dev nullb0, sector 1496 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.977683] blk_update_request: I/O error, dev nullb0, sector 1744 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  600.979164] blk_update_request: I/O error, dev nullb0, sector 1992 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 # dd of=/dev/null if=/dev/nullb0 bs=4k count=100
 100+0 records in
 100+0 records out
 409600 bytes (410 kB) copied, 0.00286957 s, 143 MB/s
 # dmesg  -c 
 
1.2 Read from the device and expect an error :- 
 # dd of=/dev/null if=/dev/nullb0 bs=4k count=100
 dd: error reading ‘/dev/nullb0’: Input/output error
 92+0 records in
 92+0 records out
 376832 bytes (377 kB) copied, 0.0127975 s, 29.4 MB/s
 # dmesg  -c 
 [  633.362252] print_req_error: 3540 callbacks suppressed
 [  633.362261] blk_update_request: I/O error, dev nullb0, sector 984 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
 [  633.363834] blk_update_request: I/O error, dev nullb0, sector 992 op 0x0:(READ) flags 0x84700 phys_seg 23 prio class 0
 [  633.365366] blk_update_request: I/O error, dev nullb0, sector 1240 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
 [  633.365449] blk_update_request: I/O error, dev nullb0, sector 736 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
 [  633.368981] buffer_io_error: 4087 callbacks suppressed
 [  633.368983] Buffer I/O error on dev nullb0, logical block 92, async page read

2. With patch :-
 # dd if=/dev/zero of=/dev/nullb0 bs=4k count=4096
 4096+0 records in
 4096+0 records out
 16777216 bytes (17 MB) copied, 0.270187 s, 62.1 MB/s
 # dmesg  -c 

2.1 Now write again to generate an error :-
 # dd if=/dev/zero of=/dev/nullb0 bs=4k count=4096
 4096+0 records in
 4096+0 records out
 16777216 bytes (17 MB) copied, 0.464682 s, 36.1 MB/s
 # dmesg  -c 
 [  696.630879] blk_update_request: I/O error, dev nullb0, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.632550] Buffer I/O error on dev nullb0, logical block 0, lost async page write
 [  696.633733] blk_update_request: I/O error, dev nullb0, sector 8 op 0x1:(WRITE) flags 0x800 phys_seg 23 prio class 0
 [  696.636239] Buffer I/O error on dev nullb0, logical block 1, lost async page write
 [  696.637996] Buffer I/O error on dev nullb0, logical block 2, lost async page write
 [  696.639718] Buffer I/O error on dev nullb0, logical block 3, lost async page write
 [  696.641455] Buffer I/O error on dev nullb0, logical block 4, lost async page write
 [  696.643151] Buffer I/O error on dev nullb0, logical block 5, lost async page write
 [  696.644821] Buffer I/O error on dev nullb0, logical block 6, lost async page write
 [  696.645827] Buffer I/O error on dev nullb0, logical block 7, lost async page write
 [  696.646828] Buffer I/O error on dev nullb0, logical block 8, lost async page write
 [  696.647843] Buffer I/O error on dev nullb0, logical block 9, lost async page write
 [  696.649017] blk_update_request: I/O error, dev nullb0, sector 192 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.650580] blk_update_request: I/O error, dev nullb0, sector 200 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.652030] blk_update_request: I/O error, dev nullb0, sector 208 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.653491] blk_update_request: I/O error, dev nullb0, sector 216 op 0x1:(WRITE) flags 0x800 phys_seg 23 prio class 0
 [  696.656347] blk_update_request: I/O error, dev nullb0, sector 400 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.658912] blk_update_request: I/O error, dev nullb0, sector 408 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 0
 [  696.661490] blk_update_request: I/O error, dev nullb0, sector 416 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
 [  696.665040] blk_update_request: I/O error, dev nullb0, sector 664 op 0x1:(WRITE) flags 0x4800 phys_seg 31 prio class 0
2.2 Read from the device with no error :- 
 # dd of=/dev/null if=/dev/nullb0 bs=4k count=100
 100+0 records in
 100+0 records out
 409600 bytes (410 kB) copied, 0.00504116 s, 81.3 MB/s
 # dmesg  -c 
 # dmesg  -c
2.3 Read from the device with no error :- 
 # dd of=/dev/null if=/dev/nullb0 bs=4k count=100
 100+0 records in
 100+0 records out
 409600 bytes (410 kB) copied, 0.00435289 s, 94.1 MB/s
 # dmesg  -c

---
 drivers/block/null_blk_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 16510795e377..3bf9c05f9825 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -606,6 +606,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
 		cmd = &nq->cmds[tag];
 		cmd->tag = tag;
 		cmd->nq = nq;
+		cmd->error = BLK_STS_OK;
 		if (nq->dev->irqmode == NULL_IRQ_TIMER) {
 			hrtimer_init(&cmd->timer, CLOCK_MONOTONIC,
 				     HRTIMER_MODE_REL);
@@ -1385,6 +1386,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
 		cmd->timer.function = null_cmd_timer_expired;
 	}
 	cmd->rq = bd->rq;
+	cmd->error = BLK_STS_OK;
 	cmd->nq = nq;
 
 	blk_mq_start_request(bd->rq);
-- 
2.22.1


                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200215031950.6688-1-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=adobriyan@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git