linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Dan Williams <dan.j.williams@intel.com>, linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 2/2] ndctl: add sector_size to 'ndctl list' output
Date: Thu, 25 Jan 2018 16:26:38 -0700	[thread overview]
Message-ID: <20180125232638.6585-2-ross.zwisler@linux.intel.com> (raw)
In-Reply-To: <20180125232638.6585-1-ross.zwisler@linux.intel.com>

It used to be that the only PMEM namespaces with a variable sector size
were ones with a BTT, but that has changed.  sector_size still doesn't make
sense for device DAX since we don't have a block I/O path, and we also skip
it if we don't have a specified sector size, as happens with namespaces of
devtype nd_namespace_io.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
 util/json.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/util/json.c b/util/json.c
index 95beaa2..89306f0 100644
--- a/util/json.c
+++ b/util/json.c
@@ -718,11 +718,6 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 			goto err;
 		json_object_object_add(jndns, "uuid", jobj);
 
-		jobj = json_object_new_int(ndctl_btt_get_sector_size(btt));
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "sector_size", jobj);
-
 		bdev = ndctl_btt_get_block_device(btt);
 	} else if (pfn) {
 		ndctl_pfn_get_uuid(pfn, uuid);
@@ -774,6 +769,23 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 	} else
 		bdev = ndctl_namespace_get_block_device(ndns);
 
+	jobj = NULL;
+	if (btt) {
+		jobj = json_object_new_int(ndctl_btt_get_sector_size(btt));
+		if (!jobj)
+			goto err;
+	} else if (!dax) {
+		unsigned int sector_size = ndctl_namespace_get_sector_size(ndns);
+
+		if (sector_size) {
+			jobj = json_object_new_int(sector_size);
+			if (!jobj)
+				goto err;
+		}
+	}
+	if (jobj)
+		json_object_object_add(jndns, "sector_size", jobj);
+
 	if (bdev && bdev[0]) {
 		jobj = json_object_new_string(bdev);
 		if (!jobj)
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-01-25 23:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 23:26 [ndctl PATCH 1/2] ndctl: update .gitignore Ross Zwisler
2018-01-25 23:26 ` Ross Zwisler [this message]
2018-01-25 23:39   ` [ndctl PATCH 2/2] ndctl: add sector_size to 'ndctl list' output Dave Jiang
2018-01-26 20:54   ` [ndctl PATCH v2 " Ross Zwisler
2018-01-26 20:56     ` Dave Jiang
2018-01-26 21:00     ` Dan Williams
2018-01-29 21:48       ` [ndctl PATCH v3 " Ross Zwisler
2018-01-29 22:09         ` Dan Williams
2018-01-25 23:51 ` [ndctl PATCH 1/2] ndctl: update .gitignore Dan Williams

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=20180125232638.6585-2-ross.zwisler@linux.intel.com \
    --to=ross.zwisler@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /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).