nvme: don't use PREPARE_WORK
PREPARE_[DELAYED_]WORK() are being phased out. They have few users and a nasty surprise in terms of reentrancy guarantee as workqueue considers work items to be different if they don't have the same work function. nvme_dev->reset_work is multiplexed with multiple work functions. Introduce nvme_reset_workfn() which invokes nvme_dev->reset_workfn and always use it as the work function and update the users to set the ->reset_workfn field instead of overriding the work function using PREPARE_WORK(). It would probably be best to route this with other related updates through the workqueue tree. Compile tested. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Matthew Wilcox <willy@linux.intel.com> Cc: linux-nvme@lists.infradead.org
This commit is contained in:
parent
77fa83cf74
commit
9ca9737444
|
@ -993,7 +993,7 @@ static void nvme_abort_cmd(int cmdid, struct nvme_queue *nvmeq)
|
||||||
dev_warn(&dev->pci_dev->dev,
|
dev_warn(&dev->pci_dev->dev,
|
||||||
"I/O %d QID %d timeout, reset controller\n", cmdid,
|
"I/O %d QID %d timeout, reset controller\n", cmdid,
|
||||||
nvmeq->qid);
|
nvmeq->qid);
|
||||||
PREPARE_WORK(&dev->reset_work, nvme_reset_failed_dev);
|
dev->reset_workfn = nvme_reset_failed_dev;
|
||||||
queue_work(nvme_workq, &dev->reset_work);
|
queue_work(nvme_workq, &dev->reset_work);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1696,8 +1696,7 @@ static int nvme_kthread(void *data)
|
||||||
list_del_init(&dev->node);
|
list_del_init(&dev->node);
|
||||||
dev_warn(&dev->pci_dev->dev,
|
dev_warn(&dev->pci_dev->dev,
|
||||||
"Failed status, reset controller\n");
|
"Failed status, reset controller\n");
|
||||||
PREPARE_WORK(&dev->reset_work,
|
dev->reset_workfn = nvme_reset_failed_dev;
|
||||||
nvme_reset_failed_dev);
|
|
||||||
queue_work(nvme_workq, &dev->reset_work);
|
queue_work(nvme_workq, &dev->reset_work);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2406,7 +2405,7 @@ static int nvme_dev_resume(struct nvme_dev *dev)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret == -EBUSY) {
|
if (ret == -EBUSY) {
|
||||||
spin_lock(&dev_list_lock);
|
spin_lock(&dev_list_lock);
|
||||||
PREPARE_WORK(&dev->reset_work, nvme_remove_disks);
|
dev->reset_workfn = nvme_remove_disks;
|
||||||
queue_work(nvme_workq, &dev->reset_work);
|
queue_work(nvme_workq, &dev->reset_work);
|
||||||
spin_unlock(&dev_list_lock);
|
spin_unlock(&dev_list_lock);
|
||||||
}
|
}
|
||||||
|
@ -2435,6 +2434,12 @@ static void nvme_reset_failed_dev(struct work_struct *ws)
|
||||||
nvme_dev_reset(dev);
|
nvme_dev_reset(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nvme_reset_workfn(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct nvme_dev *dev = container_of(work, struct nvme_dev, reset_work);
|
||||||
|
dev->reset_workfn(work);
|
||||||
|
}
|
||||||
|
|
||||||
static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
int result = -ENOMEM;
|
int result = -ENOMEM;
|
||||||
|
@ -2453,7 +2458,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
goto free;
|
goto free;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&dev->namespaces);
|
INIT_LIST_HEAD(&dev->namespaces);
|
||||||
INIT_WORK(&dev->reset_work, nvme_reset_failed_dev);
|
dev->reset_workfn = nvme_reset_failed_dev;
|
||||||
|
INIT_WORK(&dev->reset_work, nvme_reset_workfn);
|
||||||
dev->pci_dev = pdev;
|
dev->pci_dev = pdev;
|
||||||
pci_set_drvdata(pdev, dev);
|
pci_set_drvdata(pdev, dev);
|
||||||
result = nvme_set_instance(dev);
|
result = nvme_set_instance(dev);
|
||||||
|
@ -2553,7 +2559,7 @@ static int nvme_resume(struct device *dev)
|
||||||
struct nvme_dev *ndev = pci_get_drvdata(pdev);
|
struct nvme_dev *ndev = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
if (nvme_dev_resume(ndev) && !work_busy(&ndev->reset_work)) {
|
if (nvme_dev_resume(ndev) && !work_busy(&ndev->reset_work)) {
|
||||||
PREPARE_WORK(&ndev->reset_work, nvme_reset_failed_dev);
|
ndev->reset_workfn = nvme_reset_failed_dev;
|
||||||
queue_work(nvme_workq, &ndev->reset_work);
|
queue_work(nvme_workq, &ndev->reset_work);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -87,6 +87,7 @@ struct nvme_dev {
|
||||||
struct list_head namespaces;
|
struct list_head namespaces;
|
||||||
struct kref kref;
|
struct kref kref;
|
||||||
struct miscdevice miscdev;
|
struct miscdevice miscdev;
|
||||||
|
work_func_t reset_workfn;
|
||||||
struct work_struct reset_work;
|
struct work_struct reset_work;
|
||||||
char name[12];
|
char name[12];
|
||||||
char serial[20];
|
char serial[20];
|
||||||
|
|
Loading…
Reference in a new issue