11ccd14b9SJan Kara /* 21ccd14b9SJan Kara * Definitions of structures and functions for quota formats using trie 31ccd14b9SJan Kara */ 41ccd14b9SJan Kara 51ccd14b9SJan Kara #ifndef _LINUX_DQBLK_QTREE_H 61ccd14b9SJan Kara #define _LINUX_DQBLK_QTREE_H 71ccd14b9SJan Kara 81ccd14b9SJan Kara #include <linux/types.h> 91ccd14b9SJan Kara 101ccd14b9SJan Kara /* Numbers of blocks needed for updates - we count with the smallest 111ccd14b9SJan Kara * possible block size (1024) */ 121ccd14b9SJan Kara #define QTREE_INIT_ALLOC 4 131ccd14b9SJan Kara #define QTREE_INIT_REWRITE 2 141ccd14b9SJan Kara #define QTREE_DEL_ALLOC 0 151ccd14b9SJan Kara #define QTREE_DEL_REWRITE 6 161ccd14b9SJan Kara 171ccd14b9SJan Kara struct dquot; 18*0066373dSJan Kara struct kqid; 191ccd14b9SJan Kara 201ccd14b9SJan Kara /* Operations */ 211ccd14b9SJan Kara struct qtree_fmt_operations { 221ccd14b9SJan Kara void (*mem2disk_dqblk)(void *disk, struct dquot *dquot); /* Convert given entry from in memory format to disk one */ 231ccd14b9SJan Kara void (*disk2mem_dqblk)(struct dquot *dquot, void *disk); /* Convert given entry from disk format to in memory one */ 241ccd14b9SJan Kara int (*is_id)(void *disk, struct dquot *dquot); /* Is this structure for given id? */ 251ccd14b9SJan Kara }; 261ccd14b9SJan Kara 271ccd14b9SJan Kara /* Inmemory copy of version specific information */ 281ccd14b9SJan Kara struct qtree_mem_dqinfo { 291ccd14b9SJan Kara struct super_block *dqi_sb; /* Sb quota is on */ 301ccd14b9SJan Kara int dqi_type; /* Quota type */ 311ccd14b9SJan Kara unsigned int dqi_blocks; /* # of blocks in quota file */ 321ccd14b9SJan Kara unsigned int dqi_free_blk; /* First block in list of free blocks */ 331ccd14b9SJan Kara unsigned int dqi_free_entry; /* First block with free entry */ 341ccd14b9SJan Kara unsigned int dqi_blocksize_bits; /* Block size of quota file */ 351ccd14b9SJan Kara unsigned int dqi_entry_size; /* Size of quota entry in quota file */ 361ccd14b9SJan Kara unsigned int dqi_usable_bs; /* Space usable in block for quota data */ 371ccd14b9SJan Kara unsigned int dqi_qtree_depth; /* Precomputed depth of quota tree */ 38d1b98c23SJulia Lawall const struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */ 391ccd14b9SJan Kara }; 401ccd14b9SJan Kara 411ccd14b9SJan Kara int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 421ccd14b9SJan Kara int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 431ccd14b9SJan Kara int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 441ccd14b9SJan Kara int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 451ccd14b9SJan Kara int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk); 461ccd14b9SJan Kara static inline int qtree_depth(struct qtree_mem_dqinfo *info) 471ccd14b9SJan Kara { 481ccd14b9SJan Kara unsigned int epb = info->dqi_usable_bs >> 2; 491ccd14b9SJan Kara unsigned long long entries = epb; 501ccd14b9SJan Kara int i; 511ccd14b9SJan Kara 521ccd14b9SJan Kara for (i = 1; entries < (1ULL << 32); i++) 531ccd14b9SJan Kara entries *= epb; 541ccd14b9SJan Kara return i; 551ccd14b9SJan Kara } 56*0066373dSJan Kara int qtree_get_next_id(struct qtree_mem_dqinfo *info, struct kqid *qid); 571ccd14b9SJan Kara 581ccd14b9SJan Kara #endif /* _LINUX_DQBLK_QTREE_H */ 59