Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 4.8 compat #4892

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions config/kernel-submit_bio.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
dnl #
dnl # 4.8 API change
dnl # The rw argument has been removed from submit_bio/submit_bio_wait.
dnl # Callers are now expected to set bio->bi_rw instead of passing it in.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SUBMIT_BIO], [
AC_MSG_CHECKING([whether submit_bio() wants 1 arg])
ZFS_LINUX_TRY_COMPILE([
#include <linux/bio.h>
],[
blk_qc_t blk_qc;
struct bio *bio = NULL;
blk_qc = submit_bio(bio);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_1ARG_SUBMIT_BIO, 1, [submit_bio() wants 1 arg])
],[
AC_MSG_RESULT(no)
])
])
1 change: 1 addition & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_CONFIG
ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
ZFS_AC_KERNEL_CURRENT_BIO_TAIL
ZFS_AC_KERNEL_SUBMIT_BIO
ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
ZFS_AC_KERNEL_TYPE_FMODE_T
Expand Down
37 changes: 32 additions & 5 deletions include/linux/blkdev_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,23 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* The existence of these flags implies that REQ_FLUSH an REQ_FUA are
* defined. Thus we can safely define VDEV_REQ_FLUSH and VDEV_REQ_FUA
* compatibility macros.
*
* Linux 4.8 renamed the REQ_FLUSH to REQ_PREFLUSH but there was no
* functional change in behavior.
*/
#ifdef WRITE_FLUSH_FUA

#define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
#ifdef REQ_PREFLUSH
#define VDEV_REQ_FLUSH REQ_PREFLUSH
#define VDEV_REQ_FUA REQ_FUA
#else
#define VDEV_REQ_FLUSH REQ_FLUSH
#define VDEV_REQ_FUA REQ_FUA
#endif

#else

#define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
#ifdef HAVE_BIO_RW_BARRIER
#define VDEV_REQ_FLUSH (1 << BIO_RW_BARRIER)
Expand All @@ -319,18 +330,34 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
#define VDEV_REQ_FLUSH REQ_HARDBARRIER
#define VDEV_REQ_FUA REQ_FUA
#endif

#endif

/*
* 2.6.32 API change
* Use the normal I/O patch for discards.
* 2.6.28 - 2.6.35 API,
* BIO_RW_DISCARD
*
* 2.6.36 - 4.7 API,
* REQ_DISCARD
*
* 4.8 - 4.x API,
* REQ_OP_DISCARD
*
* In all cases the normal I/O path is used for discards. The only
* difference is how the kernel tags individual I/Os as discards.
*/
#ifdef QUEUE_FLAG_DISCARD
#ifdef HAVE_BIO_RW_DISCARD
#define VDEV_REQ_DISCARD (1 << BIO_RW_DISCARD)
static inline boolean_t
bio_is_discard(struct bio *bio)
{
#if defined(HAVE_BIO_RW_DISCARD)
return (bio->bi_rw & (1 << BIO_RW_DISCARD));
#elif defined(REQ_DISCARD)
return (bio->bi_rw & REQ_DISCARD);
#else
#define VDEV_REQ_DISCARD REQ_DISCARD
return (bio_op(bio) == REQ_OP_DISCARD);
#endif
}
#else
#error "Allowing the build will cause discard requests to become writes "
"potentially triggering the DMU_MAX_ACCESS assertion. Please file a "
Expand Down
15 changes: 13 additions & 2 deletions module/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,18 +484,29 @@ bio_map(struct bio *bio, void *bio_ptr, unsigned int bio_size)
return (bio_size);
}

static inline void
vdev_submit_bio_impl(int rw, struct bio *bio)
{
#ifdef HAVE_1ARG_SUBMIT_BIO
bio->bi_rw |= rw;
submit_bio(bio);
#else
submit_bio(rw, bio);
#endif
}

static inline void
vdev_submit_bio(int rw, struct bio *bio)
{
#ifdef HAVE_CURRENT_BIO_TAIL
struct bio **bio_tail = current->bio_tail;
current->bio_tail = NULL;
submit_bio(rw, bio);
vdev_submit_bio_impl(rw, bio);
current->bio_tail = bio_tail;
#else
struct bio_list *bio_list = current->bio_list;
current->bio_list = NULL;
submit_bio(rw, bio);
vdev_submit_bio_impl(rw, bio);
current->bio_list = bio_list;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ zvol_request(struct request_queue *q, struct bio *bio)
goto out2;
}

if (bio->bi_rw & VDEV_REQ_DISCARD) {
if (bio_is_discard(bio)) {
error = zvol_discard(bio);
goto out2;
}
Expand Down