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_secure_erase_sectors()
Linux 5.19 commit torvalds/linux@44abff2c0 removed the blk_queue_secure_erase() helper function. The preferred interface is to now use the bdev_max_secure_erase_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
5e4aedaca7
commit
e2c31f2bc7
@ -133,13 +133,20 @@ AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_DISCARD], [
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 4.8 API,
|
||||
dnl # blk_queue_secure_erase()
|
||||
dnl #
|
||||
dnl # 2.6.36 - 4.7 API,
|
||||
dnl # blk_queue_secdiscard()
|
||||
dnl # 5.19: bdev_max_secure_erase_sectors() available
|
||||
dnl # 4.8: blk_queue_secure_erase() available
|
||||
dnl # 2.6.36: blk_queue_secdiscard() available
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
|
||||
ZFS_LINUX_TEST_SRC([bdev_max_secure_erase_sectors], [
|
||||
#include <linux/blkdev.h>
|
||||
],[
|
||||
struct block_device *bdev __attribute__ ((unused)) = NULL;
|
||||
unsigned int error __attribute__ ((unused));
|
||||
|
||||
error = bdev_max_secure_erase_sectors(bdev);
|
||||
])
|
||||
|
||||
ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [
|
||||
#include <linux/blkdev.h>
|
||||
],[
|
||||
@ -162,21 +169,30 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE], [
|
||||
AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
|
||||
ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
|
||||
AC_MSG_CHECKING([whether bdev_max_secure_erase_sectors() is available])
|
||||
ZFS_LINUX_TEST_RESULT([bdev_max_secure_erase_sectors], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
|
||||
[blk_queue_secure_erase() is available])
|
||||
AC_DEFINE(HAVE_BDEV_MAX_SECURE_ERASE_SECTORS, 1,
|
||||
[bdev_max_secure_erase_sectors() is available])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
|
||||
AC_MSG_CHECKING([whether blk_queue_secdiscard() is available])
|
||||
ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [
|
||||
AC_MSG_CHECKING([whether blk_queue_secure_erase() is available])
|
||||
ZFS_LINUX_TEST_RESULT([blk_queue_secure_erase], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1,
|
||||
[blk_queue_secdiscard() is available])
|
||||
AC_DEFINE(HAVE_BLK_QUEUE_SECURE_ERASE, 1,
|
||||
[blk_queue_secure_erase() is available])
|
||||
],[
|
||||
ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
|
||||
AC_MSG_RESULT(no)
|
||||
|
||||
AC_MSG_CHECKING([whether blk_queue_secdiscard() is available])
|
||||
ZFS_LINUX_TEST_RESULT([blk_queue_secdiscard], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_BLK_QUEUE_SECDISCARD, 1,
|
||||
[blk_queue_secdiscard() is available])
|
||||
],[
|
||||
ZFS_LINUX_TEST_ERROR([blk_queue_secure_erase])
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
|
@ -514,21 +514,26 @@ bdev_discard_supported(struct block_device *bdev)
|
||||
}
|
||||
|
||||
/*
|
||||
* 5.19 API,
|
||||
* bdev_max_secure_erase_sectors()
|
||||
*
|
||||
* 4.8 API,
|
||||
* blk_queue_secure_erase()
|
||||
*
|
||||
* 2.6.36 - 4.7 API,
|
||||
* blk_queue_secdiscard()
|
||||
*/
|
||||
static inline int
|
||||
blk_queue_discard_secure(struct request_queue *q)
|
||||
static inline boolean_t
|
||||
bdev_secure_discard_supported(struct block_device *bdev)
|
||||
{
|
||||
#if defined(HAVE_BLK_QUEUE_SECURE_ERASE)
|
||||
return (blk_queue_secure_erase(q));
|
||||
#if defined(HAVE_BDEV_MAX_SECURE_ERASE_SECTORS)
|
||||
return (!!bdev_max_secure_erase_sectors(bdev));
|
||||
#elif defined(HAVE_BLK_QUEUE_SECURE_ERASE)
|
||||
return (!!blk_queue_secure_erase(bdev_get_queue(bdev)));
|
||||
#elif defined(HAVE_BLK_QUEUE_SECDISCARD)
|
||||
return (blk_queue_secdiscard(q));
|
||||
return (!!blk_queue_secdiscard(bdev_get_queue(bdev)));
|
||||
#else
|
||||
return (0);
|
||||
#error "Unsupported kernel"
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -304,8 +304,6 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
||||
rw_exit(&vd->vd_lock);
|
||||
}
|
||||
|
||||
struct request_queue *q = bdev_get_queue(vd->vd_bdev);
|
||||
|
||||
/* Determine the physical block size */
|
||||
int physical_block_size = bdev_physical_block_size(vd->vd_bdev);
|
||||
|
||||
@ -319,10 +317,10 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
||||
v->vdev_has_trim = bdev_discard_supported(vd->vd_bdev);
|
||||
|
||||
/* Set when device reports it supports secure TRIM. */
|
||||
v->vdev_has_securetrim = !!blk_queue_discard_secure(q);
|
||||
v->vdev_has_securetrim = bdev_secure_discard_supported(vd->vd_bdev);
|
||||
|
||||
/* Inform the ZIO pipeline that we are non-rotational */
|
||||
v->vdev_nonrot = blk_queue_nonrot(q);
|
||||
v->vdev_nonrot = blk_queue_nonrot(bdev_get_queue(vd->vd_bdev));
|
||||
|
||||
/* Physical volume size in bytes for the partition */
|
||||
*psize = bdev_capacity(vd->vd_bdev);
|
||||
|
Loading…
Reference in New Issue
Block a user