gennvm.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_dev {
  32. struct nvm_dev *dev;
  33. int nr_luns;
  34. struct gen_lun *luns;
  35. struct list_head area_list;
  36. struct mutex lock;
  37. struct list_head targets;
  38. };
  39. struct gen_area {
  40. struct list_head list;
  41. sector_t begin;
  42. sector_t end; /* end is excluded */
  43. };
  44. #define gen_for_each_lun(bm, lun, i) \
  45. for ((i) = 0, lun = &(bm)->luns[0]; \
  46. (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
  47. #endif /* GENNVM_H_ */