xref: /linux/fs/ext2/ext2.h (revision 776cfebb430c7b22c208b1b17add97f354d97cab)
1 #include <linux/fs.h>
2 #include <linux/ext2_fs.h>
3 
4 /*
5  * second extended file system inode data in memory
6  */
7 struct ext2_inode_info {
8 	__le32	i_data[15];
9 	__u32	i_flags;
10 	__u32	i_faddr;
11 	__u8	i_frag_no;
12 	__u8	i_frag_size;
13 	__u16	i_state;
14 	__u32	i_file_acl;
15 	__u32	i_dir_acl;
16 	__u32	i_dtime;
17 
18 	/*
19 	 * i_block_group is the number of the block group which contains
20 	 * this file's inode.  Constant across the lifetime of the inode,
21 	 * it is ued for making block allocation decisions - we try to
22 	 * place a file's data blocks near its inode block, and new inodes
23 	 * near to their parent directory's inode.
24 	 */
25 	__u32	i_block_group;
26 
27 	/*
28 	 * i_next_alloc_block is the logical (file-relative) number of the
29 	 * most-recently-allocated block in this file.  Yes, it is misnamed.
30 	 * We use this for detecting linearly ascending allocation requests.
31 	 */
32 	__u32	i_next_alloc_block;
33 
34 	/*
35 	 * i_next_alloc_goal is the *physical* companion to i_next_alloc_block.
36 	 * it the the physical block number of the block which was most-recently
37 	 * allocated to this file.  This give us the goal (target) for the next
38 	 * allocation when we detect linearly ascending requests.
39 	 */
40 	__u32	i_next_alloc_goal;
41 	__u32	i_prealloc_block;
42 	__u32	i_prealloc_count;
43 	__u32	i_dir_start_lookup;
44 #ifdef CONFIG_EXT2_FS_XATTR
45 	/*
46 	 * Extended attributes can be read independently of the main file
47 	 * data. Taking i_sem even when reading would cause contention
48 	 * between readers of EAs and writers of regular file data, so
49 	 * instead we synchronize on xattr_sem when reading or changing
50 	 * EAs.
51 	 */
52 	struct rw_semaphore xattr_sem;
53 #endif
54 #ifdef CONFIG_EXT2_FS_POSIX_ACL
55 	struct posix_acl	*i_acl;
56 	struct posix_acl	*i_default_acl;
57 #endif
58 	rwlock_t i_meta_lock;
59 	struct inode	vfs_inode;
60 };
61 
62 /*
63  * Inode dynamic state flags
64  */
65 #define EXT2_STATE_NEW			0x00000001 /* inode is newly created */
66 
67 
68 /*
69  * Function prototypes
70  */
71 
72 /*
73  * Ok, these declarations are also in <linux/kernel.h> but none of the
74  * ext2 source programs needs to include it so they are duplicated here.
75  */
76 
77 static inline struct ext2_inode_info *EXT2_I(struct inode *inode)
78 {
79 	return container_of(inode, struct ext2_inode_info, vfs_inode);
80 }
81 
82 /* balloc.c */
83 extern int ext2_bg_has_super(struct super_block *sb, int group);
84 extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
85 extern int ext2_new_block (struct inode *, unsigned long,
86 			   __u32 *, __u32 *, int *);
87 extern void ext2_free_blocks (struct inode *, unsigned long,
88 			      unsigned long);
89 extern unsigned long ext2_count_free_blocks (struct super_block *);
90 extern unsigned long ext2_count_dirs (struct super_block *);
91 extern void ext2_check_blocks_bitmap (struct super_block *);
92 extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
93 						    unsigned int block_group,
94 						    struct buffer_head ** bh);
95 
96 /* dir.c */
97 extern int ext2_add_link (struct dentry *, struct inode *);
98 extern ino_t ext2_inode_by_name(struct inode *, struct dentry *);
99 extern int ext2_make_empty(struct inode *, struct inode *);
100 extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **);
101 extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
102 extern int ext2_empty_dir (struct inode *);
103 extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
104 extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *);
105 
106 /* fsync.c */
107 extern int ext2_sync_file (struct file *, struct dentry *, int);
108 
109 /* ialloc.c */
110 extern struct inode * ext2_new_inode (struct inode *, int);
111 extern void ext2_free_inode (struct inode *);
112 extern unsigned long ext2_count_free_inodes (struct super_block *);
113 extern void ext2_check_inodes_bitmap (struct super_block *);
114 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
115 
116 /* inode.c */
117 extern void ext2_read_inode (struct inode *);
118 extern int ext2_write_inode (struct inode *, int);
119 extern void ext2_put_inode (struct inode *);
120 extern void ext2_delete_inode (struct inode *);
121 extern int ext2_sync_inode (struct inode *);
122 extern void ext2_discard_prealloc (struct inode *);
123 extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
124 extern void ext2_truncate (struct inode *);
125 extern int ext2_setattr (struct dentry *, struct iattr *);
126 extern void ext2_set_inode_flags(struct inode *inode);
127 
128 /* ioctl.c */
129 extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
130 		       unsigned long);
131 
132 /* super.c */
133 extern void ext2_error (struct super_block *, const char *, const char *, ...)
134 	__attribute__ ((format (printf, 3, 4)));
135 extern void ext2_warning (struct super_block *, const char *, const char *, ...)
136 	__attribute__ ((format (printf, 3, 4)));
137 extern void ext2_update_dynamic_rev (struct super_block *sb);
138 extern void ext2_write_super (struct super_block *);
139 
140 /*
141  * Inodes and files operations
142  */
143 
144 /* dir.c */
145 extern struct file_operations ext2_dir_operations;
146 
147 /* file.c */
148 extern struct inode_operations ext2_file_inode_operations;
149 extern struct file_operations ext2_file_operations;
150 
151 /* inode.c */
152 extern struct address_space_operations ext2_aops;
153 extern struct address_space_operations ext2_nobh_aops;
154 
155 /* namei.c */
156 extern struct inode_operations ext2_dir_inode_operations;
157 extern struct inode_operations ext2_special_inode_operations;
158 
159 /* symlink.c */
160 extern struct inode_operations ext2_fast_symlink_inode_operations;
161 extern struct inode_operations ext2_symlink_inode_operations;
162