List, Tomo Please find attached a tiny patch that adds support for DPO in READ/WRITE/VERIFY 10/12/16 When set to 1 we call posix_fadvise() to let the kernel know we are unlikely to reference this area again. regards ronnie sahlberg
Attachment:
0001-DPO-Add-emulation-of-DPO-bit-for-READ-WRITE-VERIFY10.patch.gz
Description: GNU Zip compressed data
From 38feafe65af95df0e0497df51df18d7ab81e2997 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> Date: Sun, 4 Mar 2012 09:33:48 +1100 Subject: [PATCH] DPO: Add emulation of DPO bit for READ/WRITE/VERIFY10/12/16 When the DPO bit is set to 1, this is an indication the initiator will not reference the data again. For this case, call posix_fadvise() and let the kernel know it may expunge this data from the page cache. From SBC READ10 : NOTE 11 - The DPO bit is used to control replacement of logical blocks in the cache when the application client has information on the future usage of the logical blocks. If the DPO bit is set to one, the application client is specifying that the logical blocks accessed by the command are not likely to be accessed again in the near future and should not be put in the cache nor retained by the cache. If the DPO bit is set to zero, the application client is specifying that the logical blocks accessed by this command are likely to be accessed again in the near future. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> --- usr/bs_rdwr.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c index 276bff3..84ed278 100644 --- a/usr/bs_rdwr.c +++ b/usr/bs_rdwr.c @@ -102,6 +102,10 @@ static void bs_rdwr_request(struct scsi_cmd *cmd) } else set_medium_error(&result, &key, &asc); + if ((cmd->scb[0] != WRITE_6) && (cmd->scb[1] & 0x10)) + posix_fadvise(fd, cmd->offset, length, + POSIX_FADV_NOREUSE); + break; case READ_6: case READ_10: @@ -113,6 +117,11 @@ static void bs_rdwr_request(struct scsi_cmd *cmd) if (ret != length) set_medium_error(&result, &key, &asc); + + if ((cmd->scb[0] != READ_6) && (cmd->scb[1] & 0x10)) + posix_fadvise(fd, cmd->offset, length, + POSIX_FADV_NOREUSE); + break; case PRE_FETCH_10: case PRE_FETCH_16: @@ -145,6 +154,10 @@ static void bs_rdwr_request(struct scsi_cmd *cmd) asc = ASC_MISCOMPARE_DURING_VERIFY_OPERATION; } + if (cmd->scb[1] & 0x10) + posix_fadvise(fd, cmd->offset, length, + POSIX_FADV_NOREUSE); + free(tmpbuf); break; default: -- 1.7.3.1