Merge remote branch 'gonzoleeman/master'
This commit is contained in:
@@ -160,6 +160,7 @@ EXTERN const char *scsi_sense_key_str(int key);
|
|||||||
|
|
||||||
EXTERN const char *scsi_sense_ascq_str(int ascq);
|
EXTERN const char *scsi_sense_ascq_str(int ascq);
|
||||||
|
|
||||||
|
EXTERN const char *scsi_pr_type_str(enum scsi_persistent_out_type pr_type);
|
||||||
|
|
||||||
enum scsi_xfer_dir {
|
enum scsi_xfer_dir {
|
||||||
SCSI_XFER_NONE = 0,
|
SCSI_XFER_NONE = 0,
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ scsi_inquiry_pagecode_to_str
|
|||||||
scsi_protocol_identifier_to_str
|
scsi_protocol_identifier_to_str
|
||||||
scsi_reportluns_cdb
|
scsi_reportluns_cdb
|
||||||
scsi_sense_ascq_str
|
scsi_sense_ascq_str
|
||||||
|
scsi_pr_type_str
|
||||||
scsi_sense_key_str
|
scsi_sense_key_str
|
||||||
scsi_set_task_private_ptr
|
scsi_set_task_private_ptr
|
||||||
scsi_task_add_data_in_buffer
|
scsi_task_add_data_in_buffer
|
||||||
|
|||||||
@@ -163,6 +163,28 @@ scsi_sense_ascq_str(int ascq)
|
|||||||
return value_string_find(ascqs, ascq);
|
return value_string_find(ascqs, ascq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
scsi_pr_type_str(enum scsi_persistent_out_type pr_type)
|
||||||
|
{
|
||||||
|
struct value_string pr_type_strings[] = {
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
|
||||||
|
"Write Exclusive"},
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
|
||||||
|
"Exclusive Access"},
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
|
||||||
|
"Write Exclusive, Registrants Only"},
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
|
||||||
|
"Exclusive Access Registrants Only"},
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
|
||||||
|
"Write Exclusive, All Registrants"},
|
||||||
|
{SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
|
||||||
|
"Exclusive Access, All Registrants"},
|
||||||
|
{0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
return value_string_find(pr_type_strings, pr_type);
|
||||||
|
}
|
||||||
|
|
||||||
inline uint64_t
|
inline uint64_t
|
||||||
scsi_get_uint64(const unsigned char *c)
|
scsi_get_uint64(const unsigned char *c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,15 @@
|
|||||||
#include "iscsi-test.h"
|
#include "iscsi-test.h"
|
||||||
|
|
||||||
|
|
||||||
|
static enum scsi_persistent_out_type pr_types_to_test[] = {
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
|
||||||
|
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
int T1130_persistent_reserve_simple(const char *initiator,
|
int T1130_persistent_reserve_simple(const char *initiator,
|
||||||
const char *url, int data_loss, int show_info)
|
const char *url, int data_loss, int show_info)
|
||||||
@@ -32,22 +41,21 @@ int T1130_persistent_reserve_simple(const char *initiator,
|
|||||||
int ret;
|
int ret;
|
||||||
int lun;
|
int lun;
|
||||||
const unsigned long long key = rand_key();
|
const unsigned long long key = rand_key();
|
||||||
struct resvn_type_info *rtip;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("1130_persistent_reserve_simple:\n");
|
printf("1130_persistent_reserve_simple:\n");
|
||||||
printf("=========================================\n");
|
printf("=========================================\n");
|
||||||
if (show_info) {
|
if (show_info) {
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
|
|
||||||
printf("Test that we can using each type of Persistent Reservation,\n");
|
printf("Test that we can use each type of Persistent Reservation,\n");
|
||||||
printf(" and that we can release each type, as well\n");
|
printf(" and that we can release each type, as well\n");
|
||||||
printf("%d, We can register a key\n", idx++);
|
printf("%d, We can register a key\n", idx++);
|
||||||
for (rtip = reservation_types;
|
for (i = 0; pr_types_to_test[i] != 0; i++) {
|
||||||
rtip->pr_type_str != NULL;
|
|
||||||
rtip++) {
|
|
||||||
printf("%d, Can register %s\n", idx++,
|
printf("%d, Can register %s\n", idx++,
|
||||||
rtip->pr_type_str);
|
scsi_pr_type_str(pr_types_to_test[i]));
|
||||||
printf("%d, Can read reservation\n", idx++);
|
printf("%d, Can read reservation\n", idx++);
|
||||||
printf("%d, Can release reservation\n", idx++);
|
printf("%d, Can release reservation\n", idx++);
|
||||||
}
|
}
|
||||||
@@ -75,23 +83,23 @@ int T1130_persistent_reserve_simple(const char *initiator,
|
|||||||
goto finished;
|
goto finished;
|
||||||
|
|
||||||
/* test each reservatoin type */
|
/* test each reservatoin type */
|
||||||
for (rtip = reservation_types;
|
for (i = 0; pr_types_to_test[i] != 0; i++) {
|
||||||
rtip->pr_type_str != NULL;
|
enum scsi_persistent_out_type pr_type = pr_types_to_test[i];
|
||||||
rtip++) {
|
|
||||||
/* reserve the target */
|
/* reserve the target */
|
||||||
ret = reserve(iscsi, lun, key, rtip);
|
ret = reserve(iscsi, lun, key, pr_type);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto finished;
|
goto finished;
|
||||||
|
|
||||||
/* verify target reservation */
|
/* verify target reservation */
|
||||||
ret = verify_reserved_as(iscsi, lun,
|
ret = verify_reserved_as(iscsi, lun,
|
||||||
pr_type_is_all_registrants(rtip->pr_type) ? 0 : key,
|
pr_type_is_all_registrants(pr_type) ? 0 : key,
|
||||||
rtip);
|
pr_type);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto finished;
|
goto finished;
|
||||||
|
|
||||||
/* release our reservation */
|
/* release our reservation */
|
||||||
ret = release(iscsi, lun, key, rtip);
|
ret = release(iscsi, lun, key, pr_type);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto finished;
|
goto finished;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,22 +263,6 @@ struct scsi_test tests[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct resvn_type_info reservation_types[] = {
|
|
||||||
{"Write Exclusive",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE},
|
|
||||||
{"Exclusive Access",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS},
|
|
||||||
{"Write Exclusive, Registrants Only",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY},
|
|
||||||
{"Exclusive Access, Registrants Only",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY},
|
|
||||||
{"Write Exclusive, All Registrants",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS},
|
|
||||||
{"Exclusive Access, All Registrants",
|
|
||||||
SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS},
|
|
||||||
{NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void print_usage(void)
|
void print_usage(void)
|
||||||
{
|
{
|
||||||
@@ -590,7 +574,7 @@ int reregister_key_fails(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
|
|
||||||
int reserve(struct iscsi_context *iscsi, int lun,
|
int reserve(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip)
|
unsigned long long key, enum scsi_persistent_out_type pr_type)
|
||||||
{
|
{
|
||||||
struct scsi_persistent_reserve_out_basic poc;
|
struct scsi_persistent_reserve_out_basic poc;
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
@@ -598,14 +582,14 @@ int reserve(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
/* reserve the target using specified reservation type */
|
/* reserve the target using specified reservation type */
|
||||||
printf("Send PROUT/RESERVE to reserve, type=%d (%s) ... ",
|
printf("Send PROUT/RESERVE to reserve, type=%d (%s) ... ",
|
||||||
rtip->pr_type, rtip->pr_type_str);
|
pr_type, scsi_pr_type_str(pr_type));
|
||||||
|
|
||||||
memset(&poc, 0, sizeof (poc));
|
memset(&poc, 0, sizeof (poc));
|
||||||
poc.reservation_key = key;
|
poc.reservation_key = key;
|
||||||
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
|
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
|
||||||
SCSI_PERSISTENT_RESERVE_RESERVE,
|
SCSI_PERSISTENT_RESERVE_RESERVE,
|
||||||
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
|
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
|
||||||
rtip->pr_type, &poc);
|
pr_type, &poc);
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
printf("[FAILED]\n");
|
printf("[FAILED]\n");
|
||||||
printf("Failed to send PROUT command: %s\n",
|
printf("Failed to send PROUT command: %s\n",
|
||||||
@@ -628,7 +612,7 @@ int reserve(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
|
|
||||||
int release(struct iscsi_context *iscsi, int lun,
|
int release(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip)
|
unsigned long long key, enum scsi_persistent_out_type pr_type)
|
||||||
{
|
{
|
||||||
struct scsi_persistent_reserve_out_basic poc;
|
struct scsi_persistent_reserve_out_basic poc;
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
@@ -636,14 +620,14 @@ int release(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
/* release the target using specified reservation type */
|
/* release the target using specified reservation type */
|
||||||
printf("Send PROUT/RELEASE to release reservation, type=%d ... ",
|
printf("Send PROUT/RELEASE to release reservation, type=%d ... ",
|
||||||
rtip->pr_type);
|
pr_type);
|
||||||
|
|
||||||
memset(&poc, 0, sizeof (poc));
|
memset(&poc, 0, sizeof (poc));
|
||||||
poc.reservation_key = key;
|
poc.reservation_key = key;
|
||||||
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
|
task = iscsi_persistent_reserve_out_sync(iscsi, lun,
|
||||||
SCSI_PERSISTENT_RESERVE_RELEASE,
|
SCSI_PERSISTENT_RESERVE_RELEASE,
|
||||||
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
|
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
|
||||||
rtip->pr_type, &poc);
|
pr_type, &poc);
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
printf("[FAILED]\n");
|
printf("[FAILED]\n");
|
||||||
printf("Failed to send PROUT command: %s\n",
|
printf("Failed to send PROUT command: %s\n",
|
||||||
@@ -665,7 +649,7 @@ int release(struct iscsi_context *iscsi, int lun,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip)
|
unsigned long long key, enum scsi_persistent_out_type pr_type)
|
||||||
{
|
{
|
||||||
struct scsi_task *task;
|
struct scsi_task *task;
|
||||||
const int buf_sz = 16384;
|
const int buf_sz = 16384;
|
||||||
@@ -673,7 +657,7 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
|
|
||||||
printf("Send PRIN/READ_RESERVATION to verify type=%d ... ",
|
printf("Send PRIN/READ_RESERVATION to verify type=%d ... ",
|
||||||
rtip->pr_type);
|
pr_type);
|
||||||
task = iscsi_persistent_reserve_in_sync(iscsi, lun,
|
task = iscsi_persistent_reserve_in_sync(iscsi, lun,
|
||||||
SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
|
SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
@@ -699,9 +683,6 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
|||||||
|
|
||||||
scsi_free_scsi_task(task);
|
scsi_free_scsi_task(task);
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX check reservation (in rr) ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!rr->reserved) {
|
if (!rr->reserved) {
|
||||||
printf("Failed to find Target reserved as expected.\n");
|
printf("Failed to find Target reserved as expected.\n");
|
||||||
@@ -712,9 +693,9 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
|||||||
key, rr->reservation_key);
|
key, rr->reservation_key);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (rr->pr_type != rtip->pr_type) {
|
if (rr->pr_type != pr_type) {
|
||||||
printf("Failed to find reservation type %d: found %d.\n",
|
printf("Failed to find reservation type %d: found %d.\n",
|
||||||
rtip->pr_type, rr->pr_type);
|
pr_type, rr->pr_type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,13 +231,6 @@ static inline int pr_type_is_all_registrants(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct resvn_type_info {
|
|
||||||
const char *pr_type_str;
|
|
||||||
enum scsi_persistent_out_type pr_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct resvn_type_info reservation_types[];
|
|
||||||
|
|
||||||
int register_and_ignore(struct iscsi_context *iscsi, int lun,
|
int register_and_ignore(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key);
|
unsigned long long key);
|
||||||
int register_key(struct iscsi_context *iscsi, int lun,
|
int register_key(struct iscsi_context *iscsi, int lun,
|
||||||
@@ -247,11 +240,11 @@ int verify_key_presence(struct iscsi_context *iscsi, int lun,
|
|||||||
int reregister_key_fails(struct iscsi_context *iscsi, int lun,
|
int reregister_key_fails(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long sark);
|
unsigned long long sark);
|
||||||
int reserve(struct iscsi_context *iscsi, int lun,
|
int reserve(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip);
|
unsigned long long key, enum scsi_persistent_out_type pr_type);
|
||||||
int release(struct iscsi_context *iscsi, int lun,
|
int release(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip);
|
unsigned long long key, enum scsi_persistent_out_type pr_type);
|
||||||
int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
int verify_reserved_as(struct iscsi_context *iscsi, int lun,
|
||||||
unsigned long long key, struct resvn_type_info *rtip);
|
unsigned long long key, enum scsi_persistent_out_type pr_type);
|
||||||
int testunitready(struct iscsi_context *iscsi, int lun);
|
int testunitready(struct iscsi_context *iscsi, int lun);
|
||||||
int testunitready_nomedium(struct iscsi_context *iscsi, int lun);
|
int testunitready_nomedium(struct iscsi_context *iscsi, int lun);
|
||||||
int testunitready_conflict(struct iscsi_context *iscsi, int lun);
|
int testunitready_conflict(struct iscsi_context *iscsi, int lun);
|
||||||
@@ -270,5 +263,4 @@ int verify12_nomedium(struct iscsi_context *iscsi, int lun, unsigned char *data,
|
|||||||
int verify12_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
int verify12_miscompare(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||||
int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, unsigned char *data, uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _ISCSI_TEST_H_ */
|
#endif /* _ISCSI_TEST_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user