mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Linux 5.19 compat: bdev_max_discard_sectors()
Linux 5.19 commit torvalds/linux@70200574cc removed the blk_queue_discard() helper function. The preferred interface is to now use the bdev_max_discard_sectors() function to check for discard support. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #13515
This commit is contained in:
parent
5f264996f4
commit
5e4aedaca7
@ -74,6 +74,8 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
|
|||||||
AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
|
AC_DEFINE(HAVE_BLK_QUEUE_UPDATE_READAHEAD, 1,
|
||||||
[blk_queue_update_readahead() exists])
|
[blk_queue_update_readahead() exists])
|
||||||
],[
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether disk_update_readahead() exists])
|
AC_MSG_CHECKING([whether disk_update_readahead() exists])
|
||||||
ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
|
ZFS_LINUX_TEST_RESULT([disk_update_readahead], [
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
@ -86,10 +88,19 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_UPDATE_READAHEAD], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # 2.6.32 API,
|
dnl # 5.19: bdev_max_discard_sectors() available
|
||||||
dnl # blk_queue_discard()
|
dnl # 2.6.32: blk_queue_discard() available
|
||||||
dnl #
|
dnl #
|
||||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
|
||||||
|
ZFS_LINUX_TEST_SRC([bdev_max_discard_sectors], [
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
],[
|
||||||
|
struct block_device *bdev __attribute__ ((unused)) = NULL;
|
||||||
|
unsigned int error __attribute__ ((unused));
|
||||||
|
|
||||||
|
error = bdev_max_discard_sectors(bdev);
|
||||||
|
])
|
||||||
|
|
||||||
ZFS_LINUX_TEST_SRC([blk_queue_discard], [
|
ZFS_LINUX_TEST_SRC([blk_queue_discard], [
|
||||||
#include <linux/blkdev.h>
|
#include <linux/blkdev.h>
|
||||||
],[
|
],[
|
||||||
@ -102,12 +113,23 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
|
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
|
||||||
|
AC_MSG_CHECKING([whether bdev_max_discard_sectors() is available])
|
||||||
|
ZFS_LINUX_TEST_RESULT([bdev_max_discard_sectors], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_BDEV_MAX_DISCARD_SECTORS, 1,
|
||||||
|
[bdev_max_discard_sectors() is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether blk_queue_discard() is available])
|
AC_MSG_CHECKING([whether blk_queue_discard() is available])
|
||||||
ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
|
ZFS_LINUX_TEST_RESULT([blk_queue_discard], [
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_BLK_QUEUE_DISCARD, 1,
|
||||||
|
[blk_queue_discard() is available])
|
||||||
],[
|
],[
|
||||||
ZFS_LINUX_TEST_ERROR([blk_queue_discard])
|
ZFS_LINUX_TEST_ERROR([blk_queue_discard])
|
||||||
])
|
])
|
||||||
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
|
@ -134,6 +134,8 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
|
|||||||
AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
|
AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
|
||||||
[iov_iter_fault_in_readable() is available])
|
[iov_iter_fault_in_readable() is available])
|
||||||
],[
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available])
|
AC_MSG_CHECKING([whether fault_in_iov_iter_readable() is available])
|
||||||
ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [
|
ZFS_LINUX_TEST_RESULT([fault_in_iov_iter_readable], [
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
@ -494,6 +494,25 @@ blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
|
|||||||
q->limits.discard_granularity = dg;
|
q->limits.discard_granularity = dg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 5.19 API,
|
||||||
|
* bdev_max_discard_sectors()
|
||||||
|
*
|
||||||
|
* 2.6.32 API,
|
||||||
|
* blk_queue_discard()
|
||||||
|
*/
|
||||||
|
static inline boolean_t
|
||||||
|
bdev_discard_supported(struct block_device *bdev)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_BDEV_MAX_DISCARD_SECTORS)
|
||||||
|
return (!!bdev_max_discard_sectors(bdev));
|
||||||
|
#elif defined(HAVE_BLK_QUEUE_DISCARD)
|
||||||
|
return (!!blk_queue_discard(bdev_get_queue(bdev)));
|
||||||
|
#else
|
||||||
|
#error "Unsupported kernel"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4.8 API,
|
* 4.8 API,
|
||||||
* blk_queue_secure_erase()
|
* blk_queue_secure_erase()
|
||||||
|
@ -316,7 +316,7 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
|||||||
v->vdev_nowritecache = B_FALSE;
|
v->vdev_nowritecache = B_FALSE;
|
||||||
|
|
||||||
/* Set when device reports it supports TRIM. */
|
/* Set when device reports it supports TRIM. */
|
||||||
v->vdev_has_trim = !!blk_queue_discard(q);
|
v->vdev_has_trim = bdev_discard_supported(vd->vd_bdev);
|
||||||
|
|
||||||
/* Set when device reports it supports secure TRIM. */
|
/* Set when device reports it supports secure TRIM. */
|
||||||
v->vdev_has_securetrim = !!blk_queue_discard_secure(q);
|
v->vdev_has_securetrim = !!blk_queue_discard_secure(q);
|
||||||
|
@ -1053,7 +1053,9 @@ zvol_os_create_minor(const char *name)
|
|||||||
(zvol_max_discard_blocks * zv->zv_volblocksize) >> 9);
|
(zvol_max_discard_blocks * zv->zv_volblocksize) >> 9);
|
||||||
blk_queue_discard_granularity(zv->zv_zso->zvo_queue,
|
blk_queue_discard_granularity(zv->zv_zso->zvo_queue,
|
||||||
zv->zv_volblocksize);
|
zv->zv_volblocksize);
|
||||||
|
#ifdef QUEUE_FLAG_DISCARD
|
||||||
blk_queue_flag_set(QUEUE_FLAG_DISCARD, zv->zv_zso->zvo_queue);
|
blk_queue_flag_set(QUEUE_FLAG_DISCARD, zv->zv_zso->zvo_queue);
|
||||||
|
#endif
|
||||||
#ifdef QUEUE_FLAG_NONROT
|
#ifdef QUEUE_FLAG_NONROT
|
||||||
blk_queue_flag_set(QUEUE_FLAG_NONROT, zv->zv_zso->zvo_queue);
|
blk_queue_flag_set(QUEUE_FLAG_NONROT, zv->zv_zso->zvo_queue);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user