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