Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Definitions of structures and functions for quota formats using trie
0004  */
0005 
0006 #ifndef _LINUX_DQBLK_QTREE_H
0007 #define _LINUX_DQBLK_QTREE_H
0008 
0009 #include <linux/types.h>
0010 
0011 /* Numbers of blocks needed for updates - we count with the smallest
0012  * possible block size (1024) */
0013 #define QTREE_INIT_ALLOC 4
0014 #define QTREE_INIT_REWRITE 2
0015 #define QTREE_DEL_ALLOC 0
0016 #define QTREE_DEL_REWRITE 6
0017 
0018 struct dquot;
0019 struct kqid;
0020 
0021 /* Operations */
0022 struct qtree_fmt_operations {
0023     void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);    /* Convert given entry from in memory format to disk one */
0024     void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);    /* Convert given entry from disk format to in memory one */
0025     int (*is_id)(void *disk, struct dquot *dquot);  /* Is this structure for given id? */
0026 };
0027 
0028 /* Inmemory copy of version specific information */
0029 struct qtree_mem_dqinfo {
0030     struct super_block *dqi_sb; /* Sb quota is on */
0031     int dqi_type;           /* Quota type */
0032     unsigned int dqi_blocks;    /* # of blocks in quota file */
0033     unsigned int dqi_free_blk;  /* First block in list of free blocks */
0034     unsigned int dqi_free_entry;    /* First block with free entry */
0035     unsigned int dqi_blocksize_bits;    /* Block size of quota file */
0036     unsigned int dqi_entry_size;    /* Size of quota entry in quota file */
0037     unsigned int dqi_usable_bs; /* Space usable in block for quota data */
0038     unsigned int dqi_qtree_depth;   /* Precomputed depth of quota tree */
0039     const struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */
0040 };
0041 
0042 int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
0043 int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
0044 int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
0045 int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
0046 int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
0047 static inline int qtree_depth(struct qtree_mem_dqinfo *info)
0048 {
0049     unsigned int epb = info->dqi_usable_bs >> 2;
0050     unsigned long long entries = epb;
0051     int i;
0052 
0053     for (i = 1; entries < (1ULL << 32); i++)
0054         entries *= epb;
0055     return i;
0056 }
0057 int qtree_get_next_id(struct qtree_mem_dqinfo *info, struct kqid *qid);
0058 
0059 #endif /* _LINUX_DQBLK_QTREE_H */