Fix synchronicity for ZVOLs.

zvol_write() assumes that the write request must be written to stable storage
if rq_is_sync() is true. Unfortunately, this assumption is incorrect. Indeed,
"sync" does *not* mean what we think it means in the context of the Linux
block layer. This is well explained in linux/fs.h:

    WRITE:       A normal async write. Device will be plugged.
    WRITE_SYNC:  Synchronous write. Identical to WRITE, but passes down
                 the hint that someone will be waiting on this IO
                 shortly.
    WRITE_FLUSH: Like WRITE_SYNC but with preceding cache flush.
    WRITE_FUA:   Like WRITE_SYNC but data is guaranteed to be on
                 non-volatile media on completion.

In other words, SYNC does not *mean* that the write must be on stable storage
on completion. It just means that someone is waiting on us to complete the
write request. Thus triggering a ZIL commit for each SYNC write request on a
ZVOL is unnecessary and harmful for performance. To make matters worse, ZVOL
users have no way to express that they actually want data to be written to
stable storage, which means the ZIL is broken for ZVOLs.

The request for stable storage is expressed by the FUA flag, so we must
commit the ZIL after the write if the FUA flag is set. In addition, we must
commit the ZIL before the write if the FLUSH flag is set.

Also, we must inform the block layer that we actually support FLUSH and FUA.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Etienne Dechamps 2011-09-05 11:11:38 +02:00 committed by Brian Behlendorf
parent 56c34bac44
commit b18019d2d8
60 changed files with 433 additions and 3 deletions

View File

@ -72,6 +72,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -52,6 +52,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -0,0 +1,46 @@
dnl #
dnl # 2.6.36 API change
dnl # In 2.6.36 kernels the blk_queue_ordered() interface has been
dnl # replaced by the simpler blk_queue_flush(). However, while the
dnl # old interface was available to all the new one is GPL-only.
dnl # Thus in addition to detecting if this function is available
dnl # we determine if it is GPL-only. If the GPL-only interface is
dnl # there we implement our own compatibility function, otherwise
dnl # we use the function. The hope is that long term this function
dnl # will be opened up.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_FLUSH], [
AC_MSG_CHECKING([whether blk_queue_flush() is available])
tmp_flags="$EXTRA_KCFLAGS"
EXTRA_KCFLAGS="-Wno-unused-but-set-variable"
ZFS_LINUX_TRY_COMPILE([
#include <linux/blkdev.h>
],[
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLK_QUEUE_FLUSH, 1,
[blk_queue_flush() is available])
],[
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING([whether blk_queue_flush() is GPL-only])
ZFS_LINUX_TRY_COMPILE([
#include <linux/module.h>
#include <linux/blkdev.h>
MODULE_LICENSE("CDDL");
],[
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
],[
AC_MSG_RESULT(no)
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY, 1,
[blk_queue_flush() is GPL-only])
])
EXTRA_KCFLAGS="$tmp_flags"
])

View File

@ -21,6 +21,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_BIO_RW_SYNCIO
ZFS_AC_KERNEL_REQ_SYNC
ZFS_AC_KERNEL_BLK_END_REQUEST
ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
ZFS_AC_KERNEL_BLK_FETCH_REQUEST
ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST
ZFS_AC_KERNEL_BLK_RQ_BYTES

274
configure vendored
View File

