Skip to content

Commit fb9b16e

Browse files
keithbuschaxboe
authored andcommitted
block: return errors from blk_execute_rq()
The synchronous blk_execute_rq() had not provided a way for its callers to know if its request was successful or not. Return the blk_status_t result of the request. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210610214437.641245-4-kbusch@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent be42a33 commit fb9b16e

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

block/blk-exec.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void blk_end_sync_rq(struct request *rq, blk_status_t error)
2121
{
2222
struct completion *waiting = rq->end_io_data;
2323

24-
rq->end_io_data = NULL;
24+
rq->end_io_data = (void *)(uintptr_t)error;
2525

2626
/*
2727
* complete last, if this is a stack request the process (and thus
@@ -85,8 +85,9 @@ static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
8585
* Description:
8686
* Insert a fully prepared request at the back of the I/O scheduler queue
8787
* for execution and wait for completion.
88+
* Return: The blk_status_t result provided to blk_mq_end_request().
8889
*/
89-
void blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head)
90+
blk_status_t blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head)
9091
{
9192
DECLARE_COMPLETION_ONSTACK(wait);
9293
unsigned long hang_check;
@@ -103,5 +104,7 @@ void blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head)
103104
while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2)));
104105
else
105106
wait_for_completion_io(&wait);
107+
108+
return (blk_status_t)(uintptr_t)rq->end_io_data;
106109
}
107110
EXPORT_SYMBOL(blk_execute_rq);

include/linux/blkdev.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,12 @@ extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, uns
909909
extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
910910
struct rq_map_data *, const struct iov_iter *,
911911
gfp_t);
912-
extern void blk_execute_rq(struct gendisk *, struct request *, int);
913912
extern void blk_execute_rq_nowait(struct gendisk *,
914913
struct request *, int, rq_end_io_fn *);
915914

915+
blk_status_t blk_execute_rq(struct gendisk *bd_disk, struct request *rq,
916+
int at_head);
917+
916918
/* Helper to convert REQ_OP_XXX to its string format XXX */
917919
extern const char *blk_op_str(unsigned int op);
918920

0 commit comments

Comments
 (0)