nvmet: Don't queue fatal error work if csts.cfs is set
authorSagi Grimberg <sagi@grimberg.me>
Sun, 6 Nov 2016 09:03:30 +0000 (11:03 +0200)
committerSagi Grimberg <sagi@grimberg.me>
Mon, 14 Nov 2016 00:08:51 +0000 (02:08 +0200)
In the transport, in case of an interal queue error like
error completion in rdma we trigger a fatal error. However,
multiple queues in the same controller can serr error completions
and we don't want to trigger fatal error work more than once.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/target/core.c

index b4cacb6f02583740933ac63c42af32a7377f6687..a21437a33adbef0c51395c0b88f2e8a10995ea86 100644 (file)
@@ -838,9 +838,13 @@ static void nvmet_fatal_error_handler(struct work_struct *work)
 
 void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl)
 {
-       ctrl->csts |= NVME_CSTS_CFS;
-       INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
-       schedule_work(&ctrl->fatal_err_work);
+       mutex_lock(&ctrl->lock);
+       if (!(ctrl->csts & NVME_CSTS_CFS)) {
+               ctrl->csts |= NVME_CSTS_CFS;
+               INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
+               schedule_work(&ctrl->fatal_err_work);
+       }
+       mutex_unlock(&ctrl->lock);
 }
 EXPORT_SYMBOL_GPL(nvmet_ctrl_fatal_error);