Linux 5.19 compat: blkdev_issue_secure_erase()
Linux 5.19 commit torvalds/linux@44abff2c0 splits the secure erase functionality from the blkdev_issue_discard() function. The blkdev_issue_secure_erase() must now be issued to issue a secure erase. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #13515
This commit is contained in:
parent
e2c31f2bc7
commit
a12a5cb5b8
|
@ -294,6 +294,57 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl #
|
||||||
|
dnl # 5.19 API: blkdev_issue_secure_erase()
|
||||||
|
dnl # 3.10 API: blkdev_issue_discard(..., BLKDEV_DISCARD_SECURE)
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE], [
|
||||||
|
ZFS_LINUX_TEST_SRC([blkdev_issue_secure_erase], [
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
],[
|
||||||
|
struct block_device *bdev = NULL;
|
||||||
|
sector_t sector = 0;
|
||||||
|
sector_t nr_sects = 0;
|
||||||
|
int error __attribute__ ((unused));
|
||||||
|
|
||||||
|
error = blkdev_issue_secure_erase(bdev,
|
||||||
|
sector, nr_sects, GFP_KERNEL);
|
||||||
|
])
|
||||||
|
|
||||||
|
ZFS_LINUX_TEST_SRC([blkdev_issue_discard_flags], [
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
],[
|
||||||
|
struct block_device *bdev = NULL;
|
||||||
|
sector_t sector = 0;
|
||||||
|
sector_t nr_sects = 0;
|
||||||
|
unsigned long flags = 0;
|
||||||
|
int error __attribute__ ((unused));
|
||||||
|
|
||||||
|
error = blkdev_issue_discard(bdev,
|
||||||
|
sector, nr_sects, GFP_KERNEL, flags);
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE], [
|
||||||
|
AC_MSG_CHECKING([whether blkdev_issue_secure_erase() is available])
|
||||||
|
ZFS_LINUX_TEST_RESULT([blkdev_issue_secure_erase], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_BLKDEV_ISSUE_SECURE_ERASE, 1,
|
||||||
|
[blkdev_issue_secure_erase() is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether blkdev_issue_discard() is available])
|
||||||
|
ZFS_LINUX_TEST_RESULT([blkdev_issue_discard_flags], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_BLKDEV_ISSUE_DISCARD, 1,
|
||||||
|
[blkdev_issue_discard() is available])
|
||||||
|
],[
|
||||||
|
ZFS_LINUX_TEST_ERROR([blkdev_issue_discard()])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
dnl #
|
dnl #
|
||||||
dnl # 5.13 API change
|
dnl # 5.13 API change
|
||||||
dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
|
dnl # blkdev_get_by_path() no longer handles ERESTARTSYS
|
||||||
|
@ -326,6 +377,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
|
||||||
ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
|
ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
|
||||||
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
||||||
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
|
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
|
||||||
|
ZFS_AC_KERNEL_SRC_BLKDEV_ISSUE_SECURE_ERASE
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
|
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
|
||||||
|
@ -340,4 +392,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
|
||||||
ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
||||||
ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
|
ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
|
||||||
ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
|
ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS
|
||||||
|
ZFS_AC_KERNEL_BLKDEV_ISSUE_SECURE_ERASE
|
||||||
])
|
])
|
||||||
|
|
|
@ -751,12 +751,38 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vdev_disk_io_trim(zio_t *zio)
|
||||||
|
{
|
||||||
|
vdev_t *v = zio->io_vd;
|
||||||
|
vdev_disk_t *vd = v->vdev_tsd;
|
||||||
|
|
||||||
|
#if defined(HAVE_BLKDEV_ISSUE_SECURE_ERASE)
|
||||||
|
if (zio->io_trim_flags & ZIO_TRIM_SECURE) {
|
||||||
|
return (-blkdev_issue_secure_erase(vd->vd_bdev,
|
||||||
|
zio->io_offset >> 9, zio->io_size >> 9, GFP_NOFS));
|
||||||
|
} else {
|
||||||
|
return (-blkdev_issue_discard(vd->vd_bdev,
|
||||||
|
zio->io_offset >> 9, zio->io_size >> 9, GFP_NOFS));
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_BLKDEV_ISSUE_DISCARD)
|
||||||
|
unsigned long trim_flags = 0;
|
||||||
|
#if defined(BLKDEV_DISCARD_SECURE)
|
||||||
|
if (zio->io_trim_flags & ZIO_TRIM_SECURE)
|
||||||
|
trim_flags |= BLKDEV_DISCARD_SECURE;
|
||||||
|
#endif
|
||||||
|
return (-blkdev_issue_discard(vd->vd_bdev,
|
||||||
|
zio->io_offset >> 9, zio->io_size >> 9, GFP_NOFS, trim_flags));
|
||||||
|
#else
|
||||||
|
#error "Unsupported kernel"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vdev_disk_io_start(zio_t *zio)
|
vdev_disk_io_start(zio_t *zio)
|
||||||
{
|
{
|
||||||
vdev_t *v = zio->io_vd;
|
vdev_t *v = zio->io_vd;
|
||||||
vdev_disk_t *vd = v->vdev_tsd;
|
vdev_disk_t *vd = v->vdev_tsd;
|
||||||
unsigned long trim_flags = 0;
|
|
||||||
int rw, error;
|
int rw, error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -829,14 +855,7 @@ vdev_disk_io_start(zio_t *zio)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZIO_TYPE_TRIM:
|
case ZIO_TYPE_TRIM:
|
||||||
#if defined(BLKDEV_DISCARD_SECURE)
|
zio->io_error = vdev_disk_io_trim(zio);
|
||||||
if (zio->io_trim_flags & ZIO_TRIM_SECURE)
|
|
||||||
trim_flags |= BLKDEV_DISCARD_SECURE;
|
|
||||||
#endif
|
|
||||||
zio->io_error = -blkdev_issue_discard(vd->vd_bdev,
|
|
||||||
zio->io_offset >> 9, zio->io_size >> 9, GFP_NOFS,
|
|
||||||
trim_flags);
|
|
||||||
|
|
||||||
rw_exit(&vd->vd_lock);
|
rw_exit(&vd->vd_lock);
|
||||||
zio_interrupt(zio);
|
zio_interrupt(zio);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue