History

block: add disk/bio-based accounting helpers

Add two new helpers to simplify I/O accounting for bio based drivers. Currently these drivers use the generic_start_io_acct and generic_end_io_acct helpers which have very cumbersome calling conventions, don't actually return the time they started accounting, and try to deal with accounting for partitions, which can't happen for bio based drivers. The new helpers will be used to subsequently replace uses of the old helpers. The main API is the bio based wrappes in blkdev.h, but for zram which wants to account rw_page based I/O lower level routines are provided as well.

Christoph Hellwig committed 6 years ago

Commit 956d5101 parent c81b49d2 files · +62 −0Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/blkdev.h+28−0
@@ -1892,4 +1892,32 @@ static inline void blk_wake_io_task(struct task_struct *waiter) · 1891 unmodified lines
18921892 wake_up_process(waiter);
18931893 }
18941894
1895+unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
1896+ unsigned int op);
1897+void disk_end_io_acct(struct gendisk *disk, unsigned int op,
1898+ unsigned long start_time);
1899+
1900+#ifdef CONFIG_BLOCK
1901+/**
1902+ * bio_start_io_acct - start I/O accounting for bio based drivers
1903+ * @bio: bio to start account for
1904+ *
1905+ * Returns the start time that should be passed back to bio_end_io_acct().
1906+ */
1907+static inline unsigned long bio_start_io_acct(struct bio *bio)
1908+{
1909+ return disk_start_io_acct(bio->bi_disk, bio_sectors(bio), bio_op(bio));
1910+}
1911+
1912+/**
1913+ * bio_end_io_acct - end I/O accounting for bio based drivers
1914+ * @bio: bio to end account for
1915+ * @start: start time returned by bio_start_io_acct()
1916+ */
1917+static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time)
1918+{
1919+ return disk_end_io_acct(bio->bi_disk, bio_op(bio), start_time);
1920+}
1921+#endif /* CONFIG_BLOCK */
1922+
18951923 #endif