Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright: Matias Bjorling <mb@bjorling.me> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License version |
| 6 | * 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef GENNVM_H_ |
| 16 | #define GENNVM_H_ |
| 17 | |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/vmalloc.h> |
| 20 | |
| 21 | #include <linux/lightnvm.h> |
| 22 | |
| 23 | struct gen_lun { |
| 24 | struct nvm_lun vlun; |
| 25 | |
| 26 | int reserved_blocks; |
| 27 | /* lun block lists */ |
| 28 | struct list_head used_list; /* In-use blocks */ |
| 29 | struct list_head free_list; /* Not used blocks i.e. released |
| 30 | * and ready for use |
| 31 | */ |
| 32 | struct list_head bb_list; /* Bad blocks. Mutually exclusive with |
| 33 | * free_list and used_list |
| 34 | */ |
| 35 | }; |
| 36 | |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 37 | struct gen_dev { |
Matias Bjørling | 1145046 | 2015-11-16 15:34:37 +0100 | [diff] [blame] | 38 | struct nvm_dev *dev; |
| 39 | |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 40 | int nr_luns; |
| 41 | struct gen_lun *luns; |
Wenwei Tao | 4c9dacb | 2016-03-03 15:06:37 +0100 | [diff] [blame] | 42 | struct list_head area_list; |
Matias Bjørling | b76eb20b | 2016-07-07 09:54:16 +0200 | [diff] [blame] | 43 | |
| 44 | struct mutex lock; |
| 45 | struct list_head targets; |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 48 | struct gen_area { |
Wenwei Tao | 4c9dacb | 2016-03-03 15:06:37 +0100 | [diff] [blame] | 49 | struct list_head list; |
| 50 | sector_t begin; |
| 51 | sector_t end; /* end is excluded */ |
| 52 | }; |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 53 | |
| 54 | #define gen_for_each_lun(bm, lun, i) \ |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 55 | for ((i) = 0, lun = &(bm)->luns[0]; \ |
| 56 | (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)]) |
| 57 | |
| 58 | #endif /* GENNVM_H_ */ |