diff options
author | Christoph Hellwig <hch@lst.de> | 2015-11-20 09:36:44 +0100 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-12-22 17:38:33 +0100 |
commit | 6bf25d16410d8d95e3552f31c6a99e3fc3d31752 (patch) | |
tree | 32299f8b98b400025295b54c41c99961539efcb2 /drivers/nvme/host/pci.c | |
parent | nvme: remove dead controllers from a work item (diff) | |
download | linux-6bf25d16410d8d95e3552f31c6a99e3fc3d31752.tar.xz linux-6bf25d16410d8d95e3552f31c6a99e3fc3d31752.zip |
nvme: switch abort_limit to an atomic_t
There is no lock to sychronize access to the abort_limit field of
struct nvme_ctrl, so switch it to an atomic_t.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/nvme/host/pci.c')
-rw-r--r-- | drivers/nvme/host/pci.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 26e982359a74..1ad7f18d48e2 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -388,7 +388,7 @@ static void abort_completion(struct nvme_queue *nvmeq, void *ctx, blk_mq_free_request(req); dev_warn(nvmeq->q_dmadev, "Abort status:%x result:%x", status, result); - ++nvmeq->dev->ctrl.abort_limit; + atomic_inc(&nvmeq->dev->ctrl.abort_limit); } static void async_completion(struct nvme_queue *nvmeq, void *ctx, @@ -1124,13 +1124,15 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) return BLK_EH_HANDLED; } - if (!dev->ctrl.abort_limit) + if (atomic_dec_and_test(&dev->ctrl.abort_limit)) return BLK_EH_RESET_TIMER; abort_req = blk_mq_alloc_request(dev->ctrl.admin_q, WRITE, BLK_MQ_REQ_NOWAIT); - if (IS_ERR(abort_req)) + if (IS_ERR(abort_req)) { + atomic_inc(&dev->ctrl.abort_limit); return BLK_EH_RESET_TIMER; + } abort_cmd = blk_mq_rq_to_pdu(abort_req); nvme_set_info(abort_cmd, abort_req, abort_completion); @@ -1141,7 +1143,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) cmd.abort.sqid = cpu_to_le16(nvmeq->qid); cmd.abort.command_id = abort_req->tag; - --dev->ctrl.abort_limit; cmd_rq->aborted = 1; dev_warn(nvmeq->q_dmadev, "I/O %d QID %d timeout, aborting\n", |