dqblk_qtree.h 2.1 KB

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