Skip to content

Commit 55fdd6b

Browse files
author
Christoph Hellwig
committed
nvmet: mask pending AENs
Per section 5.2 of the NVMe 1.3 spec: "When the controller posts a completion queue entry for an outstanding Asynchronous Event Request command and thus reports an asynchronous event, subsequent events of that event type are automatically masked by the controller until the host clears that event. An event is cleared by reading the log page associated with that event using the Get Log Page command (see section 5.14)." Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]>
1 parent c86b8f7 commit 55fdd6b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
144144
if (!status)
145145
status = nvmet_zero_sgl(req, len, req->data_len - len);
146146
ctrl->nr_changed_ns = 0;
147+
clear_bit(NVME_AEN_CFG_NS_ATTR, &ctrl->aen_masked);
147148
mutex_unlock(&ctrl->lock);
148149
out:
149150
nvmet_req_complete(req, status);

drivers/nvme/target/core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ static void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
144144
schedule_work(&ctrl->async_event_work);
145145
}
146146

147+
static bool nvmet_aen_disabled(struct nvmet_ctrl *ctrl, u32 aen)
148+
{
149+
if (!(READ_ONCE(ctrl->aen_enabled) & aen))
150+
return true;
151+
return test_and_set_bit(aen, &ctrl->aen_masked);
152+
}
153+
147154
static void nvmet_add_to_changed_ns_log(struct nvmet_ctrl *ctrl, __le32 nsid)
148155
{
149156
u32 i;
@@ -174,7 +181,7 @@ static void nvmet_ns_changed(struct nvmet_subsys *subsys, u32 nsid)
174181

175182
list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
176183
nvmet_add_to_changed_ns_log(ctrl, cpu_to_le32(nsid));
177-
if (!(READ_ONCE(ctrl->aen_enabled) & NVME_AEN_CFG_NS_ATTR))
184+
if (nvmet_aen_disabled(ctrl, NVME_AEN_CFG_NS_ATTR))
178185
continue;
179186
nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE,
180187
NVME_AER_NOTICE_NS_CHANGED,

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct nvmet_ctrl {
139139
u32 kato;
140140

141141
u32 aen_enabled;
142+
unsigned long aen_masked;
142143
struct nvmet_req *async_event_cmds[NVMET_ASYNC_EVENTS];
143144
unsigned int nr_async_event_cmds;
144145
struct list_head async_events;

0 commit comments

Comments
 (0)