File: ext2.h

package info (click to toggle)
defrag 0.73-1
  • links: PTS
  • area: main
  • in suites: hamm, potato, slink
  • size: 384 kB
  • ctags: 599
  • sloc: ansic: 4,463; makefile: 137; sh: 37
file content (86 lines) | stat: -rw-r--r-- 3,124 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * ext2.h - extfs-specific include file for the Linux file system 
 * degragmenter. 
 *
 * Copyleft  (C) 1993 Alexey Vovenko (vovenko@ixwin.ihep.su)
 * Copyright (C) 1992, 1993 Stephen Tweedie (sct@dcs.ed.ac.uk)
 * Copyright (C) 1992 Remy Card (card@masi.ibp.fr)
 * Copyright (C) 1991 Linus Torvalds (torvalds@kruuna.helsinki.fi)
 * 
 * This file may be redistributed under the terms of the GNU General
 * Public License.
 *
 */

#include <linux/fs.h>
#include <linux/ext2_fs.h>
#include <linux/ext2_fs_i.h>
#include <linux/ext2_fs_sb.h>

#define HAS_TIND

#define DIRECT_ZONES     EXT2_NDIR_BLOCKS

#define ROOT_INO         EXT2_ROOT_INO
#define BAD_INO          EXT2_BAD_INO
#define FIRST_USER_INODE EXT2_FIRST_INO(&s)

typedef unsigned long Block;

#define d_inode ext2_inode
#define i_zone i_block

#define UPPER(size,n)		((size + ((n) - 1)) / (n))
#define INODE_SIZE		(sizeof (struct d_inode))
#define INODE_BLOCKS		UPPER(INODES, EXT2_INODES_PER_BLOCK)
#define INODE_BUFFER_SIZE	(INODE_BLOCKS * BLOCK_SIZE)

#define BITS_PER_BLOCK		(BLOCK_SIZE<<3)

#define Super		(* (struct ext2_super_block *) super_block_buffer)
#define INODES		(Super.s_inodes_count)
#define ZONES		(Super.s_blocks_count)
#define FREEBLOCKSCOUNT	(Super.s_free_blocks_count)
#define FREEINODESCOUNT	(Super.s_free_inodes_count)
#define FIRSTZONE	(Super.s_first_data_block) 
#define ZONESIZE	(Super.s_log_block_size)
#define MAGIC		(Super.s_magic)
#define NORM_FIRSTZONE	1                          
#define INODES_PER_BLOCK (BLOCK_SIZE >> 2)

    /* This structure is used to calculate, how many blocks are claimed 
     * by the inodes in the each group. 
     * native_blocks is set by update_group_population and counts blocks
     *               that should be in the group and already are there.
     *               This is the most useless variable. It's collected for
     *               report only.
     *
     * wants_away    is set by update_group_population and counts blocks   
     *               that shouldn't be in the group, but initially are.
     *
     * wants_back    is also set by check_group_population and holds 
     *               count of blocks, that aren't initially in their group
     *
     * free_blocks   is set by_check_group_population() from the block 
     *               bitmaps to the amount of the blocks that would be
     *               left free in the group, after all its blocks are
     *               brought there and all foreign blocks are removed.
     *               This is the key parameter which tells us, how
     *               many blocks from other groups are allowed into the
     *               current group without pushing out the blocks from 
     *               this group.
     * 
     */
      
struct groups_population {
   ulong free_blocks;
   ulong native_blocks; /* Not used actually anywhere, but verbose report */
   ulong wants_away;
   ulong wants_back;
   ulong next_block_to_fill;
   ulong last_block;
};

ulong choose_block (ulong inode);
void check_group_population (void);
void update_group_population (ulong znr, enum walk_zone_mode mode, ulong inode);