]> git.proxmox.com Git - mirror_zfs-debian.git/commitdiff
Linux 2.6.36 compat, synchronous bio flag
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 10 Nov 2010 23:49:40 +0000 (15:49 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 11 Nov 2010 01:00:33 +0000 (17:00 -0800)
The name of the flag used to mark a bio as synchronous has changed
again in the 2.6.36 kernel due to the unification of the BIO_RW_*
and REQ_* flags.  The new flag is called REQ_SYNC.  To simplify
checking this flag I have introduced the vdev_disk_dio_is_sync()
helper function.  Based on the results of several new autoconf
tests it uses the correct mask to check for a synchronous bio.

Preferred interface for flagging a synchronous bio:
  2.6.12-2.6.29: BIO_RW_SYNC
  2.6.30-2.6.35: BIO_RW_SYNCIO
  2.6.36-2.6.xx: REQ_SYNC

config/kernel-bio-rw-syncio.m4
config/kernel.m4
configure
include/sys/vdev_disk.h
module/zfs/vdev_disk.c
zfs_config.h.in

index 2c80f5c0ea614222a5d4728e09444e343b6380c3..6f8b5b59157c23eec2d9ec37a2aae4f9d032e01c 100644 (file)
@@ -1,7 +1,24 @@
 dnl #
-dnl # 2.6.29 API change
-dnl # BIO_RW_SYNC renamed to BIO_RW_SYNCIO
+dnl # Preferred interface for flagging a synchronous bio:
+dnl # 2.6.12-2.6.29: BIO_RW_SYNC
+dnl # 2.6.30-2.6.35: BIO_RW_SYNCIO
+dnl # 2.6.36-2.6.xx: REQ_SYNC
 dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BIO_RW_SYNC], [
+       AC_MSG_CHECKING([whether BIO_RW_SYNC is defined])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/bio.h>
+       ],[
+               int flags;
+               flags = BIO_RW_SYNC;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_BIO_RW_SYNC, 1, [BIO_RW_SYNC is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
 AC_DEFUN([ZFS_AC_KERNEL_BIO_RW_SYNCIO], [
        AC_MSG_CHECKING([whether BIO_RW_SYNCIO is defined])
        ZFS_LINUX_TRY_COMPILE([
@@ -11,8 +28,22 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_RW_SYNCIO], [
                flags = BIO_RW_SYNCIO;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_BIO_RW_SYNCIO, 1,
-                         [BIO_RW_SYNCIO is defined])
+               AC_DEFINE(HAVE_BIO_RW_SYNCIO, 1, [BIO_RW_SYNCIO is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
+AC_DEFUN([ZFS_AC_KERNEL_REQ_SYNC], [
+       AC_MSG_CHECKING([whether REQ_SYNC is defined])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/bio.h>
+       ],[
+               int flags;
+               flags = REQ_SYNC;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_REQ_SYNC, 1, [REQ_SYNC is defined])
        ],[
                AC_MSG_RESULT(no)
        ])
index c73284062f9c6f204c6eb08592a0c13ea1a9b393..c2fc5a098fd9865e41dae737754d6b6eeb14e2e2 100644 (file)
@@ -16,7 +16,9 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_BIO_FAILFAST_DTD
        ZFS_AC_KERNEL_REQ_FAILFAST_MASK
        ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
+       ZFS_AC_KERNEL_BIO_RW_SYNC
        ZFS_AC_KERNEL_BIO_RW_SYNCIO
+       ZFS_AC_KERNEL_REQ_SYNC
        ZFS_AC_KERNEL_BLK_END_REQUEST
        ZFS_AC_KERNEL_BLK_FETCH_REQUEST
        ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST
index 58b295333bcf8aa277d1c6d3648ce7382895cdc9..c55348036898cae11d7af8f86228cd1560daf302 100755 (executable)
--- a/configure
+++ b/configure
        EXTRA_KCFLAGS="$tmp_flags"
 
 
+       { $as_echo "$as_me:$LINENO: checking whether BIO_RW_SYNC is defined" >&5
+$as_echo_n "checking whether BIO_RW_SYNC is defined... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/bio.h>
+
+int
+main (void)
+{
+
+               int flags;
+               flags = BIO_RW_SYNC;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build
+       echo "obj-m := conftest.o" >build/Makefile
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+               { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BIO_RW_SYNC 1
+_ACEOF
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+               { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+
+       rm -Rf build
+
+
+
+
        { $as_echo "$as_me:$LINENO: checking whether BIO_RW_SYNCIO is defined" >&5
 $as_echo_n "checking whether BIO_RW_SYNCIO is defined... " >&6; }
 
 
 
 
+       { $as_echo "$as_me:$LINENO: checking whether REQ_SYNC is defined" >&5
+$as_echo_n "checking whether REQ_SYNC is defined... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/bio.h>
+
+int
+main (void)
+{
+
+               int flags;
+               flags = REQ_SYNC;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build
+       echo "obj-m := conftest.o" >build/Makefile
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+               { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_REQ_SYNC 1
+_ACEOF
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+               { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+
+       rm -Rf build
+
+
+
+
        { $as_echo "$as_me:$LINENO: checking whether blk_end_request() is available" >&5
 $as_echo_n "checking whether blk_end_request() is available... " >&6; }
 
        EXTRA_KCFLAGS="$tmp_flags"
 
 
+       { $as_echo "$as_me:$LINENO: checking whether BIO_RW_SYNC is defined" >&5
+$as_echo_n "checking whether BIO_RW_SYNC is defined... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/bio.h>
+
+int
+main (void)
+{
+
+               int flags;
+               flags = BIO_RW_SYNC;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build
+       echo "obj-m := conftest.o" >build/Makefile
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+               { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BIO_RW_SYNC 1
+_ACEOF
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+               { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+
+       rm -Rf build
+
+
+
+
        { $as_echo "$as_me:$LINENO: checking whether BIO_RW_SYNCIO is defined" >&5
 $as_echo_n "checking whether BIO_RW_SYNCIO is defined... " >&6; }
 
 
 
 
+       { $as_echo "$as_me:$LINENO: checking whether REQ_SYNC is defined" >&5
+$as_echo_n "checking whether REQ_SYNC is defined... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/bio.h>
+
+int
+main (void)
+{
+
+               int flags;
+               flags = REQ_SYNC;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build
+       echo "obj-m := conftest.o" >build/Makefile
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+               { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_REQ_SYNC 1
+_ACEOF
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+               { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+
+       rm -Rf build
+
+
+
+
        { $as_echo "$as_me:$LINENO: checking whether blk_end_request() is available" >&5
 $as_echo_n "checking whether blk_end_request() is available... " >&6; }
 
index 986c3362422e5ca0b6bb6738e1cde9c3bf2b3161..021e66d1a9a4f1fd7a8c08422cf2314ec957f33c 100644 (file)
@@ -58,13 +58,6 @@ extern int vdev_disk_read_rootlabel(char *, char *, nvlist_t **);
 # define BIO_END_IO_RETURN(rc)         return rc
 #endif /* HAVE_2ARGS_BIO_END_IO_T */
 
-/* 2.6.29 API change */
-#ifdef HAVE_BIO_RW_SYNCIO
-# define DIO_RW_SYNCIO                 BIO_RW_SYNCIO
-#else
-# define DIO_RW_SYNCIO                 BIO_RW_SYNC
-#endif /* HAVE_BIO_RW_SYNCIO */
-
 /* 2.6.28 API change */
 #ifdef HAVE_OPEN_BDEV_EXCLUSIVE
 # define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld)
index 51062ef23529d3489e954b7a9d1f270603b37803..86a089d12ddcfaa7c76bfbb5eb2b7a86a80f0bac 100644 (file)
@@ -220,6 +220,27 @@ vdev_disk_dio_free(dio_request_t *dr)
                  sizeof(struct bio *) * dr->dr_bio_count);
 }
 
+static int
+vdev_disk_dio_is_sync(dio_request_t *dr)
+{
+#ifdef HAVE_BIO_RW_SYNC
+       /* BIO_RW_SYNC preferred interface from 2.6.12-2.6.29 */
+        return (dr->dr_rw & (1 << BIO_RW_SYNC));
+#else
+# ifdef HAVE_BIO_RW_SYNCIO
+       /* BIO_RW_SYNCIO preferred interface from 2.6.30-2.6.35 */
+        return (dr->dr_rw & (1 << BIO_RW_SYNCIO));
+# else
+#  ifdef HAVE_REQ_SYNC
+       /* REQ_SYNC preferred interface from 2.6.36-2.6.xx */
+        return (dr->dr_rw & REQ_SYNC);
+#  else
+#   error "Unable to determine bio sync flag"
+#  endif /* HAVE_REQ_SYNC */
+# endif /* HAVE_BIO_RW_SYNC */
+#endif /* HAVE_BIO_RW_SYNCIO */
+}
+
 static void
 vdev_disk_dio_get(dio_request_t *dr)
 {
@@ -284,7 +305,7 @@ BIO_END_IO_PROTO(vdev_disk_physio_completion, bio, size, error)
        rc = vdev_disk_dio_put(dr);
 
        /* Wake up synchronous waiter this is the last outstanding bio */
-       if ((rc == 1) && (dr->dr_rw & (1 << DIO_RW_SYNCIO)))
+       if ((rc == 1) && vdev_disk_dio_is_sync(dr))
                complete(&dr->dr_comp);
 
        BIO_END_IO_RETURN(0);
@@ -421,7 +442,7 @@ retry:
         * only synchronous consumer is vdev_disk_read_rootlabel() all other
         * IO originating from vdev_disk_io_start() is asynchronous.
         */
-       if (dr->dr_rw & (1 << DIO_RW_SYNCIO)) {
+       if (vdev_disk_dio_is_sync(dr)) {
                wait_for_completion(&dr->dr_comp);
                error = dr->dr_error;
                ASSERT3S(atomic_read(&dr->dr_ref), ==, 1);
index f666d45782e095388cfc2f350744308802109053..6e0e62390cc8bd4f18cdb56a39a956af88031737 100644 (file)
@@ -24,6 +24,9 @@
 /* BIO_RW_FAILFAST_* are defined */
 #undef HAVE_BIO_RW_FAILFAST_DTD
 
+/* BIO_RW_SYNC is defined */
+#undef HAVE_BIO_RW_SYNC
+
 /* BIO_RW_SYNCIO is defined */
 #undef HAVE_BIO_RW_SYNCIO
 
@@ -96,6 +99,9 @@
 /* open_bdev_exclusive() is available */
 #undef HAVE_OPEN_BDEV_EXCLUSIVE
 
+/* REQ_SYNC is defined */
+#undef HAVE_REQ_SYNC
+
 /* rq_for_each_segment() is available */
 #undef HAVE_RQ_FOR_EACH_SEGMENT