diff options
author | Brian Behlendorf <[email protected]> | 2011-02-22 12:15:13 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2011-02-23 12:29:38 -0800 |
commit | 61e909608d15dc6900a710a0ceab6e101a68ac5a (patch) | |
tree | 0786db6d6de1bd8d2fe39f7c2039007b72203351 /include | |
parent | 075cf6cb72a460d884c29085413c3ea16a62d32d (diff) |
Linux 2.6.x compat, blkdev_compat.h
For legacy reasons the zvol.c and vdev_disk.c Linux compatibility
code ended up in sys/blkdev.h and sys/vdev_disk.h headers. While
there are worse places for this code to live it should be in a
linux/blkdev_compat.h header. This change moves this block device
Linux compatibility code in to the linux/blkdev_compat.h header
and updates all the correct #include locations. This is not a
functional change or bug fix, it is just code cleanup.
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/blkdev_compat.h (renamed from include/sys/blkdev.h) | 73 | ||||
-rw-r--r-- | include/sys/Makefile.am | 1 | ||||
-rw-r--r-- | include/sys/Makefile.in | 2 | ||||
-rw-r--r-- | include/sys/dmu.h | 4 | ||||
-rw-r--r-- | include/sys/vdev_disk.h | 50 | ||||
-rw-r--r-- | include/sys/zvol.h | 2 |
6 files changed, 68 insertions, 64 deletions
diff --git a/include/sys/blkdev.h b/include/linux/blkdev_compat.h index 7f242202a..f841c6c00 100644 --- a/include/sys/blkdev.h +++ b/include/linux/blkdev_compat.h @@ -18,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC. + * Copyright (C) 2011 Lawrence Livermore National Security, LLC. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Brian Behlendorf <[email protected]>. * LLNL-CODE-403049. */ -#ifndef _SYS_BLKDEV_H -#define _SYS_BLKDEV_H - -#ifdef _KERNEL +#ifndef _ZFS_BLKDEV_H +#define _ZFS_BLKDEV_H #include <linux/blkdev.h> #include <linux/elevator.h> @@ -212,6 +211,10 @@ struct req_iterator { bio_for_each_segment(bvl, _iter.bio, _iter.i) #endif /* HAVE_RQ_FOR_EACH_SEGMENT */ +/* + * Portable helper for correctly setting the FAILFAST flags. The + * correct usage has changed 3 times from 2.6.12 to 2.6.38. + */ static inline void bio_set_flags_failfast(struct block_device *bdev, int *flags) { @@ -255,10 +258,66 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags) #endif /* HAVE_BIO_RW_FAILFAST_DTD */ } +/* + * Maximum disk label length, it may be undefined for some kernels. + */ #ifndef DISK_NAME_LEN #define DISK_NAME_LEN 32 #endif /* DISK_NAME_LEN */ -#endif /* KERNEL */ +/* + * 2.6.24 API change, + * The bio_end_io() prototype changed slightly. These are helper + * macro's to ensure the prototype and return value are handled. + */ +#ifdef HAVE_2ARGS_BIO_END_IO_T +# define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z) +# define BIO_END_IO_RETURN(rc) return +#else +# define BIO_END_IO_PROTO(fn, x, y, z) static int fn(struct bio *x, \ + unsigned int y, int z) +# define BIO_END_IO_RETURN(rc) return rc +#endif /* HAVE_2ARGS_BIO_END_IO_T */ + +/* + * 2.6.28 API change + * Used to exclusively open a block device from within the kernel. + */ +#ifdef HAVE_OPEN_BDEV_EXCLUSIVE +# define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld) +# define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md) +#else +# define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld) +# define vdev_bdev_close(bdev, md) close_bdev_excl(bdev) +#endif /* HAVE_OPEN_BDEV_EXCLUSIVE */ + +/* + * 2.6.22 API change + * The function invalidate_bdev() lost it's second argument because + * it was unused. + */ +#ifdef HAVE_1ARG_INVALIDATE_BDEV +# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev) +#else +# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1) +#endif /* HAVE_1ARG_INVALIDATE_BDEV */ + +/* + * 2.6.30 API change + * Change to make it explicit there this is the logical block size. + */ +#ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE +# define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev) +#else +# define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev) +#endif + +/* + * Default Linux IO Scheduler, + * Setting the scheduler to noop will allow the Linux IO scheduler to + * still perform front and back merging, while leaving the request + * ordering and prioritization to the ZFS IO scheduler. + */ +#define VDEV_SCHEDULER "noop" -#endif /* _SYS_BLKDEV_H */ +#endif /* _ZFS_BLKDEV_H */ diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index bde71b75e..7b95d8e91 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -72,7 +72,6 @@ COMMON_H = \ $(top_srcdir)/include/sys/zrlock.h KERNEL_H = \ - $(top_srcdir)/include/sys/blkdev.h \ $(top_srcdir)/include/sys/zfs_ioctl.h \ $(top_srcdir)/include/sys/zfs_onexit.h \ ${top_srcdir}/include/sys/zpl.h \ diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in index 37339e255..daf68b3a9 100644 --- a/include/sys/Makefile.in +++ b/include/sys/Makefile.in @@ -163,7 +163,6 @@ am__kernel_HEADERS_DIST = $(top_srcdir)/include/sys/arc.h \ $(top_srcdir)/include/sys/zio.h \ $(top_srcdir)/include/sys/zio_impl.h \ $(top_srcdir)/include/sys/zrlock.h \ - $(top_srcdir)/include/sys/blkdev.h \ $(top_srcdir)/include/sys/zfs_ioctl.h \ $(top_srcdir)/include/sys/zfs_onexit.h \ ${top_srcdir}/include/sys/zpl.h \ @@ -532,7 +531,6 @@ COMMON_H = \ $(top_srcdir)/include/sys/zrlock.h KERNEL_H = \ - $(top_srcdir)/include/sys/blkdev.h \ $(top_srcdir)/include/sys/zfs_ioctl.h \ $(top_srcdir)/include/sys/zfs_onexit.h \ ${top_srcdir}/include/sys/zpl.h \ diff --git a/include/sys/dmu.h b/include/sys/dmu.h index 7040b6740..20733f502 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -41,9 +41,6 @@ #include <sys/cred.h> #include <sys/time.h> #include <sys/uio.h> -#ifdef _KERNEL -#include <sys/blkdev.h> -#endif #ifdef __cplusplus extern "C" { @@ -514,6 +511,7 @@ void dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_tx_t *tx); #ifdef _KERNEL +#include <linux/blkdev_compat.h> int dmu_read_req(objset_t *os, uint64_t object, struct request *req); int dmu_write_req(objset_t *os, uint64_t object, struct request *req, dmu_tx_t *tx); diff --git a/include/sys/vdev_disk.h b/include/sys/vdev_disk.h index 03e7048ac..daefed718 100644 --- a/include/sys/vdev_disk.h +++ b/include/sys/vdev_disk.h @@ -28,15 +28,8 @@ #ifndef _SYS_VDEV_DISK_H #define _SYS_VDEV_DISK_H -#ifdef __cplusplus -extern "C" { -#endif - #ifdef _KERNEL #include <sys/vdev.h> -#include <sys/ddi.h> -#include <sys/sunldi.h> -#include <sys/sunddi.h> typedef struct vdev_disk { ddi_devid_t vd_devid; @@ -48,46 +41,5 @@ extern int vdev_disk_physio(struct block_device *, caddr_t, size_t, uint64_t, int); extern int vdev_disk_read_rootlabel(char *, char *, nvlist_t **); -/* 2.6.24 API change */ -#ifdef HAVE_2ARGS_BIO_END_IO_T -# define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z) -# define BIO_END_IO_RETURN(rc) return -#else -# define BIO_END_IO_PROTO(fn, x, y, z) static int fn(struct bio *x, \ - unsigned int y, int z) -# define BIO_END_IO_RETURN(rc) return rc -#endif /* HAVE_2ARGS_BIO_END_IO_T */ - -/* 2.6.28 API change */ -#ifdef HAVE_OPEN_BDEV_EXCLUSIVE -# define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld) -# define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md) -#else -# define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld) -# define vdev_bdev_close(bdev, md) close_bdev_excl(bdev) -#endif /* HAVE_OPEN_BDEV_EXCLUSIVE */ - -/* 2.6.22 API change */ -#ifdef HAVE_1ARG_INVALIDATE_BDEV -# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev) -#else -# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1) -#endif /* HAVE_1ARG_INVALIDATE_BDEV */ - -/* 2.6.30 API change */ -#ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE -# define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev) -#else -# define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev) -#endif - -/* Default Linux IO Scheduler */ -#define VDEV_SCHEDULER "noop" - #endif /* _KERNEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_VDEV_DISK_H */ +#endif /* _SYS_VDEV_DISK_H */ diff --git a/include/sys/zvol.h b/include/sys/zvol.h index c8b9d6507..815b186e0 100644 --- a/include/sys/zvol.h +++ b/include/sys/zvol.h @@ -33,8 +33,6 @@ #ifdef _KERNEL -#include <sys/blkdev.h> - extern int zvol_check_volsize(uint64_t volsize, uint64_t blocksize); extern int zvol_check_volblocksize(uint64_t volblocksize); extern int zvol_get_stats(objset_t *os, nvlist_t *nv); |