Skip to content
Permalink
Browse files
nvmet: fix mismatched serial
Target side uses 'bin2hex' to convert u64 serial number to a hex
string, saving serial number as be64 to keep right byte order.

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>
  • Loading branch information
pizhenwei authored and intel-lab-lkp committed Dec 11, 2020
1 parent 65cdb4a commit 57f71eb4dff3b1b3ecef2f0368f710025c5d47f2
Showing 1 changed file with 2 additions and 2 deletions.
@@ -997,7 +997,7 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
{
struct nvmet_subsys *subsys = to_subsys(item);

return snprintf(page, PAGE_SIZE, "%llx\n", subsys->serial);
return snprintf(page, PAGE_SIZE, "%llx\n", be64_to_cpu(subsys->serial));
}

static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
@@ -1009,7 +1009,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 = cpu_to_be64(serial);
up_write(&nvmet_config_sem);

return count;

0 comments on commit 57f71eb

Please sign in to comment.