]> git.neil.brown.name Git - linux.git/blobdiff - drivers/nvme/target/core.c
nvmet: mask pending AENs
[linux.git] / drivers / nvme / target / core.c
index 5a086b670f4206ccdde91e5979bb2ba707993a3c..a03da764ecae8cb3ec9bf0bb9c68971669b895fc 100644 (file)
@@ -144,6 +144,13 @@ static void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
        schedule_work(&ctrl->async_event_work);
 }
 
+static bool nvmet_aen_disabled(struct nvmet_ctrl *ctrl, u32 aen)
+{
+       if (!(READ_ONCE(ctrl->aen_enabled) & aen))
+               return true;
+       return test_and_set_bit(aen, &ctrl->aen_masked);
+}
+
 static void nvmet_add_to_changed_ns_log(struct nvmet_ctrl *ctrl, __le32 nsid)
 {
        u32 i;
@@ -174,7 +181,7 @@ static void nvmet_ns_changed(struct nvmet_subsys *subsys, u32 nsid)
 
        list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
                nvmet_add_to_changed_ns_log(ctrl, cpu_to_le32(nsid));
-               if (!(READ_ONCE(ctrl->aen_enabled) & NVME_AEN_CFG_NS_ATTR))
+               if (nvmet_aen_disabled(ctrl, NVME_AEN_CFG_NS_ATTR))
                        continue;
                nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE,
                                NVME_AER_NOTICE_NS_CHANGED,