From: zhenwei pi <pizhenwei@bytedance.com>
To: hch@lst.de, sagi@grimberg.me, chaitanya.kulkarni@wdc.com
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
pizhenwei@bytedance.com, kernel test robot <lkp@intel.com>
Subject: [PATCH v2] nvmet: fix mismatched serial
Date: Sat, 12 Dec 2020 15:58:01 +0800 [thread overview]
Message-ID: <20201212075801.1393924-1-pizhenwei@bytedance.com> (raw)
Target side uses 'bin2hex' to convert u64 serial number to a hex
string, saving serial number as be64 to keep the right byte order.
Also use format '%016llx' to show the full serial string to avoid
to drop prefixed zero.
Test on x86 server, config '0123456789abcdef' to 'attr_serial' on
target side, and run 'nvme id-ctrl /dev/nvme0' on initiator side,
then we can get the same SN string.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reported-by: kernel test robot <lkp@intel.com>
---
drivers/nvme/target/configfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 37e1d7784e17..6404b9ce09eb 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -996,8 +996,9 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
char *page)
{
struct nvmet_subsys *subsys = to_subsys(item);
+ u64 serial = be64_to_cpu((__force __be64)subsys->serial);
- return snprintf(page, PAGE_SIZE, "%llx\n", subsys->serial);
+ return snprintf(page, PAGE_SIZE, "%016llx\n", serial);
}
static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
@@ -1009,7 +1010,7 @@ static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
return -EINVAL;
down_write(&nvmet_config_sem);
- to_subsys(item)->serial = serial;
+ to_subsys(item)->serial = (__force u64)cpu_to_be64(serial);
up_write(&nvmet_config_sem);
return count;
--
2.25.1
next reply other threads:[~2020-12-12 9:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-12 7:58 zhenwei pi [this message]
2020-12-22 13:50 ` [PATCH v2] nvmet: fix mismatched serial Christoph Hellwig
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=20201212075801.1393924-1-pizhenwei@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=lkp@intel.com \
--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).