File lu-perform-lba-range-check-before-0-byte-fastpath.patch of Package istgt
From 87d106f8ab70594bb6456122da9b1f9e0d5328c9 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Tue, 26 Mar 2013 18:14:50 +0100
Subject: [PATCH 2/7] lu: perform lba range check before 0 byte fastpath
0 byte IOs are subject to the same lba checks as normal IOs.
---
src/istgt_lu_disk.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git src/istgt_lu_disk.c src/istgt_lu_disk.c
index 2850955..277e8d2 100644
--- src/istgt_lu_disk.c
+++ src/istgt_lu_disk.c
@@ -4020,12 +4020,6 @@ istgt_lu_disk_lbread(ISTGT_LU_DISK *spec, CONN_Ptr conn __attribute__((__unused_
uint64_t nbytes;
int64_t rc;
- if (len == 0) {
- lu_cmd->data = NULL;
- lu_cmd->data_len = 0;
- return 0;
- }
-
maxlba = spec->blockcnt;
llen = (uint64_t) len;
blen = spec->blocklen;
@@ -4041,6 +4035,12 @@ istgt_lu_disk_lbread(ISTGT_LU_DISK *spec, CONN_Ptr conn __attribute__((__unused_
return -1;
}
+ if (len == 0) {
+ lu_cmd->data = NULL;
+ lu_cmd->data_len = 0;
+ return 0;
+ }
+
if (nbytes > lu_cmd->iobufsize) {
ISTGT_ERRLOG("nbytes(%zu) > iobufsize(%zu)\n",
(size_t) nbytes, lu_cmd->iobufsize);
@@ -4079,11 +4079,6 @@ istgt_lu_disk_lbwrite(ISTGT_LU_DISK *spec, CONN_Ptr conn, ISTGT_LU_CMD_Ptr lu_cm
uint64_t nbytes;
int64_t rc;
- if (len == 0) {
- lu_cmd->data_len = 0;
- return 0;
- }
-
maxlba = spec->blockcnt;
llen = (uint64_t) len;
blen = spec->blocklen;
@@ -4099,6 +4094,11 @@ istgt_lu_disk_lbwrite(ISTGT_LU_DISK *spec, CONN_Ptr conn, ISTGT_LU_CMD_Ptr lu_cm
return -1;
}
+ if (len == 0) {
+ lu_cmd->data_len = 0;
+ return 0;
+ }
+
if (nbytes > lu_cmd->iobufsize) {
ISTGT_ERRLOG("nbytes(%zu) > iobufsize(%zu)\n",
(size_t) nbytes, lu_cmd->iobufsize);
--
1.8.1.4