mirror of https://github.com/schoebel/mars
if: adapt to generic io accounting
This commit is contained in:
parent
c8ab80d0d0
commit
4e087abc38
|
@ -136,6 +136,23 @@ extern int _compat_unlink(
|
|||
#define MARS_HAS_NEW_BIO_OP
|
||||
#endif
|
||||
|
||||
/* IO accounting */
|
||||
|
||||
/* adapt to 394ffa503bc40e32d7f54a9b817264e81ce131b4
|
||||
* detected via b25de9d6da49b1a8760a89672283128aa8c7
|
||||
*/
|
||||
#ifndef BIO_EOPNOTSUPP
|
||||
#define MARS_HAS_GENERIC_BLK_ACCOUNTING
|
||||
#elif defined(part_stat_lock)
|
||||
#define MARS_HAS_OLD_BLK_ACCOUNTING
|
||||
#endif
|
||||
/* adapt to d62e26b3ffd28f16ddae85a1babd0303a1a6dfb6
|
||||
* detected via e743eb1ecd5564b5ae0a4a76c1566f748a358839
|
||||
*/
|
||||
#ifndef QUEUE_FLAG_SYNCFULL
|
||||
#define MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING
|
||||
#endif
|
||||
|
||||
/* for mm stuff, should disappear */
|
||||
|
||||
/* adapt to 68e21be2916b359fd8afb536c1911dc014cfd03e
|
||||
|
|
|
@ -102,13 +102,57 @@ static int device_minor = 0;
|
|||
|
||||
///////////////////////// linux operations ////////////////////////
|
||||
|
||||
#ifdef part_stat_lock
|
||||
#ifdef MARS_HAS_GENERIC_BLK_ACCOUNTING
|
||||
|
||||
/* Disbaled by default, for saving overhead */
|
||||
int mars_io_acct = 0;
|
||||
|
||||
static
|
||||
void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow)
|
||||
{
|
||||
struct bio *bio;
|
||||
|
||||
if (!mars_io_acct)
|
||||
return;
|
||||
|
||||
bio = biow->bio;
|
||||
biow->start_time = jiffies;
|
||||
generic_start_io_acct(
|
||||
#ifdef MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING
|
||||
input->q,
|
||||
#endif
|
||||
bio_data_dir(bio),
|
||||
bio->bi_iter.bi_size >> 9,
|
||||
&input->disk->part0);
|
||||
}
|
||||
|
||||
static
|
||||
void _if_end_io_acct(struct if_input *input, struct bio_wrapper *biow)
|
||||
{
|
||||
struct bio *bio;
|
||||
|
||||
if (!biow->start_time)
|
||||
return;
|
||||
|
||||
bio = biow->bio;
|
||||
generic_end_io_acct(
|
||||
#ifdef MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING
|
||||
input->q,
|
||||
#endif
|
||||
bio_data_dir(bio),
|
||||
&input->disk->part0,
|
||||
biow->start_time);
|
||||
}
|
||||
|
||||
#elif defined(MARS_HAS_OLD_BLK_ACCOUNTING)
|
||||
|
||||
static
|
||||
void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow)
|
||||
{
|
||||
struct bio *bio = biow->bio;
|
||||
const int rw = bio_data_dir(bio);
|
||||
const int cpu = part_stat_lock();
|
||||
|
||||
(void)cpu;
|
||||
part_round_stats(cpu, &input->disk->part0);
|
||||
part_stat_inc(cpu, &input->disk->part0, ios[rw]);
|
||||
|
@ -140,9 +184,11 @@ void _if_end_io_acct(struct if_input *input, struct bio_wrapper *biow)
|
|||
part_stat_unlock();
|
||||
}
|
||||
|
||||
#else // part_stat_lock
|
||||
#else // MARS_HAS_OLD_BLK_ACCOUNTING
|
||||
|
||||
#define _if_start_io_acct(...) do {} while (0)
|
||||
#define _if_end_io_acct(...) do {} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
/* callback
|
||||
|
|
Loading…
Reference in New Issue