aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-09-21 23:54:49 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:21 -0500
commit1ccd14b9c271c1ac6eec5c5ec5def433100e7248 (patch)
tree959756aa5b68c568a18697464df3f0acdd0387cf /include/linux
parentcf770c137122b78470a67ebd5498947869a09197 (diff)
quota: Split off quota tree handling into a separate file
There is going to be a new version of quota format having 64-bit quota limits and a new quota format for OCFS2. They are both going to use the same tree structure as VFSv0 quota format. So split out tree handling into a separate file and make size of leaf blocks, amount of space usable in each block (needed for checksumming) and structures contained in them configurable so that the code can be shared. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/dqblk_qtree.h56
-rw-r--r--include/linux/dqblk_v2.h19
2 files changed, 64 insertions, 11 deletions
diff --git a/include/linux/dqblk_qtree.h b/include/linux/dqblk_qtree.h
new file mode 100644
index 000000000000..82a16527b367
--- /dev/null
+++ b/include/linux/dqblk_qtree.h
@@ -0,0 +1,56 @@
1/*
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;
18
19/* Operations */
20struct qtree_fmt_operations {
21 void (*mem2disk_dqblk)(void *disk, struct dquot *dquot); /* Convert given entry from in memory format to disk one */
22 void (*disk2mem_dqblk)(struct dquot *dquot, void *disk); /* Convert given entry from disk format to in memory one */
23 int (*is_id)(void *disk, struct dquot *dquot); /* Is this structure for given id? */
24};
25
26/* Inmemory copy of version specific information */
27struct qtree_mem_dqinfo {
28 struct super_block *dqi_sb; /* Sb quota is on */
29 int dqi_type; /* Quota type */
30 unsigned int dqi_blocks; /* # of blocks in quota file */
31 unsigned int dqi_free_blk; /* First block in list of free blocks */
32 unsigned int dqi_free_entry; /* First block with free entry */
33 unsigned int dqi_blocksize_bits; /* Block size of quota file */
34 unsigned int dqi_entry_size; /* Size of quota entry in quota file */
35 unsigned int dqi_usable_bs; /* Space usable in block for quota data */
36 unsigned int dqi_qtree_depth; /* Precomputed depth of quota tree */
37 struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */
38};
39
40int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
41int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
42int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
43int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
44int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
45static inline int qtree_depth(struct qtree_mem_dqinfo *info)
46{
47 unsigned int epb = info->dqi_usable_bs >> 2;
48 unsigned long long entries = epb;
49 int i;
50
51 for (i = 1; entries < (1ULL << 32); i++)
52 entries *= epb;
53 return i;
54}
55
56#endif /* _LINUX_DQBLK_QTREE_H */
diff --git a/include/linux/dqblk_v2.h b/include/linux/dqblk_v2.h
index 4f853322cb7f..e5e22a787d58 100644
--- a/include/linux/dqblk_v2.h
+++ b/include/linux/dqblk_v2.h
@@ -1,26 +1,23 @@
1/* 1/*
2 * Definitions of structures for vfsv0 quota format 2 * Definitions for vfsv0 quota format
3 */ 3 */
4 4
5#ifndef _LINUX_DQBLK_V2_H 5#ifndef _LINUX_DQBLK_V2_H
6#define _LINUX_DQBLK_V2_H 6#define _LINUX_DQBLK_V2_H
7 7
8#include <linux/types.h> 8#include <linux/dqblk_qtree.h>
9 9
10/* id numbers of quota format */ 10/* Id number of quota format */
11#define QFMT_VFS_V0 2 11#define QFMT_VFS_V0 2
12 12
13/* Numbers of blocks needed for updates */ 13/* Numbers of blocks needed for updates */
14#define V2_INIT_ALLOC 4 14#define V2_INIT_ALLOC QTREE_INIT_ALLOC
15#define V2_INIT_REWRITE 2 15#define V2_INIT_REWRITE QTREE_INIT_REWRITE
16#define V2_DEL_ALLOC 0 16#define V2_DEL_ALLOC QTREE_DEL_ALLOC
17#define V2_DEL_REWRITE 6 17#define V2_DEL_REWRITE QTREE_DEL_REWRITE
18 18
19/* Inmemory copy of version specific information */
20struct v2_mem_dqinfo { 19struct v2_mem_dqinfo {
21 unsigned int dqi_blocks; 20 struct qtree_mem_dqinfo i;
22 unsigned int dqi_free_blk;
23 unsigned int dqi_free_entry;
24}; 21};
25 22
26#endif /* _LINUX_DQBLK_V2_H */ 23#endif /* _LINUX_DQBLK_V2_H */