summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/gennvm.h
diff options
context:
space:
mode:
authorMatias Bjørling <m@bjorling.me>2015-10-28 19:54:56 +0100
committerJens Axboe <axboe@fb.com>2015-10-29 16:21:42 +0900
commit48add0f5a6f46919dd307575aad6ea3de7c9cb2a (patch)
tree1d30a56f86d8b74ffe5b80e977ededabea0ed080 /drivers/lightnvm/gennvm.h
parentcd9e9808d18fe7107c306f6e71c8be7230ee42b4 (diff)
gennvm: Generic NVM manager
The implementation for Open-Channel SSDs is divided into media management and targets. This patch implements a generic media manager for open-channel SSDs. After a media manager has been initialized, single or multiple targets can be instantiated with the media managed as the backend. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/gennvm.h')
-rw-r--r--drivers/lightnvm/gennvm.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/lightnvm/gennvm.h b/drivers/lightnvm/gennvm.h
new file mode 100644
index 000000000000..d23bd3501ddc
--- /dev/null
+++ b/drivers/lightnvm/gennvm.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright: Matias Bjorling <mb@bjorling.me>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef GENNVM_H_
+#define GENNVM_H_
+
+#include <linux/module.h>
+#include <linux/vmalloc.h>
+
+#include <linux/lightnvm.h>
+
+struct gen_lun {
+ struct nvm_lun vlun;
+
+ int reserved_blocks;
+ /* lun block lists */
+ struct list_head used_list; /* In-use blocks */
+ struct list_head free_list; /* Not used blocks i.e. released
+ * and ready for use
+ */
+ struct list_head bb_list; /* Bad blocks. Mutually exclusive with
+ * free_list and used_list
+ */
+};
+
+struct gen_nvm {
+ int nr_luns;
+ struct gen_lun *luns;
+};
+
+#define gennvm_for_each_lun(bm, lun, i) \
+ for ((i) = 0, lun = &(bm)->luns[0]; \
+ (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
+
+#endif /* GENNVM_H_ */