dqblk_qtree.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Definitions of structures and functions for quota formats using trie
  4. */
  5. #ifndef _LINUX_DQBLK_QTREE_H
  6. #define _LINUX_DQBLK_QTREE_H
  7. #include <linux/types.h>
  8. /* Numbers of blocks needed for updates - we count with the smallest
  9. * possible block size (1024) */
  10. #define QTREE_INIT_ALLOC 4
  11. #define QTREE_INIT_REWRITE 2
  12. #define QTREE_DEL_ALLOC 0
  13. #define QTREE_DEL_REWRITE 6
  14. struct dquot;
  15. struct kqid;
  16. /* Operations */
  17. struct qtree_fmt_operations {
  18. void (*mem2disk_dqblk)(void *disk, struct dquot *dquot); /* Convert given entry from in memory format to disk one */
  19. void (*disk2mem_dqblk)(struct dquot *dquot, void *disk); /* Convert given entry from disk format to in memory one */
  20. int (*is_id)(void *disk, struct dquot *dquot); /* Is this structure for given id? */
  21. };
  22. /* Inmemory copy of version specific information */
  23. struct qtree_mem_dqinfo {
  24. struct super_block *dqi_sb; /* Sb quota is on */
  25. int dqi_type; /* Quota type */
  26. unsigned int dqi_blocks; /* # of blocks in quota file */
  27. unsigned int dqi_free_blk; /* First block in list of free blocks */
  28. unsigned int dqi_free_entry; /* First block with free entry */
  29. unsigned int dqi_blocksize_bits; /* Block size of quota file */
  30. unsigned int dqi_entry_size; /* Size of quota entry in quota file */
  31. unsigned int dqi_usable_bs; /* Space usable in block for quota data */
  32. unsigned int dqi_qtree_depth; /* Precomputed depth of quota tree */
  33. const struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */
  34. };
  35. int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
  36. int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
  37. int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
  38. int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
  39. int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
  40. static inline int qtree_depth(struct qtree_mem_dqinfo *info)
  41. {
  42. unsigned int epb = info->dqi_usable_bs >> 2;
  43. unsigned long long entries = epb;
  44. int i;
  45. for (i = 1; entries < (1ULL << 32); i++)
  46. entries *= epb;
  47. return i;
  48. }
  49. int qtree_get_next_id(struct qtree_mem_dqinfo *info, struct kqid *qid);
  50. #endif /* _LINUX_DQBLK_QTREE_H */