reiserfs_fs.h
来自「自己做的交叉编译工具!gcc-3.4.5,glibc-2.3.6在ubuntu8」· C头文件 代码 · 共 1,578 行 · 第 1/5 页
H
1,578 行
{ int vi_index; // index in the array of item operations unsigned short vi_type; // left/right mergeability unsigned short vi_item_len; /* length of item that it will have after balancing */ struct item_head * vi_ih; const char * vi_item; // body of item (old or new) const void * vi_new_data; // 0 always but paste mode void * vi_uarea; // item specific area};struct virtual_node{ char * vn_free_ptr; /* this is a pointer to the free space in the buffer */ unsigned short vn_nr_item; /* number of items in virtual node */ short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */ short vn_mode; /* mode of balancing (paste, insert, delete, cut) */ short vn_affected_item_num; short vn_pos_in_item; struct item_head * vn_ins_ih; /* item header of inserted item, 0 for other modes */ const void * vn_data; struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */};/* used by directory items when creating virtual nodes */struct direntry_uarea { int flags; __u16 entry_count; __u16 entry_sizes[1];} __attribute__ ((__packed__)) ;/***************************************************************************//* TREE BALANCE *//***************************************************************************//* This temporary structure is used in tree balance algorithms, and constructed as we go to the extent that its various parts are needed. It contains arrays of nodes that can potentially be involved in the balancing of node S, and parameters that define how each of the nodes must be balanced. Note that in these algorithms for balancing the worst case is to need to balance the current node S and the left and right neighbors and all of their parents plus create a new node. We implement S1 balancing for the leaf nodes and S0 balancing for the internal nodes (S1 and S0 are defined in our papers.)*/#define MAX_FREE_BLOCK 7 /* size of the array of buffers to free at end of do_balance *//* maximum number of FEB blocknrs on a single level */#define MAX_AMOUNT_NEEDED 2/* These are modes of balancing *//* When inserting an item. */#define M_INSERT 'i'/* When inserting into (directories only) or appending onto an already existant item. */#define M_PASTE 'p'/* When deleting an item. */#define M_DELETE 'd'/* When truncating an item or removing an entry from a (directory) item. */#define M_CUT 'c'/* used when balancing on leaf level skipped (in reiserfsck) */#define M_INTERNAL 'n'/* When further balancing is not needed, then do_balance does not need to be called. */#define M_SKIP_BALANCING 's'#define M_CONVERT 'v'/* modes of leaf_move_items */#define LEAF_FROM_S_TO_L 0#define LEAF_FROM_S_TO_R 1#define LEAF_FROM_R_TO_L 2#define LEAF_FROM_L_TO_R 3#define LEAF_FROM_S_TO_SNEW 4#define FIRST_TO_LAST 0#define LAST_TO_FIRST 1/* there are 4 types of items: stat data, directory item, indirect, direct.+-------------------+------------+--------------+------------+| | k_offset | k_uniqueness | mergeable? |+-------------------+------------+--------------+------------+| stat data | 0 | 0 | no |+-------------------+------------+--------------+------------+| 1st directory item| DOT_OFFSET |DIRENTRY_UNIQUENESS| no | | non 1st directory | hash value | | yes || item | | | |+-------------------+------------+--------------+------------+| indirect item | offset + 1 |TYPE_INDIRECT | if this is not the first indirect item of the object+-------------------+------------+--------------+------------+| direct item | offset + 1 |TYPE_DIRECT | if not this is not the first direct item of the object+-------------------+------------+--------------+------------+*/struct item_operations { int (*bytes_number) (struct item_head * ih, int block_size); void (*decrement_key) (struct cpu_key *); int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize); void (*print_item) (struct item_head *, char * item); void (*check_item) (struct item_head *, char * item); int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi, int is_affected, int insert_size); int (*check_left) (struct virtual_item * vi, int free, int start_skip, int end_skip); int (*check_right) (struct virtual_item * vi, int free); int (*part_size) (struct virtual_item * vi, int from, int to); int (*unit_num) (struct virtual_item * vi); void (*print_vi) (struct virtual_item * vi);};extern struct item_operations * item_ops [TYPE_ANY + 1];#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)#define op_print_item(ih,item) item_ops[le_ih_k_type (ih)]->print_item (ih, item)#define op_check_item(ih,item) item_ops[le_ih_k_type (ih)]->check_item (ih, item)#define op_create_vi(vn,vi,is_affected,insert_size) item_ops[le_ih_k_type ((vi)->vi_ih)]->create_vi (vn,vi,is_affected,insert_size)#define op_check_left(vi,free,start_skip,end_skip) item_ops[(vi)->vi_index]->check_left (vi, free, start_skip, end_skip)#define op_check_right(vi,free) item_ops[(vi)->vi_index]->check_right (vi, free)#define op_part_size(vi,from,to) item_ops[(vi)->vi_index]->part_size (vi, from, to)#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi)#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi)#define COMP_SHORT_KEYS comp_short_keys/* number of blocks pointed to by the indirect item */#define I_UNFM_NUM(p_s_ih) ( ih_item_len(p_s_ih) / UNFM_P_SIZE )/* the used space within the unformatted node corresponding to pos within the item pointed to by ih */#define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - ih_free_space(ih) : (size))/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to *//* get the item header */ #define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )/* get key */#define B_N_PDELIM_KEY(bh,item_num) ( (struct reiserfs_key * )((bh)->b_data + BLKH_SIZE) + (item_num) )/* get the key */#define B_N_PKEY(bh,item_num) ( &(B_N_PITEM_HEAD(bh,item_num)->ih_key) )/* get item body */#define B_N_PITEM(bh,item_num) ( (bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(item_num))))/* get the stat data by the buffer header and the item order */#define B_N_STAT_DATA(bh,nr) \( (struct stat_data *)((bh)->b_data + ih_location(B_N_PITEM_HEAD((bh),(nr))) ) ) /* following defines use reiserfs buffer header and item header *//* get stat-data */#define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )((bh)->b_data + ih_location(ih)) )// this is 3976 for size==4096#define MAX_DIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - 2*IH_SIZE - SD_SIZE - UNFM_P_SIZE)/* indirect items consist of entries which contain blocknrs, pos indicates which entry, and B_I_POS_UNFM_POINTER resolves to the blocknr contained by the entry pos points to */#define B_I_POS_UNFM_POINTER(bh,ih,pos) le32_to_cpu(*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)))#define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)struct reiserfs_iget_args { __u32 objectid ; __u32 dirid ;} ;/***************************************************************************//* FUNCTION DECLARATIONS *//***************************************************************************/#define get_journal_desc_magic(bh) (bh->b_data + bh->b_size - 12)#define journal_trans_half(blocksize) \ ((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32))/* journal.c see journal.c for all the comments here *//* first block written in a commit. */struct reiserfs_journal_desc { __le32 j_trans_id ; /* id of commit */ __le32 j_len ; /* length of commit. len +1 is the commit block */ __le32 j_mount_id ; /* mount id of this trans*/ __le32 j_realblock[1] ; /* real locations for each block */} ;#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)#define get_desc_trans_len(d) le32_to_cpu((d)->j_len)#define get_desc_mount_id(d) le32_to_cpu((d)->j_mount_id)#define set_desc_trans_id(d,val) do { (d)->j_trans_id = cpu_to_le32 (val); } while (0)#define set_desc_trans_len(d,val) do { (d)->j_len = cpu_to_le32 (val); } while (0)#define set_desc_mount_id(d,val) do { (d)->j_mount_id = cpu_to_le32 (val); } while (0)/* last block written in a commit */struct reiserfs_journal_commit { __le32 j_trans_id ; /* must match j_trans_id from the desc block */ __le32 j_len ; /* ditto */ __le32 j_realblock[1] ; /* real locations for each block */} ;#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)#define get_commit_trans_len(c) le32_to_cpu((c)->j_len)#define get_commit_mount_id(c) le32_to_cpu((c)->j_mount_id)#define set_commit_trans_id(c,val) do { (c)->j_trans_id = cpu_to_le32 (val); } while (0)#define set_commit_trans_len(c,val) do { (c)->j_len = cpu_to_le32 (val); } while (0)/* this header block gets written whenever a transaction is considered fully flushed, and is more recent than the** last fully flushed transaction. fully flushed means all the log blocks and all the real blocks are on disk,** and this transaction does not need to be replayed.*/struct reiserfs_journal_header { __le32 j_last_flush_trans_id ; /* id of last fully flushed transaction */ __le32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */ __le32 j_mount_id ; /* 12 */ struct journal_params jh_journal;} ;/* biggest tunable defines are right here */#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */#define JOURNAL_TRANS_MIN_DEFAULT 256#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */#define JOURNAL_MIN_RATIO 2#define JOURNAL_MAX_COMMIT_AGE 30 #define JOURNAL_MAX_TRANS_AGE 30#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)#ifdef CONFIG_QUOTA#define REISERFS_QUOTA_TRANS_BLOCKS 2 /* We need to update data and inode (atime) */#define REISERFS_QUOTA_INIT_BLOCKS (DQUOT_MAX_WRITES*(JOURNAL_PER_BALANCE_CNT+2)+1) /* 1 balancing, 1 bitmap, 1 data per write + stat data update */#else#define REISERFS_QUOTA_TRANS_BLOCKS 0#define REISERFS_QUOTA_INIT_BLOCKS 0#endif/* both of these can be as low as 1, or as high as you want. The min is the** number of 4k bitmap nodes preallocated on mount. New nodes are allocated** as needed, and released when transactions are committed. On release, if ** the current number of nodes is > max, the node is freed, otherwise, ** it is put on a free list for faster use later.*/#define REISERFS_MIN_BITMAP_NODES 10 #define REISERFS_MAX_BITMAP_NODES 100 #define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */#define JBH_HASH_MASK 8191#define _jhashfn(sb,block) \ (((unsigned long)sb>>L1_CACHE_SHIFT) ^ \ (((block)<<(JBH_HASH_SHIFT - 6)) ^ ((block) >> 13) ^ ((block) << (JBH_HASH_SHIFT - 12))))#define journal_hash(t,sb,block) ((t)[_jhashfn((sb),(block)) & JBH_HASH_MASK])// We need these to make journal.c code more readable#define journal_find_get_block(s, block) __find_get_block(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)#define journal_getblk(s, block) __getblk(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)void reiserfs_commit_for_inode(struct inode *) ;void reiserfs_update_inode_transaction(struct inode *) ;void reiserfs_wait_on_write_block(struct super_block *s) ;void reiserfs_block_writes(struct reiserfs_transaction_handle *th) ;void reiserfs_allow_writes(struct super_block *s) ;void reiserfs_check_lock_depth(char *caller) ;int journal_init(struct super_block *, const char * j_dev_name, int old_format) ;int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ;int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ;int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, b_blocknr_t blocknr) ;int push_journal_writer(char *w) ;int pop_journal_writer(int windex) ;int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ;int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ;int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;void flush_async_commits(struct super_block *p_s_sb) ;int reiserfs_remove_page_from_flush_list(struct reiserfs_transaction_handle *, struct inode *) ;int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ;void add_save_link (struct reiserfs_transaction_handle * th, struct inode * inode, int truncate);void remove_save_link (struct inode * inode, int truncate);/* objectid.c */__u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th);void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release);int reiserfs_convert_objectid_map_v1(struct super_block *) ;// first key is in cpu form, second - leextern inline int comp_keys (const struct key * le_key, const struct cpu_key * cpu_key);extern inline int comp_short_keys (const struct key * le_key, const struct cpu_key * cpu_key);extern inline void le_key2cpu_key (struct cpu_key * to, const struct key * from);// both are cpu keysextern inline int comp_cpu_keys (const struct cpu_key *, c
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?