compat: adapt to RHEL 7

This commit is contained in:
Thomas Schoebel-Theuer 2021-04-27 07:59:45 +02:00
parent 39e84726aa
commit 534e2ce7db
2 changed files with 26 additions and 5 deletions

View File

@ -24,6 +24,7 @@
#ifndef _MARS_COMPAT
#define _MARS_COMPAT
#include <generated/uapi/linux/version.h>
#include <linux/major.h>
/* Detect 5c0ba4e0762e6dabd14a5c276652e2defec38de7
@ -136,11 +137,6 @@ extern int _compat_unlink(
#define MARS_HAS_SET_DEV
#endif
/* adapt to 4e1b2d52a80d79296a5d899d73249748dea71a53 and many others */
#ifdef bio_op
#define MARS_HAS_NEW_BIO_OP
#endif
#ifdef bio_end_sector
#define MARS_HAS_VOID_RELEASE
#endif
@ -311,4 +307,16 @@ extern int _compat_unlink(
#define WRITE_ONCE(dst,src) ACCESS_ONCE(dst) = (src)
#endif
/* specialized compat for RHEL / CentOS / etc */
#ifdef RHEL_MAJOR
#if RHEL_MAJOR <= 7
#undef MARS_HAS_NEW_BIO_OP
#define MARS_HAS_PART_STATS_QUEUE
#endif
#endif /* RHEL_MAJOR */
#endif /* _MARS_COMPAT */

View File

@ -152,7 +152,11 @@ void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow)
const int cpu = part_stat_lock();
(void)cpu;
#ifdef MARS_HAS_PART_STATS_QUEUE
part_round_stats(input->q, cpu, &input->disk->part0);
#else
part_round_stats(cpu, &input->disk->part0);
#endif
part_stat_inc(cpu, &input->disk->part0, ios[rw]);
// remove_this
#ifdef MARS_HAS_BVEC_ITER
@ -163,7 +167,11 @@ void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow)
part_stat_add(cpu, &input->disk->part0, sectors[rw], bio->bi_size >> 9);
#endif
// end_remove_this
#ifdef MARS_HAS_PART_STATS_QUEUE
part_inc_in_flight(input->q, &input->disk->part0, rw);
#else
part_inc_in_flight(&input->disk->part0, rw);
#endif
part_stat_unlock();
biow->start_time = jiffies;
}
@ -177,8 +185,13 @@ void _if_end_io_acct(struct if_input *input, struct bio_wrapper *biow)
const int cpu = part_stat_lock();
(void)cpu;
part_stat_add(cpu, &input->disk->part0, ticks[rw], duration);
#ifdef MARS_HAS_PART_STATS_QUEUE
part_round_stats(input->q, cpu, &input->disk->part0);
part_dec_in_flight(input->q, &input->disk->part0, rw);
#else
part_round_stats(cpu, &input->disk->part0);
part_dec_in_flight(&input->disk->part0, rw);
#endif
part_stat_unlock();
}