Re: [PATCH 06/10] engines/libblkio: Add option libblkio_write_zeroes_on_trim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/21/22 13:28, Alberto Faria wrote:
When set, trim IOs will be submitted as blkioq_write_zeroes() requests
instead of blkioq_discard() requests.

Signed-off-by: Alberto Faria <afaria@xxxxxxxxxx>
---
  HOWTO.rst          |  5 +++++
  engines/libblkio.c | 20 ++++++++++++++++++--
  fio.1              |  4 ++++
  3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/HOWTO.rst b/HOWTO.rst
index b9c7c8df..7155add6 100644
--- a/HOWTO.rst
+++ b/HOWTO.rst
@@ -2879,6 +2879,11 @@ with the caveat that when used on the command line, they must come after the
Submit vectored read and write requests. Default is 0. +.. option:: libblkio_write_zeroes_on_trim=bool : [libblkio]

Same comment here as for libblkio_vectored regarding option types.

+
+	Submit trims as "write zeroes" requests instead of discard requests.
+	Default is 0.
+
  I/O depth
  ~~~~~~~~~
diff --git a/engines/libblkio.c b/engines/libblkio.c
index dcf701ad..79af3aa7 100644
--- a/engines/libblkio.c
+++ b/engines/libblkio.c
@@ -29,6 +29,7 @@ struct fio_blkio_options {
unsigned int hipri;
  	unsigned int vectored;
+	unsigned int write_zeroes_on_trim;
  };
static struct fio_option options[] = {
@@ -78,6 +79,16 @@ static struct fio_option options[] = {
  		.category = FIO_OPT_C_ENGINE,
  		.group	= FIO_OPT_G_LIBBLKIO,
  	},
+	{
+		.name	= "libblkio_write_zeroes_on_trim",
+		.lname	= "Use blkioq_write_zeroes() for TRIM",
+		.type	= FIO_OPT_STR_SET,
+		.off1	= offsetof(struct fio_blkio_options,
+				   write_zeroes_on_trim),
+		.help	= "Use blkioq_write_zeroes() for TRIM instead of blkioq_discard()",
+		.category = FIO_OPT_C_ENGINE,
+		.group	= FIO_OPT_G_LIBBLKIO,
+	},
{
  		.name = NULL,
@@ -484,8 +495,13 @@ static enum fio_q_status fio_blkio_queue(struct thread_data *td,
  			break;
case DDIR_TRIM:
-			blkioq_discard(data->q, io_u->offset, io_u->xfer_buflen,
-				       io_u, 0);
+			if (options->write_zeroes_on_trim) {
+				blkioq_write_zeroes(data->q, io_u->offset,
+						    io_u->xfer_buflen, io_u, 0);
+			} else {
+				blkioq_discard(data->q, io_u->offset,
+					       io_u->xfer_buflen, io_u, 0);
+			}
  		        break;
case DDIR_SYNC:
diff --git a/fio.1 b/fio.1
index a403b415..053c2eda 100644
--- a/fio.1
+++ b/fio.1
@@ -2626,6 +2626,10 @@ Use poll queues.
  .TP
  .BI (libblkio)libblkio_vectored \fR=\fPbool
  Submit vectored read and write requests. Default is 0.
+.TP
+.BI (libblkio)libblkio_write_zeroes_on_trim \fR=\fPbool
+Submit trims as "write zeroes" requests instead of discard requests. Default is
+0.
  .SS "I/O depth"
  .TP
  .BI iodepth \fR=\fPint




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux