aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2022-05-27 19:40:22 +0000
committerBrian Behlendorf <[email protected]>2022-06-01 14:24:49 -0700
commit7ae5ea8864d7a0cbf63feb61bd9022adc803b60d (patch)
tree5cf49007b7f1c940b8e5d1d5d356580839deb0a2 /module
parent048301b6dc37293006a11963a3a270db664eb919 (diff)
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 <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #13515
Diffstat (limited to 'module')
-rw-r--r--module/os/linux/zfs/vdev_disk.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c
index 950da87f3..97cd90bf0 100644
--- a/module/os/linux/zfs/vdev_disk.c
+++ b/module/os/linux/zfs/vdev_disk.c
@@ -749,12 +749,38 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
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
vdev_disk_io_start(zio_t *zio)
{
vdev_t *v = zio->io_vd;
vdev_disk_t *vd = v->vdev_tsd;
- unsigned long trim_flags = 0;
int rw, error;
/*
@@ -827,14 +853,7 @@ vdev_disk_io_start(zio_t *zio)
break;
case ZIO_TYPE_TRIM:
-#if defined(BLKDEV_DISCARD_SECURE)
- 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);
-
+ zio->io_error = vdev_disk_io_trim(zio);
rw_exit(&vd->vd_lock);
zio_interrupt(zio);
return;