diff options
author | Brian Behlendorf <[email protected]> | 2019-01-16 10:39:19 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-01-28 10:11:45 -0800 |
commit | 26a856594f731db62446cf537659f9360261fe97 (patch) | |
tree | 39f1422bdb38e32b10990e53b2ab7067956e8bc5 /module/zfs/vdev_disk.c | |
parent | 0c593296e98e3ac95f14704e4cee6cedb2134990 (diff) |
Linux 5.0 compat: Fix bio_set_dev()
The Linux 5.0 kernel updated the bio_set_dev() macro so it calls the
GPL-only bio_associate_blkg() symbol thus inadvertently converting
the entire macro. Provide a minimal version which always assigns the
request queue's root_blkg to the bio.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #8287
Diffstat (limited to 'module/zfs/vdev_disk.c')
-rw-r--r-- | module/zfs/vdev_disk.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/module/zfs/vdev_disk.c b/module/zfs/vdev_disk.c index c53a0aa0f..db765c57b 100644 --- a/module/zfs/vdev_disk.c +++ b/module/zfs/vdev_disk.c @@ -513,13 +513,38 @@ vdev_submit_bio_impl(struct bio *bio) #endif } -#ifndef HAVE_BIO_SET_DEV +#ifdef HAVE_BIO_SET_DEV +#if defined(CONFIG_BLK_CGROUP) && defined(HAVE_BIO_SET_DEV_GPL_ONLY) +/* + * The Linux 5.0 kernel updated the bio_set_dev() macro so it calls the + * GPL-only bio_associate_blkg() symbol thus inadvertently converting + * the entire macro. Provide a minimal version which always assigns the + * request queue's root_blkg to the bio. + */ +static inline void +vdev_bio_associate_blkg(struct bio *bio) +{ + struct request_queue *q = bio->bi_disk->queue; + + ASSERT3P(q, !=, NULL); + ASSERT3P(q->root_blkg, !=, NULL); + ASSERT3P(bio->bi_blkg, ==, NULL); + + if (blkg_tryget(q->root_blkg)) + bio->bi_blkg = q->root_blkg; +} +#define bio_associate_blkg vdev_bio_associate_blkg +#endif +#else +/* + * Provide a bio_set_dev() helper macro for pre-Linux 4.14 kernels. + */ static inline void bio_set_dev(struct bio *bio, struct block_device *bdev) { bio->bi_bdev = bdev; } -#endif /* !HAVE_BIO_SET_DEV */ +#endif /* HAVE_BIO_SET_DEV */ static inline void vdev_submit_bio(struct bio *bio) |