Skip to content

Commit 9a8d23d

Browse files
htejunJens Axboe
authored andcommitted
mg_disk: fix queue hang / infinite retry on !fs requests
Both request functions in mg_disk simply return when they encounter a !fs request, which means the request will never be cleared from the queue causing queue hang and indefinite retry of the request. Fix it. While at it, flatten condition checks and add unlikely to !fs tests. [ Impact: fix possible queue hang / infinite retry of !fs requests ] Signed-off-by: Tejun Heo <tj@kernel.org> Cc: unsik Kim <donari75@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 8f6205c commit 9a8d23d

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

‎drivers/block/mg_disk.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,16 @@ static void mg_request_poll(struct request_queue *q)
672672

673673
while ((req = elv_next_request(q)) != NULL) {
674674
host = req->rq_disk->private_data;
675-
if (blk_fs_request(req)) {
676-
switch (rq_data_dir(req)) {
677-
case READ:
678-
mg_read(req);
679-
break;
680-
case WRITE:
681-
mg_write(req);
682-
break;
683-
}
675+
676+
if (unlikely(!blk_fs_request(req))) {
677+
__blk_end_request_cur(req, -EIO);
678+
continue;
684679
}
680+
681+
if (rq_data_dir(req) == READ)
682+
mg_read(req);
683+
else
684+
mg_write(req);
685685
}
686686
}
687687

@@ -766,8 +766,10 @@ static void mg_request(struct request_queue *q)
766766
continue;
767767
}
768768

769-
if (!blk_fs_request(req))
770-
return;
769+
if (unlikely(!blk_fs_request(req))) {
770+
__blk_end_request_cur(req, -EIO);
771+
continue;
772+
}
771773

772774
if (!mg_issue_req(req, host, sect_num, sect_cnt))
773775
return;

0 commit comments

Comments
 (0)