@ -13667,6 +13667,143 @@ _ACEOF
fi
rm -Rf build
EXTRA_KCFLAGS="$tmp_flags"
{ $as_echo "$as_me:$LINENO: checking whether blk_queue_flush() is available" >&5
$as_echo_n "checking whether blk_queue_flush() is available... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
EXTRA_KCFLAGS="-Wno-unused-but-set-variable"
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/blkdev.h>
int
main (void)
{
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
;
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_BLK_QUEUE_FLUSH 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_queue_flush() is GPL-only" >&5
$as_echo_n "checking whether blk_queue_flush() is GPL-only... " >&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/module.h>
#include <linux/blkdev.h>
MODULE_LICENSE("CDDL");
int
main (void)
{
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
;
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: no" >&5
$as_echo "no" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_BLK_QUEUE_FLUSH_GPL_ONLY 1
_ACEOF
fi
rm -Rf build
@ -18863,6 +19000,143 @@ _ACEOF
fi
rm -Rf build
EXTRA_KCFLAGS="$tmp_flags"
{ $as_echo "$as_me:$LINENO: checking whether blk_queue_flush() is available" >&5
$as_echo_n "checking whether blk_queue_flush() is available... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
EXTRA_KCFLAGS="-Wno-unused-but-set-variable"
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/blkdev.h>
int
main (void)
{
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
;
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_BLK_QUEUE_FLUSH 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_queue_flush() is GPL-only" >&5
$as_echo_n "checking whether blk_queue_flush() is GPL-only... " >&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/module.h>
#include <linux/blkdev.h>
MODULE_LICENSE("CDDL");
int
main (void)
{
struct request_queue *q = NULL;
(void) blk_queue_flush(q, REQ_FLUSH);
;
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: no" >&5
$as_echo "no" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_BLK_QUEUE_FLUSH_GPL_ONLY 1
_ACEOF
fi
rm -Rf build

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -132,6 +132,23 @@ blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
# endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */
#endif /* HAVE_BLK_END_REQUEST */
/*
* 2.6.36 API change,
* The blk_queue_flush() interface has replaced blk_queue_ordered()
* interface. However, while the old interface was available to all the
* new one is GPL-only. Thus if the GPL-only version is detected we
* implement our own trivial helper compatibility funcion. The hope is
* that long term this function will be opened up.
*/
#if defined(HAVE_BLK_QUEUE_FLUSH) && defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY)
#define blk_queue_flush __blk_queue_flush
static inline void
__blk_queue_flush(struct request_queue *q, unsigned int flags)
{
q->flush_flags = flags & (REQ_FLUSH | REQ_FUA);
}
#endif /* HAVE_BLK_QUEUE_FLUSH && HAVE_BLK_QUEUE_FLUSH_GPL_ONLY */
#ifndef HAVE_BLK_RQ_POS
static inline sector_t
blk_rq_pos(struct request *req)
@ -345,11 +362,19 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* allow richer semantics to be expressed to the block layer. It is
* the block layers responsibility to choose the correct way to
* implement these semantics.
*
* 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.
*/
#ifdef WRITE_FLUSH_FUA
# define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
# define VDEV_REQ_FLUSH REQ_FLUSH
# define VDEV_REQ_FUA REQ_FUA
#else
# define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
# define VDEV_REQ_FLUSH REQ_HARDBARRIER
# define VDEV_REQ_FUA REQ_HARDBARRIER
#endif
/*

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -534,6 +534,17 @@ zvol_write(void *arg)
dmu_tx_t *tx;
rl_t *rl;
if (req->cmd_flags & VDEV_REQ_FLUSH)
zil_commit(zv->zv_zilog, ZVOL_OBJ);
/*
* Some requests are just for flush and nothing else.
*/
if (size == 0) {
blk_end_request(req, 0, size);
return;
}
rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_WRITER);
tx = dmu_tx_create(zv->zv_objset);
@ -550,12 +561,14 @@ zvol_write(void *arg)
error = dmu_write_req(zv->zv_objset, ZVOL_OBJ, req, tx);
if (error == 0)
zvol_log_write(zv, tx, offset, size, rq_is_sync(req));
zvol_log_write(zv, tx, offset, size,
req->cmd_flags & VDEV_REQ_FUA);
dmu_tx_commit(tx);
zfs_range_unlock(rl);
if (rq_is_sync(req) || zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS)
if ((req->cmd_flags & VDEV_REQ_FUA) ||
zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zv->zv_zilog, ZVOL_OBJ);
blk_end_request(req, -error, size);
@ -578,6 +591,11 @@ zvol_read(void *arg)
int error;
rl_t *rl;
if (size == 0) {
blk_end_request(req, 0, size);
return;
}
rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_READER);
error = dmu_read_req(zv->zv_objset, ZVOL_OBJ, req);
@ -627,7 +645,7 @@ zvol_request(struct request_queue *q)
while ((req = blk_fetch_request(q)) != NULL) {
size = blk_rq_bytes(req);
if (blk_rq_pos(req) + blk_rq_sectors(req) >
if (size != 0 && blk_rq_pos(req) + blk_rq_sectors(req) >
get_capacity(zv->zv_disk)) {
printk(KERN_INFO
"%s: bad access: block=%llu, count=%lu\n",
@ -1062,6 +1080,12 @@ zvol_alloc(dev_t dev, const char *name)
if (zv->zv_queue == NULL)
goto out_kmem;
#ifdef HAVE_BLK_QUEUE_FLUSH
blk_queue_flush(zv->zv_queue, VDEV_REQ_FLUSH | VDEV_REQ_FUA);
#else
blk_queue_ordered(zv->zv_queue, QUEUE_ORDERED_DRAIN, NULL);
#endif /* HAVE_BLK_QUEUE_FLUSH */
zv->zv_disk = alloc_disk(ZVOL_MINORS);
if (zv->zv_disk == NULL)
goto out_queue;

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -49,6 +49,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -50,6 +50,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-bio-rw-syncio.m4 \
$(top_srcdir)/config/kernel-blk-end-request.m4 \
$(top_srcdir)/config/kernel-blk-fetch-request.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-requeue-request.m4 \
$(top_srcdir)/config/kernel-blk-rq-bytes.m4 \
$(top_srcdir)/config/kernel-blk-rq-pos.m4 \

View File

@ -51,6 +51,12 @@
/* blk_fetch_request() is available */
#undef HAVE_BLK_FETCH_REQUEST
/* blk_queue_flush() is available */
#undef HAVE_BLK_QUEUE_FLUSH
/* blk_queue_flush() is GPL-only */
#undef HAVE_BLK_QUEUE_FLUSH_GPL_ONLY
/* blk_requeue_request() is available */
#undef HAVE_BLK_REQUEUE_REQUEST