diff --git a/kernel/compat.h b/kernel/compat.h index 9ea89389..7816042d 100644 --- a/kernel/compat.h +++ b/kernel/compat.h @@ -240,6 +240,19 @@ extern int __oldcompat_unlink( #define MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING #endif +/* Adapt to e722fff238bbfe6308d7778a8c2163c181bf998a + * after 956d510ee78caebc83c0eaeb892db5b239a36a06 + * detected via 0512a75b98f847c2e9a4b664013424e603e202f7 + * (see also 24d69293d9a561645e0b4d78c2fb179827e35f53) + * and disable the old methods. + */ +#ifdef BLK_STS_ZONE_RESOURCE +#define MARS_HAS_BIO_IO_ACCT +#undef MARS_HAS_GENERIC_BLK_ACCOUNTING +#undef MARS_HAS_OLD_BLK_ACCOUNTING +#undef MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING +#endif + /* vfs stuff */ /* Adapt to diff --git a/kernel/mars_if.c b/kernel/mars_if.c index b0a83204..ddf51407 100644 --- a/kernel/mars_if.c +++ b/kernel/mars_if.c @@ -102,7 +102,43 @@ static int device_minor = 0; ///////////////////////// linux operations //////////////////////// -#ifdef MARS_HAS_GENERIC_BLK_ACCOUNTING +#ifdef MARS_HAS_BIO_IO_ACCT +/* Now IO accounting is enabled by default. + * Thanks to Christoph Hellwig who simplified the upstream a lot. + */ +int mars_io_acct = 1; + +static inline +void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow) +{ + struct bio *bio; + + if (!mars_io_acct) + return; + + bio = biow->bio; + /* We cannot account at certain kernels when bi_disk is unknown. + */ + if (!bio || !bio->bi_disk) + return; + + biow->start_time = bio_start_io_acct(bio); +} + +static inline +void _if_end_io_acct(struct if_input *input, struct bio_wrapper *biow) +{ + struct bio *bio; + + if (!biow->start_time) + return; + + bio = biow->bio; + bio_end_io_acct(bio, biow->start_time); +} + +/* Check whether some old IO accounting methods are usable */ +#elif defined(MARS_HAS_GENERIC_BLK_ACCOUNTING) /* Disbaled by default, for saving overhead */ int mars_io_acct = 0; @@ -144,6 +180,7 @@ void _if_end_io_acct(struct if_input *input, struct bio_wrapper *biow) biow->start_time); } +/* To disappear in the long term */ #elif defined(MARS_HAS_OLD_BLK_ACCOUNTING) static diff --git a/kernel/mars_if.h b/kernel/mars_if.h index c0181802..661f9eff 100644 --- a/kernel/mars_if.h +++ b/kernel/mars_if.h @@ -126,4 +126,8 @@ struct if_brick { MARS_TYPES(if); +///////////////////////// statistics //////////////////////// + +extern int mars_io_acct; + #endif diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index c60b3aa5..057b1420 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -538,6 +538,9 @@ struct ctl_table io_tuning_table[] = { THRESHOLD_ENTRIES(&aio_io_threshold[1], "aio_io_w"), THRESHOLD_ENTRIES(&aio_sync_threshold, "aio_sync"), INT_ENTRY("if_nr_requests", if_nr_requests, 0600), +#if defined(MARS_HAS_BIO_IO_ACCT) || defined(MARS_HAS_GENERIC_BLK_ACCOUNTING) + INT_ENTRY("if_io_acct", mars_io_acct, 0600), +#endif {} };