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; 181ccd14b9SJan Kara 191ccd14b9SJan Kara /* Operations */ 201ccd14b9SJan Kara struct qtree_fmt_operations { 211ccd14b9SJan Kara void (*mem2disk_dqblk)(void *disk, struct dquot *dquot); /* Convert given entry from in memory format to disk one */ 221ccd14b9SJan Kara void (*disk2mem_dqblk)(struct dquot *dquot, void *disk); /* Convert given entry from disk format to in memory one */ 231ccd14b9SJan Kara int (*is_id)(void *disk, struct dquot *dquot); /* Is this structure for given id? */ 241ccd14b9SJan Kara }; 251ccd14b9SJan Kara 261ccd14b9SJan Kara /* Inmemory copy of version specific information */ 271ccd14b9SJan Kara struct qtree_mem_dqinfo { 281ccd14b9SJan Kara struct super_block *dqi_sb; /* Sb quota is on */ 291ccd14b9SJan Kara int dqi_type; /* Quota type */ 301ccd14b9SJan Kara unsigned int dqi_blocks; /* # of blocks in quota file */ 311ccd14b9SJan Kara unsigned int dqi_free_blk; /* First block in list of free blocks */ 321ccd14b9SJan Kara unsigned int dqi_free_entry; /* First block with free entry */ 331ccd14b9SJan Kara unsigned int dqi_blocksize_bits; /* Block size of quota file */ 341ccd14b9SJan Kara unsigned int dqi_entry_size; /* Size of quota entry in quota file */ 351ccd14b9SJan Kara unsigned int dqi_usable_bs; /* Space usable in block for quota data */ 361ccd14b9SJan Kara unsigned int dqi_qtree_depth; /* Precomputed depth of quota tree */ 37*d1b98c23SJulia Lawall const struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */ 381ccd14b9SJan Kara }; 391ccd14b9SJan Kara 401ccd14b9SJan Kara int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 411ccd14b9SJan Kara int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 421ccd14b9SJan Kara int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 431ccd14b9SJan Kara int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot); 441ccd14b9SJan Kara int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk); 451ccd14b9SJan Kara static inline int qtree_depth(struct qtree_mem_dqinfo *info) 461ccd14b9SJan Kara { 471ccd14b9SJan Kara unsigned int epb = info->dqi_usable_bs >> 2; 481ccd14b9SJan Kara unsigned long long entries = epb; 491ccd14b9SJan Kara int i; 501ccd14b9SJan Kara 511ccd14b9SJan Kara for (i = 1; entries < (1ULL << 32); i++) 521ccd14b9SJan Kara entries *= epb; 531ccd14b9SJan Kara return i; 541ccd14b9SJan Kara } 551ccd14b9SJan Kara 561ccd14b9SJan Kara #endif /* _LINUX_DQBLK_QTREE_H */ 57