block/sed-opal: allocate struct opal_dev dynamically

Insted of bloating the containing structure with it all the time this
allocates struct opal_dev dynamically.  Additionally this allows moving
the definition of struct opal_dev into sed-opal.c.  For this a new
private data field is added to it that is passed to the send/receive
callback.  After that a lot of internals can be made private as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Scott Bauer <scott.bauer@intel.com>
Reviewed-by: Scott Bauer <scott.bauer@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Christoph Hellwig
2017-02-17 13:59:39 +01:00
committed by Jens Axboe
parent f5b37b7c23
commit 4f1244c829
6 changed files with 131 additions and 140 deletions

View File

@@ -1742,6 +1742,7 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
if (dev->ctrl.admin_q)
blk_put_queue(dev->ctrl.admin_q);
kfree(dev->queues);
kfree(dev->ctrl.opal_dev);
kfree(dev);
}
@@ -1791,10 +1792,13 @@ static void nvme_reset_work(struct work_struct *work)
if (result)
goto out;
init_opal_dev(&dev->ctrl.opal_dev, &nvme_sec_submit);
if (!dev->ctrl.opal_dev) {
dev->ctrl.opal_dev =
init_opal_dev(&dev->ctrl, &nvme_sec_submit);
}
if (was_suspend)
opal_unlock_from_suspend(&dev->ctrl.opal_dev);
opal_unlock_from_suspend(dev->ctrl.opal_dev);
result = nvme_setup_io_queues(dev);
if (result)