Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,36 +1088,6 @@ static inline void blk_account_io_done(struct request *req, u64 now)
}
}

static inline bool blk_rq_passthrough_stats(struct request *req)
{
struct bio *bio = req->bio;

if (!blk_queue_passthrough_stat(req->q))
return false;

/* Requests without a bio do not transfer data. */
if (!bio)
return false;

/*
* Stats are accumulated in the bdev, so must have one attached to a
* bio to track stats. Most drivers do not set the bdev for passthrough
* requests, but nvme is one that will set it.
*/
if (!bio->bi_bdev)
return false;

/*
* We don't know what a passthrough command does, but we know the
* payload size and data direction. Ensuring the size is aligned to the
* block size filters out most commands with payloads that don't
* represent sector access.
*/
if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
return false;
return true;
}

static inline void blk_account_io_start(struct request *req)
{
trace_block_io_start(req);
Expand Down
4 changes: 3 additions & 1 deletion drivers/nvme/host/multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ void nvme_mpath_start_request(struct request *rq)
nvme_req(rq)->flags |= NVME_MPATH_CNT_ACTIVE;
}

if (!blk_queue_io_stat(disk->queue) || blk_rq_is_passthrough(rq) ||
if (!blk_queue_io_stat(disk->queue) ||
(nvme_req(rq)->flags & NVME_MPATH_IO_STATS))
return;
if (blk_rq_is_passthrough(rq) && !blk_rq_passthrough_stats(rq))
return;

nvme_req(rq)->flags |= NVME_MPATH_IO_STATS;
nvme_req(rq)->start_time = bdev_start_io_acct(disk->part0, req_op(rq),
Expand Down
29 changes: 29 additions & 0 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -1243,4 +1243,33 @@ static inline int blk_rq_map_sg(struct request *rq, struct scatterlist *sglist)
}
void blk_dump_rq_flags(struct request *, char *);

static inline bool blk_rq_passthrough_stats(struct request *req)
{
struct bio *bio = req->bio;

if (!blk_queue_passthrough_stat(req->q))
return false;

/* Requests without a bio do not transfer data. */
if (!bio)
return false;

/*
* Stats are accumulated in the bdev, so must have one attached to a
* bio to track stats. Most drivers do not set the bdev for passthrough
* requests, but nvme is one that will set it.
*/
if (!bio->bi_bdev)
return false;

/*
* We don't know what a passthrough command does, but we know the
* payload size and data direction. Ensuring the size is aligned to the
* block size filters out most commands with payloads that don't
* represent sector access.
*/
if (blk_rq_bytes(req) & (bdev_logical_block_size(bio->bi_bdev) - 1))
return false;
return true;
}
#endif /* BLK_MQ_H */