aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in1
-rw-r--r--cmd/Makefile.in1
-rw-r--r--cmd/mount_zfs/Makefile.in1
-rw-r--r--cmd/sas_switch_id/Makefile.in1
-rw-r--r--cmd/zdb/Makefile.in1
-rw-r--r--cmd/zfs/Makefile.in1
-rw-r--r--cmd/zinject/Makefile.in1
-rw-r--r--cmd/zpios/Makefile.in1
-rw-r--r--cmd/zpool/Makefile.in1
-rw-r--r--cmd/zpool_id/Makefile.in1
-rw-r--r--cmd/zpool_layout/Makefile.in1
-rw-r--r--cmd/ztest/Makefile.in1
-rw-r--r--cmd/zvol_id/Makefile.in1
-rw-r--r--config/kernel-blk-queue-discard.m422
-rw-r--r--config/kernel.m41
-rwxr-xr-xconfigure138
-rw-r--r--dracut/90zfs/Makefile.in1
-rw-r--r--dracut/Makefile.in1
-rw-r--r--etc/Makefile.in1
-rw-r--r--etc/init.d/Makefile.in1
-rw-r--r--etc/zfs/Makefile.in1
-rw-r--r--include/Makefile.in1
-rw-r--r--include/linux/Makefile.in1
-rw-r--r--include/linux/blkdev_compat.h8
-rw-r--r--include/sys/Makefile.in1
-rw-r--r--include/sys/fm/Makefile.in1
-rw-r--r--include/sys/fm/fs/Makefile.in1
-rw-r--r--include/sys/fs/Makefile.in1
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/libavl/Makefile.in1
-rw-r--r--lib/libefi/Makefile.in1
-rw-r--r--lib/libnvpair/Makefile.in1
-rw-r--r--lib/libshare/Makefile.in1
-rw-r--r--lib/libspl/Makefile.in1
-rw-r--r--lib/libspl/asm-generic/Makefile.in1
-rw-r--r--lib/libspl/asm-i386/Makefile.in1
-rw-r--r--lib/libspl/asm-x86_64/Makefile.in1
-rw-r--r--lib/libspl/include/Makefile.in1
-rw-r--r--lib/libspl/include/ia32/Makefile.in1
-rw-r--r--lib/libspl/include/ia32/sys/Makefile.in1
-rw-r--r--lib/libspl/include/rpc/Makefile.in1
-rw-r--r--lib/libspl/include/sys/Makefile.in1
-rw-r--r--lib/libspl/include/sys/dktp/Makefile.in1
-rw-r--r--lib/libspl/include/sys/sysevent/Makefile.in1
-rw-r--r--lib/libspl/include/util/Makefile.in1
-rw-r--r--lib/libunicode/Makefile.in1
-rw-r--r--lib/libuutil/Makefile.in1
-rw-r--r--lib/libzfs/Makefile.in1
-rw-r--r--lib/libzpool/Makefile.in1
-rw-r--r--man/Makefile.in1
-rw-r--r--man/man8/Makefile.in1
-rw-r--r--module/zfs/zvol.c47
-rw-r--r--scripts/Makefile.in1
-rw-r--r--scripts/zpios-profile/Makefile.in1
-rw-r--r--scripts/zpios-test/Makefile.in1
-rw-r--r--scripts/zpool-config/Makefile.in1
-rw-r--r--scripts/zpool-layout/Makefile.in1
-rw-r--r--udev/Makefile.in1
-rw-r--r--udev/rules.d/Makefile.in1
-rw-r--r--zfs_config.h.in3
60 files changed, 273 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
index 64deb2369..67412c63d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/Makefile.in b/cmd/Makefile.in
index 4a38f36fc..b362f4bc4 100644
--- a/cmd/Makefile.in
+++ b/cmd/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/mount_zfs/Makefile.in b/cmd/mount_zfs/Makefile.in
index 273e20542..5945bd1c1 100644
--- a/cmd/mount_zfs/Makefile.in
+++ b/cmd/mount_zfs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/sas_switch_id/Makefile.in b/cmd/sas_switch_id/Makefile.in
index 73a22c4ef..64d07e09b 100644
--- a/cmd/sas_switch_id/Makefile.in
+++ b/cmd/sas_switch_id/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zdb/Makefile.in b/cmd/zdb/Makefile.in
index 5ce100dd0..0c99ae803 100644
--- a/cmd/zdb/Makefile.in
+++ b/cmd/zdb/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zfs/Makefile.in b/cmd/zfs/Makefile.in
index 81f778a5e..71941603d 100644
--- a/cmd/zfs/Makefile.in
+++ b/cmd/zfs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zinject/Makefile.in b/cmd/zinject/Makefile.in
index 644c0b2a3..08aaa40ed 100644
--- a/cmd/zinject/Makefile.in
+++ b/cmd/zinject/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zpios/Makefile.in b/cmd/zpios/Makefile.in
index e270f3744..8ab6938cc 100644
--- a/cmd/zpios/Makefile.in
+++ b/cmd/zpios/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zpool/Makefile.in b/cmd/zpool/Makefile.in
index 81620379a..85d09af71 100644
--- a/cmd/zpool/Makefile.in
+++ b/cmd/zpool/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zpool_id/Makefile.in b/cmd/zpool_id/Makefile.in
index 578fdbbc6..204efe831 100644
--- a/cmd/zpool_id/Makefile.in
+++ b/cmd/zpool_id/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zpool_layout/Makefile.in b/cmd/zpool_layout/Makefile.in
index b89e9e8e8..09ed6de1d 100644
--- a/cmd/zpool_layout/Makefile.in
+++ b/cmd/zpool_layout/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/ztest/Makefile.in b/cmd/ztest/Makefile.in
index 70532fbef..f6c5deda7 100644
--- a/cmd/ztest/Makefile.in
+++ b/cmd/ztest/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/cmd/zvol_id/Makefile.in b/cmd/zvol_id/Makefile.in
index 6bacf9944..f369599ee 100644
--- a/cmd/zvol_id/Makefile.in
+++ b/cmd/zvol_id/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/config/kernel-blk-queue-discard.m4 b/config/kernel-blk-queue-discard.m4
new file mode 100644
index 000000000..3e5147a51
--- /dev/null
+++ b/config/kernel-blk-queue-discard.m4
@@ -0,0 +1,22 @@
+dnl #
+dnl # 2.6.32 API change
+dnl # Discard requests were moved to the normal I/O path.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
+ AC_MSG_CHECKING([whether blk_queue_discard() 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_discard(q);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BLK_QUEUE_DISCARD, 1,
+ [blk_queue_discard() is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+ EXTRA_KCFLAGS="$tmp_flags"
+])
diff --git a/config/kernel.m4 b/config/kernel.m4
index c41cdf694..0adceadac 100644
--- a/config/kernel.m4
+++ b/config/kernel.m4
@@ -27,6 +27,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_BLK_QUEUE_PHYSICAL_BLOCK_SIZE
ZFS_AC_KERNEL_BLK_QUEUE_IO_OPT
ZFS_AC_KERNEL_BLK_QUEUE_NONROT
+ ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
ZFS_AC_KERNEL_BLK_FETCH_REQUEST
ZFS_AC_KERNEL_BLK_REQUEUE_REQUEST
ZFS_AC_KERNEL_BLK_RQ_BYTES
diff --git a/configure b/configure
index 4288ca658..0b00c6ddd 100755
--- a/configure
+++ b/configure
@@ -14159,6 +14159,75 @@ fi
EXTRA_KCFLAGS="$tmp_flags"
+ { $as_echo "$as_me:$LINENO: checking whether blk_queue_discard() is available" >&5
+$as_echo_n "checking whether blk_queue_discard() 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_discard(q);
+
+ ;
+ 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_DISCARD 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
+
+
+ EXTRA_KCFLAGS="$tmp_flags"
+
+
{ $as_echo "$as_me:$LINENO: checking whether blk_fetch_request() is available" >&5
$as_echo_n "checking whether blk_fetch_request() is available... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
@@ -19977,6 +20046,75 @@ fi
EXTRA_KCFLAGS="$tmp_flags"
+ { $as_echo "$as_me:$LINENO: checking whether blk_queue_discard() is available" >&5
+$as_echo_n "checking whether blk_queue_discard() 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_discard(q);
+
+ ;
+ 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_DISCARD 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
+
+
+ EXTRA_KCFLAGS="$tmp_flags"
+
+
{ $as_echo "$as_me:$LINENO: checking whether blk_fetch_request() is available" >&5
$as_echo_n "checking whether blk_fetch_request() is available... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
diff --git a/dracut/90zfs/Makefile.in b/dracut/90zfs/Makefile.in
index f574205dd..0725bbc74 100644
--- a/dracut/90zfs/Makefile.in
+++ b/dracut/90zfs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/dracut/Makefile.in b/dracut/Makefile.in
index a9f8be205..1544385b4 100644
--- a/dracut/Makefile.in
+++ b/dracut/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/etc/Makefile.in b/etc/Makefile.in
index 2cb43ca3c..14737685d 100644
--- a/etc/Makefile.in
+++ b/etc/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/etc/init.d/Makefile.in b/etc/init.d/Makefile.in
index 73f07f4b6..cbed8c0ac 100644
--- a/etc/init.d/Makefile.in
+++ b/etc/init.d/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/etc/zfs/Makefile.in b/etc/zfs/Makefile.in
index 8024d3095..e161cb455 100644
--- a/etc/zfs/Makefile.in
+++ b/etc/zfs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/Makefile.in b/include/Makefile.in
index d7423a3c7..9f3972782 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/linux/Makefile.in b/include/linux/Makefile.in
index d18e5dd9c..9c69b6257 100644
--- a/include/linux/Makefile.in
+++ b/include/linux/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/linux/blkdev_compat.h b/include/linux/blkdev_compat.h
index 56a1bafe9..bd1b2bf54 100644
--- a/include/linux/blkdev_compat.h
+++ b/include/linux/blkdev_compat.h
@@ -425,6 +425,14 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
#endif
/*
+ * 2.6.32 API change
+ * Use the normal I/O patch for discards.
+ */
+#ifdef REQ_DISCARD
+# define VDEV_REQ_DISCARD REQ_DISCARD
+#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
diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in
index 06c20479b..91fd34b65 100644
--- a/include/sys/Makefile.in
+++ b/include/sys/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in
index 245995dda..0dcd27b10 100644
--- a/include/sys/fm/Makefile.in
+++ b/include/sys/fm/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in
index 10dcd83e9..03c32de06 100644
--- a/include/sys/fm/fs/Makefile.in
+++ b/include/sys/fm/fs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in
index ee2f16821..1f8de0f07 100644
--- a/include/sys/fs/Makefile.in
+++ b/include/sys/fs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 43bdf0dc2..daaf306b1 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libavl/Makefile.in b/lib/libavl/Makefile.in
index d909fa66a..d28c6acde 100644
--- a/lib/libavl/Makefile.in
+++ b/lib/libavl/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in
index a0595ce5d..4a935784a 100644
--- a/lib/libefi/Makefile.in
+++ b/lib/libefi/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libnvpair/Makefile.in b/lib/libnvpair/Makefile.in
index 533d96235..e982a68bd 100644
--- a/lib/libnvpair/Makefile.in
+++ b/lib/libnvpair/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libshare/Makefile.in b/lib/libshare/Makefile.in
index 8390ce835..61b61a700 100644
--- a/lib/libshare/Makefile.in
+++ b/lib/libshare/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/Makefile.in b/lib/libspl/Makefile.in
index 541f72b9d..2d1a8ad17 100644
--- a/lib/libspl/Makefile.in
+++ b/lib/libspl/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/asm-generic/Makefile.in b/lib/libspl/asm-generic/Makefile.in
index 974f489ad..63b0ef392 100644
--- a/lib/libspl/asm-generic/Makefile.in
+++ b/lib/libspl/asm-generic/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/asm-i386/Makefile.in b/lib/libspl/asm-i386/Makefile.in
index f84cd39d9..2d43d8918 100644
--- a/lib/libspl/asm-i386/Makefile.in
+++ b/lib/libspl/asm-i386/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/asm-x86_64/Makefile.in b/lib/libspl/asm-x86_64/Makefile.in
index 23c4b2917..c6d61a5fa 100644
--- a/lib/libspl/asm-x86_64/Makefile.in
+++ b/lib/libspl/asm-x86_64/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/Makefile.in b/lib/libspl/include/Makefile.in
index 043f0fe1e..ab1d8511e 100644
--- a/lib/libspl/include/Makefile.in
+++ b/lib/libspl/include/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/ia32/Makefile.in b/lib/libspl/include/ia32/Makefile.in
index dad5d8561..f1f6cb87f 100644
--- a/lib/libspl/include/ia32/Makefile.in
+++ b/lib/libspl/include/ia32/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/ia32/sys/Makefile.in b/lib/libspl/include/ia32/sys/Makefile.in
index d7ea24fff..70eb6a35d 100644
--- a/lib/libspl/include/ia32/sys/Makefile.in
+++ b/lib/libspl/include/ia32/sys/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/rpc/Makefile.in b/lib/libspl/include/rpc/Makefile.in
index 3a0b3a1af..a217ab6dc 100644
--- a/lib/libspl/include/rpc/Makefile.in
+++ b/lib/libspl/include/rpc/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in
index b8663bdd2..efa77adc6 100644
--- a/lib/libspl/include/sys/Makefile.in
+++ b/lib/libspl/include/sys/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/sys/dktp/Makefile.in b/lib/libspl/include/sys/dktp/Makefile.in
index e5c353795..1656d9d4e 100644
--- a/lib/libspl/include/sys/dktp/Makefile.in
+++ b/lib/libspl/include/sys/dktp/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/sys/sysevent/Makefile.in b/lib/libspl/include/sys/sysevent/Makefile.in
index edb36b071..5a37394e3 100644
--- a/lib/libspl/include/sys/sysevent/Makefile.in
+++ b/lib/libspl/include/sys/sysevent/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libspl/include/util/Makefile.in b/lib/libspl/include/util/Makefile.in
index 301fde587..8894eb57a 100644
--- a/lib/libspl/include/util/Makefile.in
+++ b/lib/libspl/include/util/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libunicode/Makefile.in b/lib/libunicode/Makefile.in
index 3e3cb2df1..6135529f8 100644
--- a/lib/libunicode/Makefile.in
+++ b/lib/libunicode/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libuutil/Makefile.in b/lib/libuutil/Makefile.in
index 1fb5e573d..e10118898 100644
--- a/lib/libuutil/Makefile.in
+++ b/lib/libuutil/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libzfs/Makefile.in b/lib/libzfs/Makefile.in
index 9ba47ca73..84e9e2a7e 100644
--- a/lib/libzfs/Makefile.in
+++ b/lib/libzfs/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/lib/libzpool/Makefile.in b/lib/libzpool/Makefile.in
index fc071e22a..6c6b3b1e7 100644
--- a/lib/libzpool/Makefile.in
+++ b/lib/libzpool/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/man/Makefile.in b/man/Makefile.in
index 8e98be3d1..1552a216a 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in
index 12524ffcc..5d1fcd726 100644
--- a/man/man8/Makefile.in
+++ b/man/man8/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 19888ea96..9b1313402 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -574,6 +574,42 @@ zvol_write(void *arg)
blk_end_request(req, -error, size);
}
+#ifdef HAVE_BLK_QUEUE_DISCARD
+static void
+zvol_discard(void *arg)
+{
+ struct request *req = (struct request *)arg;
+ struct request_queue *q = req->q;
+ zvol_state_t *zv = q->queuedata;
+ uint64_t offset = blk_rq_pos(req) << 9;
+ uint64_t size = blk_rq_bytes(req);
+ int error;
+ rl_t *rl;
+
+ if (offset + size > zv->zv_volsize) {
+ blk_end_request(req, -EIO, size);
+ return;
+ }
+
+ if (size == 0) {
+ blk_end_request(req, 0, size);
+ return;
+ }
+
+ rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_WRITER);
+
+ error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ, offset, size);
+
+ /*
+ * TODO: maybe we should add the operation to the log.
+ */
+
+ zfs_range_unlock(rl);
+
+ blk_end_request(req, -error, size);
+}
+#endif /* HAVE_BLK_QUEUE_DISCARD */
+
/*
* Common read path running under the zvol taskq context. This function
* is responsible for copying the requested data out of the DMU and in to
@@ -674,6 +710,13 @@ zvol_request(struct request_queue *q)
break;
}
+#ifdef HAVE_BLK_QUEUE_DISCARD
+ if (req->cmd_flags & VDEV_REQ_DISCARD) {
+ zvol_dispatch(zvol_discard, req);
+ break;
+ }
+#endif /* HAVE_BLK_QUEUE_DISCARD */
+
zvol_dispatch(zvol_write, req);
break;
default:
@@ -1193,6 +1236,10 @@ __zvol_create_minor(const char *name)
blk_queue_max_segment_size(zv->zv_queue, UINT_MAX);
blk_queue_physical_block_size(zv->zv_queue, zv->zv_volblocksize);
blk_queue_io_opt(zv->zv_queue, zv->zv_volblocksize);
+#ifdef HAVE_BLK_QUEUE_DISCARD
+ blk_queue_max_discard_sectors(zv->zv_queue, UINT_MAX);
+ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zv->zv_queue);
+#endif
#ifdef HAVE_BLK_QUEUE_NONROT
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zv->zv_queue);
#endif
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index f8316f960..a3822d902 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/scripts/zpios-profile/Makefile.in b/scripts/zpios-profile/Makefile.in
index 0264aa45d..ed4e3192c 100644
--- a/scripts/zpios-profile/Makefile.in
+++ b/scripts/zpios-profile/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/scripts/zpios-test/Makefile.in b/scripts/zpios-test/Makefile.in
index b5d5d2569..637dfd7fa 100644
--- a/scripts/zpios-test/Makefile.in
+++ b/scripts/zpios-test/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in
index 73c32494d..6afa78fc0 100644
--- a/scripts/zpool-config/Makefile.in
+++ b/scripts/zpool-config/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/scripts/zpool-layout/Makefile.in b/scripts/zpool-layout/Makefile.in
index 70545c4c7..ca0927382 100644
--- a/scripts/zpool-layout/Makefile.in
+++ b/scripts/zpool-layout/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/udev/Makefile.in b/udev/Makefile.in
index 018d0a72e..6b20a9fc6 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/udev/rules.d/Makefile.in b/udev/rules.d/Makefile.in
index 671fb7b75..fe559cd73 100644
--- a/udev/rules.d/Makefile.in
+++ b/udev/rules.d/Makefile.in
@@ -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-discard.m4 \
$(top_srcdir)/config/kernel-blk-queue-flush.m4 \
$(top_srcdir)/config/kernel-blk-queue-io-opt.m4 \
$(top_srcdir)/config/kernel-blk-queue-max-hw-sectors.m4 \
diff --git a/zfs_config.h.in b/zfs_config.h.in
index c91735a8e..887f0f7c9 100644
--- a/zfs_config.h.in
+++ b/zfs_config.h.in
@@ -51,6 +51,9 @@
/* blk_fetch_request() is available */
#undef HAVE_BLK_FETCH_REQUEST
+/* blk_queue_discard() is available */
+#undef HAVE_BLK_QUEUE_DISCARD
+
/* blk_queue_flush() is available */
#undef HAVE_BLK_QUEUE_FLUSH