[PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change the lpfc_lun_queue_depth attribute to be writable. When written,
will change the driver's value and calls the new scsi service routine
shost_change_max_queue_depths() to set the maximum and queue depth of
the luns on the shost to the new value.

Signed-off-by: Dick Kennedy <dick.kennedy@xxxxxxxxxxxx>
Signed-off-by: James Smart <jsmart2021@xxxxxxxxx>

---
This patch is dependent upon this series, which adds the new
scsi service routine shost_change_max_queue_depths():
https://www.spinics.net/lists/linux-scsi/msg137981.html
---
 drivers/scsi/lpfc/lpfc.h      |  3 +++
 drivers/scsi/lpfc/lpfc_attr.c | 59 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index cebbad1b3e55..d26ae94e6f1e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -69,6 +69,9 @@ struct lpfc_sli2_slim;
 #define LPFC_TGTQ_RAMPUP_PCENT	5	/* Target queue rampup in percentage */
 #define LPFC_MIN_TGT_QDEPTH	10
 #define LPFC_MAX_TGT_QDEPTH	0xFFFF
+#define LPFC_MIN_LUN_QDEPTH	1
+#define LPFC_DEF_LUN_QDEPTH	30
+#define LPFC_MAX_LUN_QDEPTH	512
 
 #define  LPFC_MAX_BUCKET_COUNT 20	/* Maximum no. of buckets for stat data
 					   collection. */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 48b6c98ec922..127484061f18 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3870,8 +3870,63 @@ LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
 # lun_queue_depth:  This parameter is used to limit the number of outstanding
 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
 */
-LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
-		  "Max number of FCP commands we can queue to a specific LUN");
+static u16 lpfc_lun_queue_depth = LPFC_DEF_LUN_QDEPTH;
+module_param(lpfc_lun_queue_depth, ushort, 0644);
+MODULE_PARM_DESC(lpfc_lun_queue_depth,
+		 "Max number of FCP commands we can queue to a specific LUN");
+lpfc_vport_param_show(lun_queue_depth);
+lpfc_vport_param_init(lun_queue_depth, LPFC_DEF_LUN_QDEPTH, LPFC_MIN_LUN_QDEPTH,
+		      LPFC_MAX_LUN_QDEPTH);
+
+static ssize_t
+lpfc_lun_queue_depth_store(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	struct Scsi_Host  *shost = class_to_shost(dev);
+	struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+	struct lpfc_hba   *phba = vport->phba;
+	u16 new_queue_depth;
+	int rc;
+
+	rc = kstrtou16(buf, 0, &new_queue_depth);
+	if (rc) {
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4385 lpfc_lun_queue_depth: failed to convert "
+				"\"%s\" to u16 (%d)\n",
+				buf, rc);
+		return -EINVAL;
+	}
+
+	/* Check allowed range */
+	if (new_queue_depth < LPFC_MIN_LUN_QDEPTH ||
+	    new_queue_depth > LPFC_MAX_LUN_QDEPTH) {
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4386 lpfc_lun_queue_depth: %d outside of "
+				"allowed range [%u, %u]\n",
+				new_queue_depth, LPFC_MIN_LUN_QDEPTH,
+				LPFC_MAX_LUN_QDEPTH);
+		return -EINVAL;
+	}
+
+	/* Check if previously set same value */
+	if (new_queue_depth == vport->cfg_lun_queue_depth)
+		goto buffer_done;
+
+	/* Store for future calls to slave_configure */
+	vport->cfg_lun_queue_depth = new_queue_depth;
+
+	/* Change all the current LUNs' queue depths */
+	rc = shost_change_max_queue_depths(shost, new_queue_depth);
+	if (rc)
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4387 lpfc_lun_queue_depth: error setting lun "
+				"max queue depths (%d)\n",
+				rc);
+
+buffer_done:
+	return strlen(buf);
+}
+static DEVICE_ATTR_RW(lpfc_lun_queue_depth);
 
 /*
 # tgt_queue_depth:  This parameter is used to limit the number of outstanding
-- 
2.13.7




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux