Skip to content

Commit

Permalink
nvmet: don't override treq upon modification.
Browse files Browse the repository at this point in the history
Only override the allowed parts of it.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
[hch: slight tweak to the NVME_TREQ_SECURE_CHANNEL_MASK definition]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Sagi Grimberg authored and Jens Axboe committed Dec 8, 2018
1 parent e6a622f commit 0445e1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/nvme/target/configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ CONFIGFS_ATTR(nvmet_, addr_traddr);
static ssize_t nvmet_addr_treq_show(struct config_item *item,
char *page)
{
switch (to_nvmet_port(item)->disc_addr.treq) {
switch (to_nvmet_port(item)->disc_addr.treq &
NVME_TREQ_SECURE_CHANNEL_MASK) {
case NVMF_TREQ_NOT_SPECIFIED:
return sprintf(page, "not specified\n");
case NVMF_TREQ_REQUIRED:
Expand All @@ -169,6 +170,7 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item,
const char *page, size_t count)
{
struct nvmet_port *port = to_nvmet_port(item);
u8 treq = port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK;

if (port->enabled) {
pr_err("Cannot modify address while enabled\n");
Expand All @@ -177,15 +179,16 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item,
}

if (sysfs_streq(page, "not specified")) {
port->disc_addr.treq = NVMF_TREQ_NOT_SPECIFIED;
treq |= NVMF_TREQ_NOT_SPECIFIED;
} else if (sysfs_streq(page, "required")) {
port->disc_addr.treq = NVMF_TREQ_REQUIRED;
treq |= NVMF_TREQ_REQUIRED;
} else if (sysfs_streq(page, "not required")) {
port->disc_addr.treq = NVMF_TREQ_NOT_REQUIRED;
treq |= NVMF_TREQ_NOT_REQUIRED;
} else {
pr_err("Invalid value '%s' for treq\n", page);
return -EINVAL;
}
port->disc_addr.treq = treq;

return count;
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ enum {
NVMF_TREQ_NOT_SPECIFIED = 0, /* Not specified */
NVMF_TREQ_REQUIRED = 1, /* Required */
NVMF_TREQ_NOT_REQUIRED = 2, /* Not Required */
#define NVME_TREQ_SECURE_CHANNEL_MASK \
(NVMF_TREQ_REQUIRED | NVMF_TREQ_NOT_REQUIRED)
};

/* RDMA QP Service Type codes for Discovery Log Page entry TSAS
Expand Down

0 comments on commit 0445e1b

Please sign in to comment.