diff options
author | Nicholas Bellinger <nab@daterainc.com> | 2013-08-20 17:24:09 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-09-09 17:29:35 -0400 |
commit | 0123a9ec6a4fea20d5afea90c9b47fb73fb1bc34 (patch) | |
tree | 6ac9f2539a9db0013757f51b18a97f3bf8ded49a | |
parent | 76dde50ebef75773ea2b68e0bf914e87e6a3711c (diff) |
target: Add MAXIMUM COMPARE AND WRITE LENGTH in Block Limits VPD
This patch adds the MAXIMUM COMPARE AND WRITE LENGTH bit, currently
hardcoded to a single logical block (NoLB=1) within the Block Limits
VPD in spc_emulate_evpd_b0().
Also add emulate_caw device attribute in configfs (enabled by default)
to allow the exposure of this bit to be disabled, if necessary.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Martin Petersen <martin.petersen@oracle.com>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: James Bottomley <JBottomley@Parallels.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
-rw-r--r-- | drivers/target/target_core_configfs.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_device.c | 14 | ||||
-rw-r--r-- | drivers/target/target_core_internal.h | 1 | ||||
-rw-r--r-- | drivers/target/target_core_spc.c | 5 | ||||
-rw-r--r-- | include/target/target_core_base.h | 3 |
5 files changed, 27 insertions, 0 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index f67a9afdeb21..24517d4aa1de 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -636,6 +636,9 @@ SE_DEV_ATTR(emulate_tpu, S_IRUGO | S_IWUSR); | |||
636 | DEF_DEV_ATTRIB(emulate_tpws); | 636 | DEF_DEV_ATTRIB(emulate_tpws); |
637 | SE_DEV_ATTR(emulate_tpws, S_IRUGO | S_IWUSR); | 637 | SE_DEV_ATTR(emulate_tpws, S_IRUGO | S_IWUSR); |
638 | 638 | ||
639 | DEF_DEV_ATTRIB(emulate_caw); | ||
640 | SE_DEV_ATTR(emulate_caw, S_IRUGO | S_IWUSR); | ||
641 | |||
639 | DEF_DEV_ATTRIB(enforce_pr_isids); | 642 | DEF_DEV_ATTRIB(enforce_pr_isids); |
640 | SE_DEV_ATTR(enforce_pr_isids, S_IRUGO | S_IWUSR); | 643 | SE_DEV_ATTR(enforce_pr_isids, S_IRUGO | S_IWUSR); |
641 | 644 | ||
@@ -693,6 +696,7 @@ static struct configfs_attribute *target_core_dev_attrib_attrs[] = { | |||
693 | &target_core_dev_attrib_emulate_tas.attr, | 696 | &target_core_dev_attrib_emulate_tas.attr, |
694 | &target_core_dev_attrib_emulate_tpu.attr, | 697 | &target_core_dev_attrib_emulate_tpu.attr, |
695 | &target_core_dev_attrib_emulate_tpws.attr, | 698 | &target_core_dev_attrib_emulate_tpws.attr, |
699 | &target_core_dev_attrib_emulate_caw.attr, | ||
696 | &target_core_dev_attrib_enforce_pr_isids.attr, | 700 | &target_core_dev_attrib_enforce_pr_isids.attr, |
697 | &target_core_dev_attrib_is_nonrot.attr, | 701 | &target_core_dev_attrib_is_nonrot.attr, |
698 | &target_core_dev_attrib_emulate_rest_reord.attr, | 702 | &target_core_dev_attrib_emulate_rest_reord.attr, |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 8f4142fe5f19..0b5f86806f1d 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -890,6 +890,19 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag) | |||
890 | return 0; | 890 | return 0; |
891 | } | 891 | } |
892 | 892 | ||
893 | int se_dev_set_emulate_caw(struct se_device *dev, int flag) | ||
894 | { | ||
895 | if (flag != 0 && flag != 1) { | ||
896 | pr_err("Illegal value %d\n", flag); | ||
897 | return -EINVAL; | ||
898 | } | ||
899 | dev->dev_attrib.emulate_caw = flag; | ||
900 | pr_debug("dev[%p]: SE Device CompareAndWrite (AtomicTestandSet): %d\n", | ||
901 | dev, flag); | ||
902 | |||
903 | return 0; | ||
904 | } | ||
905 | |||
893 | int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag) | 906 | int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag) |
894 | { | 907 | { |
895 | if ((flag != 0) && (flag != 1)) { | 908 | if ((flag != 0) && (flag != 1)) { |
@@ -1423,6 +1436,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) | |||
1423 | dev->dev_attrib.emulate_tas = DA_EMULATE_TAS; | 1436 | dev->dev_attrib.emulate_tas = DA_EMULATE_TAS; |
1424 | dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU; | 1437 | dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU; |
1425 | dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS; | 1438 | dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS; |
1439 | dev->dev_attrib.emulate_caw = DA_EMULATE_CAW; | ||
1426 | dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; | 1440 | dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; |
1427 | dev->dev_attrib.is_nonrot = DA_IS_NONROT; | 1441 | dev->dev_attrib.is_nonrot = DA_IS_NONROT; |
1428 | dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD; | 1442 | dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD; |
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 18d49df4d0ac..805ceb4285b8 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h | |||
@@ -33,6 +33,7 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int); | |||
33 | int se_dev_set_emulate_tas(struct se_device *, int); | 33 | int se_dev_set_emulate_tas(struct se_device *, int); |
34 | int se_dev_set_emulate_tpu(struct se_device *, int); | 34 | int se_dev_set_emulate_tpu(struct se_device *, int); |
35 | int se_dev_set_emulate_tpws(struct se_device *, int); | 35 | int se_dev_set_emulate_tpws(struct se_device *, int); |
36 | int se_dev_set_emulate_caw(struct se_device *, int); | ||
36 | int se_dev_set_enforce_pr_isids(struct se_device *, int); | 37 | int se_dev_set_enforce_pr_isids(struct se_device *, int); |
37 | int se_dev_set_is_nonrot(struct se_device *, int); | 38 | int se_dev_set_is_nonrot(struct se_device *, int); |
38 | int se_dev_set_emulate_rest_reord(struct se_device *dev, int); | 39 | int se_dev_set_emulate_rest_reord(struct se_device *dev, int); |
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 4cb667d720a7..ed7077a67d7b 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -457,6 +457,11 @@ spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) | |||
457 | 457 | ||
458 | /* Set WSNZ to 1 */ | 458 | /* Set WSNZ to 1 */ |
459 | buf[4] = 0x01; | 459 | buf[4] = 0x01; |
460 | /* | ||
461 | * Set MAXIMUM COMPARE AND WRITE LENGTH | ||
462 | */ | ||
463 | if (dev->dev_attrib.emulate_caw) | ||
464 | buf[5] = 0x01; | ||
460 | 465 | ||
461 | /* | 466 | /* |
462 | * Set OPTIMAL TRANSFER LENGTH GRANULARITY | 467 | * Set OPTIMAL TRANSFER LENGTH GRANULARITY |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 7fdb3fae2961..61a4dc890701 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -97,6 +97,8 @@ | |||
97 | * block/blk-lib.c:blkdev_issue_discard() | 97 | * block/blk-lib.c:blkdev_issue_discard() |
98 | */ | 98 | */ |
99 | #define DA_EMULATE_TPWS 0 | 99 | #define DA_EMULATE_TPWS 0 |
100 | /* Emulation for CompareAndWrite (AtomicTestandSet) by default */ | ||
101 | #define DA_EMULATE_CAW 1 | ||
100 | /* No Emulation for PSCSI by default */ | 102 | /* No Emulation for PSCSI by default */ |
101 | #define DA_EMULATE_ALUA 0 | 103 | #define DA_EMULATE_ALUA 0 |
102 | /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ | 104 | /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ |
@@ -602,6 +604,7 @@ struct se_dev_attrib { | |||
602 | int emulate_tas; | 604 | int emulate_tas; |
603 | int emulate_tpu; | 605 | int emulate_tpu; |
604 | int emulate_tpws; | 606 | int emulate_tpws; |
607 | int emulate_caw; | ||
605 | int enforce_pr_isids; | 608 | int enforce_pr_isids; |
606 | int is_nonrot; | 609 | int is_nonrot; |
607 | int emulate_rest_reord; | 610 | int emulate_rest_reord; |