aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/core.c
diff options
context:
space:
mode:
authorMatias Bjørling <m@bjorling.me>2016-01-12 01:49:21 -0500
committerJens Axboe <axboe@fb.com>2016-01-12 10:21:16 -0500
commit91276162de9476b8ff32d9452e849210e5dd09e9 (patch)
tree53337c60f7d863b1ab733f9bcd4964da818f9057 /drivers/lightnvm/core.c
parentabd805ec9f51f37db9da63dda44c3f4b4ae8ad57 (diff)
lightnvm: refactor end_io functions for sync
To implement sync I/O support within the LightNVM core, the end_io functions are refactored to take an end_io function pointer instead of testing for initialized media manager, followed by calling its end_io function. Sync I/O can then be implemented using a callback that signal I/O completion. This is similar to the logic found in blk_to_execute_io(). By implementing it this way, the underlying device I/Os submission logic is abstracted away from core, targets, and media managers. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r--drivers/lightnvm/core.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 081b0f59b773..fa1a052c4737 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/miscdevice.h> 28#include <linux/miscdevice.h>
29#include <linux/lightnvm.h> 29#include <linux/lightnvm.h>
30#include <linux/sched/sysctl.h>
30#include <uapi/linux/lightnvm.h> 31#include <uapi/linux/lightnvm.h>
31 32
32static LIST_HEAD(nvm_targets); 33static LIST_HEAD(nvm_targets);
@@ -288,6 +289,21 @@ int nvm_erase_ppa(struct nvm_dev *dev, struct ppa_addr ppa)
288} 289}
289EXPORT_SYMBOL(nvm_erase_ppa); 290EXPORT_SYMBOL(nvm_erase_ppa);
290 291
292void nvm_end_io(struct nvm_rq *rqd, int error)
293{
294 rqd->end_io(rqd, error);
295}
296EXPORT_SYMBOL(nvm_end_io);
297
298static void nvm_end_io_sync(struct nvm_rq *rqd, int errors)
299{
300 struct completion *waiting = rqd->wait;
301
302 rqd->wait = NULL;
303
304 complete(waiting);
305}
306
291static int nvm_core_init(struct nvm_dev *dev) 307static int nvm_core_init(struct nvm_dev *dev)
292{ 308{
293 struct nvm_id *id = &dev->identity; 309 struct nvm_id *id = &dev->identity;