Skip to content

Commit a7f5b1a

Browse files
snitmgregkh
authored andcommitted
block: add bio_start_io_acct_time() to control start_time
commit e45c47d upstream. bio_start_io_acct_time() interface is like bio_start_io_acct() that allows start_time to be passed in. This gives drivers the ability to defer starting accounting until after IO is issued (but possibily not entirely due to bio splitting). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Link: https://lore.kernel.org/r/20220128155841.39644-2-snitzer@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dc93c7a commit a7f5b1a

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

‎block/blk-core.c‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,20 +1258,32 @@ void __blk_account_io_start(struct request *rq)
12581258
}
12591259

12601260
static unsigned long __part_start_io_acct(struct block_device *part,
1261-
unsigned int sectors, unsigned int op)
1261+
unsigned int sectors, unsigned int op,
1262+
unsigned long start_time)
12621263
{
12631264
const int sgrp = op_stat_group(op);
1264-
unsigned long now = READ_ONCE(jiffies);
12651265

12661266
part_stat_lock();
1267-
update_io_ticks(part, now, false);
1267+
update_io_ticks(part, start_time, false);
12681268
part_stat_inc(part, ios[sgrp]);
12691269
part_stat_add(part, sectors[sgrp], sectors);
12701270
part_stat_local_inc(part, in_flight[op_is_write(op)]);
12711271
part_stat_unlock();
12721272

1273-
return now;
1273+
return start_time;
1274+
}
1275+
1276+
/**
1277+
* bio_start_io_acct_time - start I/O accounting for bio based drivers
1278+
* @bio: bio to start account for
1279+
* @start_time: start time that should be passed back to bio_end_io_acct().
1280+
*/
1281+
void bio_start_io_acct_time(struct bio *bio, unsigned long start_time)
1282+
{
1283+
__part_start_io_acct(bio->bi_bdev, bio_sectors(bio),
1284+
bio_op(bio), start_time);
12741285
}
1286+
EXPORT_SYMBOL_GPL(bio_start_io_acct_time);
12751287

12761288
/**
12771289
* bio_start_io_acct - start I/O accounting for bio based drivers
@@ -1281,14 +1293,15 @@ static unsigned long __part_start_io_acct(struct block_device *part,
12811293
*/
12821294
unsigned long bio_start_io_acct(struct bio *bio)
12831295
{
1284-
return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), bio_op(bio));
1296+
return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio),
1297+
bio_op(bio), jiffies);
12851298
}
12861299
EXPORT_SYMBOL_GPL(bio_start_io_acct);
12871300

12881301
unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
12891302
unsigned int op)
12901303
{
1291-
return __part_start_io_acct(disk->part0, sectors, op);
1304+
return __part_start_io_acct(disk->part0, sectors, op, jiffies);
12921305
}
12931306
EXPORT_SYMBOL(disk_start_io_acct);
12941307

‎include/linux/blkdev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
12541254
void disk_end_io_acct(struct gendisk *disk, unsigned int op,
12551255
unsigned long start_time);
12561256

1257+
void bio_start_io_acct_time(struct bio *bio, unsigned long start_time);
12571258
unsigned long bio_start_io_acct(struct bio *bio);
12581259
void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time,
12591260
struct block_device *orig_bdev);

0 commit comments

Comments
 (0)