aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Dechamps <[email protected]>2012-08-01 10:29:59 +0200
committerBrian Behlendorf <[email protected]>2012-08-07 14:55:31 -0700
commitee5fd0bb80d68ef095f831784cbb17181b2ba898 (patch)
treee2437a510eaa09db0af6429e1aa94d2d44b35182
parent9a512dca97fec1afa5068b53621ce1dd7dbef578 (diff)
Set zvol discard_granularity to the volblocksize.
Currently, zvols have a discard granularity set to 0, which suggests to the upper layer that discard requests of arbirarily small size and alignment can be made efficiently. In practice however, ZFS does not handle unaligned discard requests efficiently: indeed, it is unable to free a part of a block. It will write zeros to the specified range instead, which is both useless and inefficient (see dnode_free_range). With this patch, zvol block devices expose volblocksize as their discard granularity, so the upper layer is aware that it's not supposed to send discard requests smaller than volblocksize. Signed-off-by: Brian Behlendorf <[email protected]> Closes #862
-rw-r--r--Makefile.in1
-rw-r--r--cmd/Makefile.in1
-rw-r--r--cmd/mount_zfs/Makefile.in1
-rw-r--r--cmd/vdev_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-discard-granularity.m420
-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.h15
-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/man5/Makefile.in1
-rw-r--r--man/man8/Makefile.in1
-rw-r--r--module/zfs/zvol.c1
-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
61 files changed, 233 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
index 52946a266..a8b6a09f0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -91,6 +91,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/Makefile.in b/cmd/Makefile.in
index bd03b3558..3a031e875 100644
--- a/cmd/Makefile.in
+++ b/cmd/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/mount_zfs/Makefile.in b/cmd/mount_zfs/Makefile.in
index 0a6ca2e09..b0e80aa20 100644
--- a/cmd/mount_zfs/Makefile.in
+++ b/cmd/mount_zfs/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/vdev_id/Makefile.in b/cmd/vdev_id/Makefile.in
index 4a8ecfd4a..56b1ebe77 100644
--- a/cmd/vdev_id/Makefile.in
+++ b/cmd/vdev_id/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zdb/Makefile.in b/cmd/zdb/Makefile.in
index 6842334f5..e55f6adf5 100644
--- a/cmd/zdb/Makefile.in
+++ b/cmd/zdb/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zfs/Makefile.in b/cmd/zfs/Makefile.in
index 582604b69..bdd2914d9 100644
--- a/cmd/zfs/Makefile.in
+++ b/cmd/zfs/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zinject/Makefile.in b/cmd/zinject/Makefile.in
index 1a8a7837f..d229f81dd 100644
--- a/cmd/zinject/Makefile.in
+++ b/cmd/zinject/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zpios/Makefile.in b/cmd/zpios/Makefile.in
index 6bfb81c9e..40db43c30 100644
--- a/cmd/zpios/Makefile.in
+++ b/cmd/zpios/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zpool/Makefile.in b/cmd/zpool/Makefile.in
index 9ac1d2e77..74390c423 100644
--- a/cmd/zpool/Makefile.in
+++ b/cmd/zpool/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zpool_id/Makefile.in b/cmd/zpool_id/Makefile.in
index 67812174f..c4dc586e2 100644
--- a/cmd/zpool_id/Makefile.in
+++ b/cmd/zpool_id/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zpool_layout/Makefile.in b/cmd/zpool_layout/Makefile.in
index c6a2f0db4..d13c2e6bf 100644
--- a/cmd/zpool_layout/Makefile.in
+++ b/cmd/zpool_layout/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/ztest/Makefile.in b/cmd/ztest/Makefile.in
index 2dbdfd4d7..b4cdc2284 100644
--- a/cmd/ztest/Makefile.in
+++ b/cmd/ztest/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/cmd/zvol_id/Makefile.in b/cmd/zvol_id/Makefile.in
index d16e5b75c..acc243317 100644
--- a/cmd/zvol_id/Makefile.in
+++ b/cmd/zvol_id/Makefile.in
@@ -71,6 +71,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/config/kernel-discard-granularity.m4 b/config/kernel-discard-granularity.m4
new file mode 100644
index 000000000..2c677c909
--- /dev/null
+++ b/config/kernel-discard-granularity.m4
@@ -0,0 +1,20 @@
+dnl #
+dnl # 2.6.33 API change
+dnl # Discard granularity and alignment restrictions may now be set.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_DISCARD_GRANULARITY], [
+ AC_MSG_CHECKING([whether ql->discard_granularity is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/blkdev.h>
+ ],[
+ struct queue_limits ql __attribute__ ((unused));
+
+ ql.discard_granularity = 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_DISCARD_GRANULARITY, 1,
+ [ql->discard_granularity is available])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel.m4 b/config/kernel.m4
index a40bb5b6c..260ad84f4 100644
--- a/config/kernel.m4
+++ b/config/kernel.m4
@@ -39,6 +39,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_GET_GENDISK
ZFS_AC_KERNEL_RQ_IS_SYNC
ZFS_AC_KERNEL_RQ_FOR_EACH_SEGMENT
+ ZFS_AC_KERNEL_DISCARD_GRANULARITY
ZFS_AC_KERNEL_CONST_XATTR_HANDLER
ZFS_AC_KERNEL_XATTR_HANDLER_GET
ZFS_AC_KERNEL_XATTR_HANDLER_SET
diff --git a/configure b/configure
index 9b97fb427..313e05137 100755
--- a/configure
+++ b/configure
@@ -15369,6 +15369,75 @@ fi
EXTRA_KCFLAGS="$tmp_flags"
+
+ { $as_echo "$as_me:$LINENO: checking whether ql->discard_granularity is available" >&5
+$as_echo_n "checking whether ql->discard_granularity is available... " >&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/blkdev.h>
+
+int
+main (void)
+{
+
+ struct queue_limits ql __attribute__ ((unused));
+
+ ql.discard_granularity = 0;
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ 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 $modpost_flag'
+ { (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_DISCARD_GRANULARITY 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 super_block uses const struct xattr_hander" >&5
$as_echo_n "checking whether super_block uses const struct xattr_hander... " >&6; }
@@ -22873,6 +22942,75 @@ fi
EXTRA_KCFLAGS="$tmp_flags"
+
+ { $as_echo "$as_me:$LINENO: checking whether ql->discard_granularity is available" >&5
+$as_echo_n "checking whether ql->discard_granularity is available... " >&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/blkdev.h>
+
+int
+main (void)
+{
+
+ struct queue_limits ql __attribute__ ((unused));
+
+ ql.discard_granularity = 0;
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ 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 $modpost_flag'
+ { (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_DISCARD_GRANULARITY 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 super_block uses const struct xattr_hander" >&5
$as_echo_n "checking whether super_block uses const struct xattr_hander... " >&6; }
diff --git a/dracut/90zfs/Makefile.in b/dracut/90zfs/Makefile.in
index 956e45860..60fa58509 100644
--- a/dracut/90zfs/Makefile.in
+++ b/dracut/90zfs/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/dracut/Makefile.in b/dracut/Makefile.in
index 0e98a6ca9..cda6b566b 100644
--- a/dracut/Makefile.in
+++ b/dracut/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/etc/Makefile.in b/etc/Makefile.in
index 850bff29c..44d418c4d 100644
--- a/etc/Makefile.in
+++ b/etc/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/etc/init.d/Makefile.in b/etc/init.d/Makefile.in
index 0ddd918ee..559726126 100644
--- a/etc/init.d/Makefile.in
+++ b/etc/init.d/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/etc/zfs/Makefile.in b/etc/zfs/Makefile.in
index b9fbd1727..fe4596f09 100644
--- a/etc/zfs/Makefile.in
+++ b/etc/zfs/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/Makefile.in b/include/Makefile.in
index 4bacc977d..da7c0018f 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/linux/Makefile.in b/include/linux/Makefile.in
index cdf0e1c62..aa5651d3e 100644
--- a/include/linux/Makefile.in
+++ b/include/linux/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/linux/blkdev_compat.h b/include/linux/blkdev_compat.h
index bd1b2bf54..a5294ceba 100644
--- a/include/linux/blkdev_compat.h
+++ b/include/linux/blkdev_compat.h
@@ -433,6 +433,21 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
#endif
/*
+ * 2.6.33 API change
+ * Discard granularity and alignment restrictions may now be set. For
+ * older kernels which do not support this it is safe to skip it.
+ */
+#ifdef HAVE_DISCARD_GRANULARITY
+static inline void
+blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
+{
+ q->limits.discard_granularity = dg;
+}
+#else
+#define blk_queue_discard_granularity(x, dg) ((void)0)
+#endif /* HAVE_DISCARD_GRANULARITY */
+
+/*
* 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 e6e880bab..be2aec909 100644
--- a/include/sys/Makefile.in
+++ b/include/sys/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in
index 9d2aff60b..9193af56b 100644
--- a/include/sys/fm/Makefile.in
+++ b/include/sys/fm/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in
index feac8f9fb..8d7829d83 100644
--- a/include/sys/fm/fs/Makefile.in
+++ b/include/sys/fm/fs/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in
index c1bff97bb..7529f0682 100644
--- a/include/sys/fs/Makefile.in
+++ b/include/sys/fs/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 87dfb2fba..1ad953932 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libavl/Makefile.in b/lib/libavl/Makefile.in
index 26dacbec9..f5311c3c0 100644
--- a/lib/libavl/Makefile.in
+++ b/lib/libavl/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in
index e9b8f9559..7a60887d4 100644
--- a/lib/libefi/Makefile.in
+++ b/lib/libefi/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libnvpair/Makefile.in b/lib/libnvpair/Makefile.in
index 0f36765c1..2e0fcf9e1 100644
--- a/lib/libnvpair/Makefile.in
+++ b/lib/libnvpair/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libshare/Makefile.in b/lib/libshare/Makefile.in
index 811b05101..081ce0992 100644
--- a/lib/libshare/Makefile.in
+++ b/lib/libshare/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/Makefile.in b/lib/libspl/Makefile.in
index 88ded3bb9..89fe88ac4 100644
--- a/lib/libspl/Makefile.in
+++ b/lib/libspl/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/asm-generic/Makefile.in b/lib/libspl/asm-generic/Makefile.in
index b8ba11408..b7059c02f 100644
--- a/lib/libspl/asm-generic/Makefile.in
+++ b/lib/libspl/asm-generic/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/asm-i386/Makefile.in b/lib/libspl/asm-i386/Makefile.in
index 7cd6977b2..8e7e590fe 100644
--- a/lib/libspl/asm-i386/Makefile.in
+++ b/lib/libspl/asm-i386/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/asm-x86_64/Makefile.in b/lib/libspl/asm-x86_64/Makefile.in
index 083fee5d5..3df767a15 100644
--- a/lib/libspl/asm-x86_64/Makefile.in
+++ b/lib/libspl/asm-x86_64/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/Makefile.in b/lib/libspl/include/Makefile.in
index 0c6fdcf69..b81c3dbe8 100644
--- a/lib/libspl/include/Makefile.in
+++ b/lib/libspl/include/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/ia32/Makefile.in b/lib/libspl/include/ia32/Makefile.in
index 02186ac39..23ffb4dc1 100644
--- a/lib/libspl/include/ia32/Makefile.in
+++ b/lib/libspl/include/ia32/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/ia32/sys/Makefile.in b/lib/libspl/include/ia32/sys/Makefile.in
index f9e0236bc..2b2c230f9 100644
--- a/lib/libspl/include/ia32/sys/Makefile.in
+++ b/lib/libspl/include/ia32/sys/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/rpc/Makefile.in b/lib/libspl/include/rpc/Makefile.in
index b601bc125..3752b74df 100644
--- a/lib/libspl/include/rpc/Makefile.in
+++ b/lib/libspl/include/rpc/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in
index 8258f0fe0..fec69dfe7 100644
--- a/lib/libspl/include/sys/Makefile.in
+++ b/lib/libspl/include/sys/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/sys/dktp/Makefile.in b/lib/libspl/include/sys/dktp/Makefile.in
index 9ea3a27c2..3932adcba 100644
--- a/lib/libspl/include/sys/dktp/Makefile.in
+++ b/lib/libspl/include/sys/dktp/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/sys/sysevent/Makefile.in b/lib/libspl/include/sys/sysevent/Makefile.in
index 62b876137..7d784f360 100644
--- a/lib/libspl/include/sys/sysevent/Makefile.in
+++ b/lib/libspl/include/sys/sysevent/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libspl/include/util/Makefile.in b/lib/libspl/include/util/Makefile.in
index cf37f1639..e32a340d2 100644
--- a/lib/libspl/include/util/Makefile.in
+++ b/lib/libspl/include/util/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libunicode/Makefile.in b/lib/libunicode/Makefile.in
index 4ca968241..971a2bc5e 100644
--- a/lib/libunicode/Makefile.in
+++ b/lib/libunicode/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libuutil/Makefile.in b/lib/libuutil/Makefile.in
index a90c890cb..64b2c3005 100644
--- a/lib/libuutil/Makefile.in
+++ b/lib/libuutil/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libzfs/Makefile.in b/lib/libzfs/Makefile.in
index c2c1d2e4a..f22b6f0a5 100644
--- a/lib/libzfs/Makefile.in
+++ b/lib/libzfs/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/lib/libzpool/Makefile.in b/lib/libzpool/Makefile.in
index a94b7e1cd..b0c001545 100644
--- a/lib/libzpool/Makefile.in
+++ b/lib/libzpool/Makefile.in
@@ -70,6 +70,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/man/Makefile.in b/man/Makefile.in
index 1996ca2e5..9c333675e 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/man/man5/Makefile.in b/man/man5/Makefile.in
index b0346ccfe..ad3c16f17 100644
--- a/man/man5/Makefile.in
+++ b/man/man5/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in
index c91894424..5412e744f 100644
--- a/man/man8/Makefile.in
+++ b/man/man8/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 32e4f3c1e..07bda6dba 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -1245,6 +1245,7 @@ __zvol_create_minor(const char *name)
#ifdef HAVE_BLK_QUEUE_DISCARD
blk_queue_max_discard_sectors(zv->zv_queue,
(zvol_max_discard_blocks * zv->zv_volblocksize) >> 9);
+ blk_queue_discard_granularity(zv->zv_queue, zv->zv_volblocksize);
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zv->zv_queue);
#endif
#ifdef HAVE_BLK_QUEUE_NONROT
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 3bc46fcbf..73c96feb1 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/scripts/zpios-profile/Makefile.in b/scripts/zpios-profile/Makefile.in
index c51db4236..2533fa1c7 100644
--- a/scripts/zpios-profile/Makefile.in
+++ b/scripts/zpios-profile/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/scripts/zpios-test/Makefile.in b/scripts/zpios-test/Makefile.in
index c05e18b9a..cbcf1df07 100644
--- a/scripts/zpios-test/Makefile.in
+++ b/scripts/zpios-test/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in
index 17043188e..f1ec2f829 100644
--- a/scripts/zpool-config/Makefile.in
+++ b/scripts/zpool-config/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/scripts/zpool-layout/Makefile.in b/scripts/zpool-layout/Makefile.in
index 1f82746ab..81e036d63 100644
--- a/scripts/zpool-layout/Makefile.in
+++ b/scripts/zpool-layout/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/udev/Makefile.in b/udev/Makefile.in
index 33b2c5852..b961f0f17 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -68,6 +68,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/udev/rules.d/Makefile.in b/udev/rules.d/Makefile.in
index f0c78e091..846ca5944 100644
--- a/udev/rules.d/Makefile.in
+++ b/udev/rules.d/Makefile.in
@@ -69,6 +69,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/kernel-create-umode-t.m4 \
$(top_srcdir)/config/kernel-d-make-root.m4 \
$(top_srcdir)/config/kernel-d-obtain-alias.m4 \
+ $(top_srcdir)/config/kernel-discard-granularity.m4 \
$(top_srcdir)/config/kernel-encode-fh-inode.m4 \
$(top_srcdir)/config/kernel-evict-inode.m4 \
$(top_srcdir)/config/kernel-fallocate.m4 \
diff --git a/zfs_config.h.in b/zfs_config.h.in
index 15f5a5cae..260bd5ab7 100644
--- a/zfs_config.h.in
+++ b/zfs_config.h.in
@@ -120,6 +120,9 @@
/* xattr_handler->set() wants dentry */
#undef HAVE_DENTRY_XATTR_SET
+/* ql->discard_granularity is available */
+#undef HAVE_DISCARD_GRANULARITY
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H