All of lore.kernel.org
 help / color / mirror / Atom feed
From: hare@suse.de (Hannes Reinecke)
Subject: [PATCH 1/2] nvmet: make MDTS value configurable
Date: Fri, 29 Mar 2019 13:04:03 +0100	[thread overview]
Message-ID: <20190329120404.55637-2-hare@suse.de> (raw)
In-Reply-To: <20190329120404.55637-1-hare@suse.de>

For testing the bio splitting algorithm it's useful to be able to
modify the mdts value.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/target/admin-cmd.c |  3 +--
 drivers/nvme/target/configfs.c  | 27 +++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h     |  2 ++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 76250181fee0..1c4cb371fac8 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -311,8 +311,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	/* we support multiple ports, multiples hosts and ANA: */
 	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
 
-	/* no limit on data transfer sizes for now */
-	id->mdts = 0;
+	id->mdts = ctrl->subsys->mdts;
 	id->cntlid = cpu_to_le16(ctrl->cntlid);
 	id->ver = cpu_to_le32(ctrl->subsys->ver);
 
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index adb79545cdd7..63b9991de79e 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -859,10 +859,37 @@ static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
 }
 CONFIGFS_ATTR(nvmet_subsys_, attr_serial);
 
+static ssize_t nvmet_subsys_attr_mdts_show(struct config_item *item,
+					   char *page)
+{
+	struct nvmet_subsys *subsys = to_subsys(item);
+
+	return snprintf(page, PAGE_SIZE, "%u\n", subsys->mdts);
+}
+
+static ssize_t nvmet_subsys_attr_mdts_store(struct config_item *item,
+					    const char *page, size_t count)
+{
+	struct nvmet_subsys *subsys = to_subsys(item);
+	unsigned int mdts;
+	int ret;
+
+	ret = kstrtou32(page, 0, &mdts);
+	if (ret)
+		return ret;
+	down_write(&nvmet_config_sem);
+	subsys->mdts = mdts;
+	up_write(&nvmet_config_sem);
+
+	return count;
+}
+CONFIGFS_ATTR(nvmet_subsys_, attr_mdts);
+
 static struct configfs_attribute *nvmet_subsys_attrs[] = {
 	&nvmet_subsys_attr_attr_allow_any_host,
 	&nvmet_subsys_attr_attr_version,
 	&nvmet_subsys_attr_attr_serial,
+	&nvmet_subsys_attr_attr_mdts,
 	NULL,
 };
 
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 51e49efd7849..f05f069f83ea 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -217,6 +217,8 @@ struct nvmet_subsys {
 	bool			allow_any_host;
 
 	u16			max_qid;
+	u8			mdts;
+	u8			mpsmin;
 
 	u64			ver;
 	u64			serial;
-- 
2.16.4

  reply	other threads:[~2019-03-29 12:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 12:04 [PATCH 0/2] nvmet: add some more configfs attributes Hannes Reinecke
2019-03-29 12:04 ` Hannes Reinecke [this message]
2019-03-29 17:27   ` [PATCH 1/2] nvmet: make MDTS value configurable Heitke, Kenneth
2019-03-31 15:04   ` Max Gurtovoy
2019-04-01  2:02     ` Hannes Reinecke
2019-04-01  3:10       ` Keith Busch
2019-04-01 11:48         ` Hannes Reinecke
2019-04-02 12:06           ` Max Gurtovoy
2019-04-02 23:31             ` Keith Busch
2019-04-03 14:53         ` Christoph Hellwig
2019-03-29 12:04 ` [PATCH 2/2] nvmet: make CNTLID range configurable Hannes Reinecke
2019-04-03 18:11   ` Christoph Hellwig
2019-04-03 22:13     ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190329120404.55637-2-hare@suse.de \
    --to=hare@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.