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([
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)
])
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; }
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)
{
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);
* 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);