Skip to content

Commit

Permalink
block: don't call blk_status_to_errno in blk_update_request
Browse files Browse the repository at this point in the history
We only need to call it to resolve the blk_status_t -> errno mapping for
tracing, so move the conversion into the tracepoints that are not called
at all when tracing isn't enabled.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Oct 19, 2021
1 parent db9a02b commit 8a7d267
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ bool blk_update_request(struct request *req, blk_status_t error,
{
int total_bytes;

trace_block_rq_complete(req, blk_status_to_errno(error), nr_bytes);
trace_block_rq_complete(req, error, nr_bytes);

if (!req->bio)
return false;
Expand Down
6 changes: 3 additions & 3 deletions include/trace/events/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ TRACE_EVENT(block_rq_requeue,
*/
TRACE_EVENT(block_rq_complete,

TP_PROTO(struct request *rq, int error, unsigned int nr_bytes),
TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),

TP_ARGS(rq, error, nr_bytes),

TP_STRUCT__entry(
__field( dev_t, dev )
__field( sector_t, sector )
__field( unsigned int, nr_sector )
__field( int, error )
__field( int , error )
__array( char, rwbs, RWBS_LEN )
__dynamic_array( char, cmd, 1 )
),
Expand All @@ -131,7 +131,7 @@ TRACE_EVENT(block_rq_complete,
__entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
__entry->sector = blk_rq_pos(rq);
__entry->nr_sector = nr_bytes >> 9;
__entry->error = error;
__entry->error = blk_status_to_errno(error);

blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
__get_str(cmd)[0] = '\0';
Expand Down
7 changes: 4 additions & 3 deletions kernel/trace/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ blk_trace_request_get_cgid(struct request *rq)
* Records an action against a request. Will log the bio offset + size.
*
**/
static void blk_add_trace_rq(struct request *rq, int error,
static void blk_add_trace_rq(struct request *rq, blk_status_t error,
unsigned int nr_bytes, u32 what, u64 cgid)
{
struct blk_trace *bt;
Expand All @@ -834,7 +834,8 @@ static void blk_add_trace_rq(struct request *rq, int error,
what |= BLK_TC_ACT(BLK_TC_FS);

__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq),
rq->cmd_flags, what, error, 0, NULL, cgid);
rq->cmd_flags, what, blk_status_to_errno(error), 0,
NULL, cgid);
rcu_read_unlock();
}

Expand Down Expand Up @@ -863,7 +864,7 @@ static void blk_add_trace_rq_requeue(void *ignore, struct request *rq)
}

static void blk_add_trace_rq_complete(void *ignore, struct request *rq,
int error, unsigned int nr_bytes)
blk_status_t error, unsigned int nr_bytes)
{
blk_add_trace_rq(rq, error, nr_bytes, BLK_TA_COMPLETE,
blk_trace_request_get_cgid(rq));
Expand Down

0 comments on commit 8a7d267

Please sign in to comment.