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
4 changes: 2 additions & 2 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ unsigned long bdev_start_io_acct(struct block_device *bdev, enum req_op op,
{
part_stat_lock();
update_io_ticks(bdev, start_time, false);
part_stat_local_inc(bdev, in_flight[op_is_write(op)]);
bdev_inc_in_flight(bdev, op);
part_stat_unlock();

return start_time;
Expand Down Expand Up @@ -1073,7 +1073,7 @@ void bdev_end_io_acct(struct block_device *bdev, enum req_op op,
part_stat_inc(bdev, ios[sgrp]);
part_stat_add(bdev, sectors[sgrp], sectors);
part_stat_add(bdev, nsecs[sgrp], jiffies_to_nsecs(duration));
part_stat_local_dec(bdev, in_flight[op_is_write(op)]);
bdev_inc_in_flight(bdev, op);
part_stat_unlock();
}
EXPORT_SYMBOL(bdev_end_io_acct);
Expand Down
5 changes: 2 additions & 3 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,7 @@ static inline void blk_account_io_done(struct request *req, u64 now)
update_io_ticks(req->part, jiffies, true);
part_stat_inc(req->part, ios[sgrp]);
part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns);
part_stat_local_dec(req->part,
in_flight[op_is_write(req_op(req))]);
bdev_dec_in_flight(req->part, req_op(req));
part_stat_unlock();
}
}
Expand Down Expand Up @@ -1143,7 +1142,7 @@ static inline void blk_account_io_start(struct request *req)

part_stat_lock();
update_io_ticks(req->part, jiffies, false);
part_stat_local_inc(req->part, in_flight[op_is_write(req_op(req))]);
bdev_inc_in_flight(req->part, req_op(req));
part_stat_unlock();
}

Expand Down
21 changes: 21 additions & 0 deletions block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <linux/bio-integrity.h>
#include <linux/blk-crypto.h>
#include <linux/part_stat.h>
#include <linux/lockdep.h>
#include <linux/memblock.h> /* for max_pfn/max_low_pfn */
#include <linux/sched/sysctl.h>
Expand Down Expand Up @@ -485,6 +486,26 @@ static inline void req_set_nomerge(struct request_queue *q, struct request *req)
q->last_merge = NULL;
}

static inline void bdev_inc_in_flight(struct block_device *bdev,
enum req_op op)
{
bool rw = op_is_write(op);

part_stat_local_inc(bdev, in_flight[rw]);
if (bdev_is_partition(bdev))
part_stat_local_inc(bdev_whole(bdev), in_flight[rw]);
}

static inline void bdev_dec_in_flight(struct block_device *bdev,
enum req_op op)
{
bool rw = op_is_write(op);

part_stat_local_dec(bdev, in_flight[rw]);
if (bdev_is_partition(bdev))
part_stat_local_dec(bdev_whole(bdev), in_flight[rw]);
}

/*
* Internal io_context interface
*/
Expand Down