From 31ab1e1ac9815bec9c63ab12799fe4aa6c5be091 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Thu, 31 May 2018 22:49:04 +0200 Subject: [PATCH] test-tool: add prin_read_keys() allocation_len parameter Accepting an Allocation Length parameter allows us to test for truncation of response data, as per SPC5r17 4.2.5.6: The device server shall terminate transfers to the Data-In Buffer when the number of bytes or blocks specified by the ALLOCATION LENGTH field have been transferred or when all available data have been transferred, whichever is less. With this change, all existing prin_read_keys() callers continue to use same ALLOCATION LENGTH value as earlier (16K). Signed-off-by: David Disseldorp --- test-tool/iscsi-support.c | 9 +++++---- test-tool/iscsi-support.h | 3 ++- test-tool/iscsi-test-cu.c | 2 +- test-tool/test_prin_read_keys_simple.c | 2 +- test-tool/test_prin_serviceaction_range.c | 4 ++-- test-tool/test_prout_clear_simple.c | 6 +++--- test-tool/test_prout_preempt.c | 4 ++-- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 958dce9..f0446a6 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -667,17 +667,18 @@ prin_task(struct scsi_device *sdev, int service_action, } int -prin_read_keys(struct scsi_device *sdev, struct scsi_task **tp, - struct scsi_persistent_reserve_in_read_keys **rkp) +prin_read_keys(struct scsi_device *sdev, + struct scsi_task **tp, + struct scsi_persistent_reserve_in_read_keys **rkp, + uint16_t allocation_len) { - const int buf_sz = 16384; struct scsi_persistent_reserve_in_read_keys *rk = NULL; logging(LOG_VERBOSE, "Send PRIN/READ_KEYS"); *tp = scsi_cdb_persistent_reserve_in(SCSI_PERSISTENT_RESERVE_READ_KEYS, - buf_sz); + allocation_len); assert(*tp != NULL); *tp = send_scsi_command(sdev, *tp, NULL); diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 283d597..5f79d8b 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -822,7 +822,8 @@ int all_zero(const unsigned char *buf, unsigned size); int prin_task(struct scsi_device *sdev, int service_action, int success_expected); int prin_read_keys(struct scsi_device *sdev, struct scsi_task **tp, - struct scsi_persistent_reserve_in_read_keys **rkp); + struct scsi_persistent_reserve_in_read_keys **rkp, + uint16_t allocation_len); int prout_register_and_ignore(struct scsi_device *sdev, unsigned long long key); int prout_register_key(struct scsi_device *sdev, diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 3ec3b09..a4c4a0b 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -1069,7 +1069,7 @@ static int clear_pr(struct scsi_device *sdev) struct scsi_persistent_reserve_in_read_keys *rk; res = 0; - if (prin_read_keys(sdev, &pr_task, &rk) != 0) + if (prin_read_keys(sdev, &pr_task, &rk, 16384) != 0) goto out; res = -1; diff --git a/test-tool/test_prin_read_keys_simple.c b/test-tool/test_prin_read_keys_simple.c index f268e96..5797091 100644 --- a/test-tool/test_prin_read_keys_simple.c +++ b/test-tool/test_prin_read_keys_simple.c @@ -37,7 +37,7 @@ test_prin_read_keys_simple(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works."); - ret = prin_read_keys(sd, &task, NULL); + ret = prin_read_keys(sd, &task, NULL, 16384); if (ret == -2) { CU_PASS("PERSISTENT RESERVE IN is not implemented."); return; diff --git a/test-tool/test_prin_serviceaction_range.c b/test-tool/test_prin_serviceaction_range.c index e261d6a..4bc1094 100644 --- a/test-tool/test_prin_serviceaction_range.c +++ b/test-tool/test_prin_serviceaction_range.c @@ -38,11 +38,11 @@ test_prin_serviceaction_range(void) logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range."); /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */ - ret = prin_read_keys(sd, &task, NULL); + ret = prin_read_keys(sd, &task, NULL, 16384); if (ret == -2) { CU_PASS("PERSISTENT RESERVE IN is not implemented."); return; - } + } CU_ASSERT_EQUAL(ret, 0); /* verify that PRIN/SA={0,1,2,3} works ... */ diff --git a/test-tool/test_prout_clear_simple.c b/test-tool/test_prout_clear_simple.c index 2203998..c570945 100644 --- a/test-tool/test_prout_clear_simple.c +++ b/test-tool/test_prout_clear_simple.c @@ -45,10 +45,10 @@ test_prout_clear_simple(void) if (ret == -2) { CU_PASS("PERSISTENT RESERVE OUT is not implemented."); return; - } + } CU_ASSERT_EQUAL(ret, 0); - ret = prin_read_keys(sd, &tsk, &rk); + ret = prin_read_keys(sd, &tsk, &rk, 16384); CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(rk, NULL); if (!rk) @@ -78,7 +78,7 @@ test_prout_clear_simple(void) ret = prin_verify_not_reserved(sd); CU_ASSERT_EQUAL(ret, 0); - ret = prin_read_keys(sd, &tsk, &rk); + ret = prin_read_keys(sd, &tsk, &rk, 16384); CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(rk, NULL); if (!rk) diff --git a/test-tool/test_prout_preempt.c b/test-tool/test_prout_preempt.c index 90c0f76..0c11c33 100644 --- a/test-tool/test_prout_preempt.c +++ b/test-tool/test_prout_preempt.c @@ -78,7 +78,7 @@ test_prout_preempt_rm_reg(void) CU_ASSERT_EQUAL(ret, 0); /* confirm that k1 and k2 are registered */ - ret = prin_read_keys(sd, &tsk, &rk); + ret = prin_read_keys(sd, &tsk, &rk, 16384); CU_ASSERT_EQUAL_FATAL(ret, 0); CU_ASSERT_EQUAL(rk->num_keys, 2); @@ -99,7 +99,7 @@ test_prout_preempt_rm_reg(void) ret = test_iscsi_tur_until_good(sd2, &num_uas); CU_ASSERT_EQUAL(ret, 0); - ret = prin_read_keys(sd, &tsk, &rk); + ret = prin_read_keys(sd, &tsk, &rk, 16384); CU_ASSERT_EQUAL_FATAL(ret, 0); CU_ASSERT_EQUAL(rk->num_keys, 1);