Linux 2.6.36 compat, synchronous bio flag

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
This commit is contained in:
Brian Behlendorf 2010-11-10 15:49:40 -08:00
parent f4af6bb783
commit 675de5aa37
6 changed files with 330 additions and 13 deletions

View 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)
])

View 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

264
configure vendored
View File

@ -12884,6 +12884,72 @@ fi
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; }
@ -12950,6 +13016,72 @@ fi
{ $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; }
@ -16087,6 +16219,72 @@ fi
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; }
@ -16153,6 +16351,72 @@ fi
{ $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; }

View 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)

View 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);

View 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