gennvm.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef GENNVM_H_
  15. #define GENNVM_H_
  16. #include <linux/module.h>
  17. #include <linux/vmalloc.h>
  18. #include <linux/lightnvm.h>
  19. struct gen_lun {
  20. struct nvm_lun vlun;
  21. int reserved_blocks;
  22. /* lun block lists */
  23. struct list_head used_list; /* In-use blocks */
  24. struct list_head free_list; /* Not used blocks i.e. released
  25. * and ready for use
  26. */
  27. struct list_head bb_list; /* Bad blocks. Mutually exclusive with
  28. * free_list and used_list
  29. */
  30. };
  31. struct gen_nvm {
  32. struct nvm_dev *dev;
  33. int nr_luns;
  34. struct gen_lun *luns;
  35. };
  36. #define gennvm_for_each_lun(bm, lun, i) \
  37. for ((i) = 0, lun = &(bm)->luns[0]; \
  38. (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
  39. #endif /* GENNVM_H_ */