Commit 0123a9ec6a4fea20d5afea90c9b47fb73fb1bc34

Authored by Nicholas Bellinger
Committed by Nicholas Bellinger
1 parent 76dde50ebe

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>

Showing 5 changed files with 27 additions and 0 deletions Side-by-side Diff

drivers/target/target_core_configfs.c
... ... @@ -636,6 +636,9 @@
636 636 DEF_DEV_ATTRIB(emulate_tpws);
637 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 642 DEF_DEV_ATTRIB(enforce_pr_isids);
640 643 SE_DEV_ATTR(enforce_pr_isids, S_IRUGO | S_IWUSR);
641 644  
... ... @@ -693,6 +696,7 @@
693 696 &target_core_dev_attrib_emulate_tas.attr,
694 697 &target_core_dev_attrib_emulate_tpu.attr,
695 698 &target_core_dev_attrib_emulate_tpws.attr,
  699 + &target_core_dev_attrib_emulate_caw.attr,
696 700 &target_core_dev_attrib_enforce_pr_isids.attr,
697 701 &target_core_dev_attrib_is_nonrot.attr,
698 702 &target_core_dev_attrib_emulate_rest_reord.attr,
drivers/target/target_core_device.c
... ... @@ -890,6 +890,19 @@
890 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 906 int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag)
894 907 {
895 908 if ((flag != 0) && (flag != 1)) {
... ... @@ -1423,6 +1436,7 @@
1423 1436 dev->dev_attrib.emulate_tas = DA_EMULATE_TAS;
1424 1437 dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU;
1425 1438 dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS;
  1439 + dev->dev_attrib.emulate_caw = DA_EMULATE_CAW;
1426 1440 dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS;
1427 1441 dev->dev_attrib.is_nonrot = DA_IS_NONROT;
1428 1442 dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD;
drivers/target/target_core_internal.h
... ... @@ -33,6 +33,7 @@
33 33 int se_dev_set_emulate_tas(struct se_device *, int);
34 34 int se_dev_set_emulate_tpu(struct se_device *, int);
35 35 int se_dev_set_emulate_tpws(struct se_device *, int);
  36 +int se_dev_set_emulate_caw(struct se_device *, int);
36 37 int se_dev_set_enforce_pr_isids(struct se_device *, int);
37 38 int se_dev_set_is_nonrot(struct se_device *, int);
38 39 int se_dev_set_emulate_rest_reord(struct se_device *dev, int);
drivers/target/target_core_spc.c
... ... @@ -457,6 +457,11 @@
457 457  
458 458 /* Set WSNZ to 1 */
459 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 467 * Set OPTIMAL TRANSFER LENGTH GRANULARITY
include/target/target_core_base.h
... ... @@ -97,6 +97,8 @@
97 97 * block/blk-lib.c:blkdev_issue_discard()
98 98 */
99 99 #define DA_EMULATE_TPWS 0
  100 +/* Emulation for CompareAndWrite (AtomicTestandSet) by default */
  101 +#define DA_EMULATE_CAW 1
100 102 /* No Emulation for PSCSI by default */
101 103 #define DA_EMULATE_ALUA 0
102 104 /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
... ... @@ -602,6 +604,7 @@
602 604 int emulate_tas;
603 605 int emulate_tpu;
604 606 int emulate_tpws;
  607 + int emulate_caw;
605 608 int enforce_pr_isids;
606 609 int is_nonrot;
607 610 int emulate_rest_reord;