linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me,
	damien.lemoal@wdc.com,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH V10 8/8] nvme: add comments to nvme_zns_alloc_report_buffer
Date: Mon,  8 Mar 2021 20:58:23 -0800	[thread overview]
Message-ID: <20210309045823.18545-9-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210309045823.18545-1-chaitanya.kulkarni@wdc.com>

The report zone buffer calculation is dependent nvme report zones
header, nvme report zone descriptor and on the various block
layer request queue attributes such as queue_max_hw_sectors(),
queue_max_segments(). These queue_XXX attributes are calculated on
different ctrl values in the nvme-core.

Add clear comments about what values we are using and how they are
calculated based on the controller's attributes.

This is needed since when referencing the code after long time it is not
straight forward to understand how we calculate the buffer size given
that there are variables and ctrl attributes involved.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/zns.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index c7e3ec561ba0..03778e0e368b 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -120,16 +120,38 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns,
 	size_t bufsize;
 	void *buf;
 
+	/*
+	 * Set the minimum buffer size for report zone header and one zone
+	 * descriptor.
+	 */
 	const size_t min_bufsize = sizeof(struct nvme_zone_report) +
 				   sizeof(struct nvme_zone_descriptor);
 
+	/*
+	 * Recalculate the number of zones based on disk size of zone size.
+	 */
 	nr_zones = min_t(unsigned int, nr_zones,
 			 get_capacity(ns->disk) >> ilog2(ns->zsze));
 
+	/*
+	 * Calculate the buffer size based on the report zone header and number
+	 * of zone descriptors are required for each zone.
+	 */
 	bufsize = sizeof(struct nvme_zone_report) +
 		nr_zones * sizeof(struct nvme_zone_descriptor);
+
+	/*
+	 * Recalculate and Limit the buffer size to queue max hw sectors. For
+	 * NVMe queue max hw sectors are calcualted based on controller's
+	 * Maximum Data Transfer Size (MDTS).
+	 */
 	bufsize = min_t(size_t, bufsize,
 			queue_max_hw_sectors(q) << SECTOR_SHIFT);
+	/*
+	 * Recalculate and Limit the buffer size to queue max segments. For
+	 * NVMe queue max segments are calculated based on how many controller
+	 * pages are needed to fit the max hw sectors.
+	 */
 	bufsize = min_t(size_t, bufsize, queue_max_segments(q) << PAGE_SHIFT);
 
 	while (bufsize >= min_bufsize) {
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

      parent reply	other threads:[~2021-03-09  5:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09  4:58 [PATCH V10 0/8] nvmet: add ZBD backend support Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 1/8] nvmet: trim args for nvmet_copy_ns_identifier() Chaitanya Kulkarni
2021-03-09 11:34   ` Christoph Hellwig
2021-03-09 20:54     ` Chaitanya Kulkarni
2021-03-09 21:03     ` Chaitanya Kulkarni
2021-03-10  8:49       ` Christoph Hellwig
2021-03-10  8:52         ` Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 2/8] nvmet: add NVM Command Set Identifier support Chaitanya Kulkarni
2021-03-09 11:37   ` Christoph Hellwig
2021-03-09 21:07     ` Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 3/8] nvmet: add command set supported ctrl cap Chaitanya Kulkarni
2021-03-09 11:38   ` Christoph Hellwig
2021-03-09 21:09     ` Chaitanya Kulkarni
2021-03-10  7:05   ` Chaitanya Kulkarni
2021-03-10  7:14     ` hch
2021-03-09  4:58 ` [PATCH V10 4/8] nvmet: add ZBD over ZNS backend support Chaitanya Kulkarni
2021-03-09 11:41   ` Christoph Hellwig
2021-03-09 21:13     ` Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 5/8] nvmet: add nvmet_req_bio put helper for backends Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 6/8] nvme-core: check ctrl css before setting up zns Chaitanya Kulkarni
2021-03-09 11:42   ` Christoph Hellwig
2021-03-09 15:03     ` Christoph Hellwig
2021-03-10  1:14       ` Chaitanya Kulkarni
2021-03-09  4:58 ` [PATCH V10 7/8] nvme-core: add a helper to print css related error Chaitanya Kulkarni
2021-03-09  4:58 ` Chaitanya Kulkarni [this message]

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=20210309045823.18545-9-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=damien.lemoal@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).