diff options
author | Christoph Hellwig <hch@lst.de> | 2018-05-25 17:16:09 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-06-01 14:37:35 +0200 |
commit | c16734ea98f5549fed9a1af47e943a45855274e0 (patch) | |
tree | 5921c34c91f029ad23ec1df30c4444f4d8ce5002 /drivers/nvme/target/admin-cmd.c | |
parent | nvmet: split log page implementation (diff) | |
download | linux-c16734ea98f5549fed9a1af47e943a45855274e0.tar.xz linux-c16734ea98f5549fed9a1af47e943a45855274e0.zip |
nvmet: implement the changed namespaces log
Just keep a per-controller buffer of changed namespaces and copy it out
in the get log page implementation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Diffstat (limited to 'drivers/nvme/target/admin-cmd.c')
-rw-r--r-- | drivers/nvme/target/admin-cmd.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index e96bb02c4f2c..52129d13770e 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -126,6 +126,29 @@ out: nvmet_req_complete(req, status); } +static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req) +{ + struct nvmet_ctrl *ctrl = req->sq->ctrl; + u16 status = NVME_SC_INTERNAL; + size_t len; + + if (req->data_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32)) + goto out; + + mutex_lock(&ctrl->lock); + if (ctrl->nr_changed_ns == U32_MAX) + len = sizeof(__le32); + else + len = ctrl->nr_changed_ns * sizeof(__le32); + status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len); + if (!status) + status = nvmet_zero_sgl(req, len, req->data_len - len); + ctrl->nr_changed_ns = 0; + mutex_unlock(&ctrl->lock); +out: + nvmet_req_complete(req, status); +} + static void nvmet_execute_identify_ctrl(struct nvmet_req *req) { struct nvmet_ctrl *ctrl = req->sq->ctrl; @@ -543,6 +566,9 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req) */ req->execute = nvmet_execute_get_log_page_noop; return 0; + case NVME_LOG_CHANGED_NS: + req->execute = nvmet_execute_get_log_changed_ns; + return 0; } break; case nvme_admin_identify: |