More patch description fixups. Standardize case.
[ext4-patch-queue.git] / ext4-online-defrag-header-changes.patch
bloba00f47ec6b248eb02825497b3f14735185f891d5
1 ext4: online defrad header file changes
2 From: Akira Fujita <a-fujita@rs.jp.nec.com>
4 Ext4 online defrag has the following three functions.
6 1.[ no option ] Solving a single file fragmentation
7 Single file fragmentation is solved by moving file
8 data to contiguous free blocks.
10 2.[ -r ] Solving a relevant file fragmentation
11 Relevant file fragmentation is solved by moving
12 the files under the specified directory closer together.
14 3.[ -f ] Solving a free space fragmentation
15 If there is no contiguous free blocks in the filesystem,
16 the other files are moved to make sufficient space to allocate
17 contiguous blocks for the target file.
19 Current status:
20 These patches are at the experimental stage so they have some
21 items to improve. But these are worth enough to examine my trial.
23 Dependencies:
24 My patches depend on the multi-block allocation in ext4 patch queue.
26 Outstanding issues:
27 Nothing for the moment.
29 Next steps:
30 - Make carry out movement of data as atomic transaction.
32 Summary of patches:
33 *These patches are applied on the top of
34 ext4 git tree(linux-2.6.24-rc5).
35 http://repo.or.cz/r/ext4-patch-queue.git
37 [PATCH 1/5] ext4 online defrag header file changes
38 - Header file changes used by online defrag.
40 [PATCH 2/5] Allocate new contiguous blocks with mballoc
41 - Search contiguous free blocks and allocate them for the temporary
42 inode with the multi-block allocation.
44 [PATCH 3/5] Move the file data to the new blocks
45 - Move the blocks on the temporary inode to the original inode
46 by a page.
48 [PATCH 4/5] Free space fragmentation functions
49 - Defrag tries to move other files to make sufficient space
50 and reallocates the contiguous blocks for the target file.
52 [PATCH 5/5] Online defrag command
53 - The defrag command. Usage is as follows:
54 o Put the multiple files closer together.
55 # e4defrag -r directory-name
56 o Defrag for free space fragmentation.
57 # e4defrag -f file-name
58 o Defrag for a single file.
59 # e4defrag file-name
60 o Defrag for all files on ext4.
61 # e4defrag device-name
63 Header file changes used by online defrag.
65 Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
66 Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
67 ---
68 ---
69 fs/ext4/Makefile | 2 -
70 include/linux/ext4_fs.h | 71 ++++++++++++++++++++++++++++++++++++++++
71 include/linux/ext4_fs_extents.h | 22 ++++++++++++
72 3 files changed, 94 insertions(+), 1 deletion(-)
74 Index: linux-2.6.24-rc7/fs/ext4/Makefile
75 ===================================================================
76 --- linux-2.6.24-rc7.orig/fs/ext4/Makefile 2008-01-16 13:52:19.000000000 -0800
77 +++ linux-2.6.24-rc7/fs/ext4/Makefile 2008-01-16 14:01:10.000000000 -0800
78 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
80 ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
81 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
82 - ext4_jbd2.o migrate.o mballoc.o
83 + ext4_jbd2.o migrate.o mballoc.o defrag.o
85 ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
86 ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
87 Index: linux-2.6.24-rc7/include/linux/ext4_fs.h
88 ===================================================================
89 --- linux-2.6.24-rc7.orig/include/linux/ext4_fs.h 2008-01-16 13:52:51.000000000 -0800
90 +++ linux-2.6.24-rc7/include/linux/ext4_fs.h 2008-01-16 14:38:02.000000000 -0800
91 @@ -95,6 +95,7 @@ struct ext4_allocation_request {
92 unsigned long len;
93 /* flags. see above EXT4_MB_HINT_* */
94 unsigned long flags;
95 + long long excepted_group;
99 @@ -299,6 +300,17 @@ struct ext4_new_group_data {
100 #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
101 #define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
102 #define EXT4_IOC_MIGRATE _IO('f', 7)
103 +#define EXT4_IOC_GET_EXTENTS _IOR('f', 7, long)
104 +#define EXT4_IOC_GET_TREE_DEPTH _IOR('f', 8, long)
105 +#define EXT4_IOC_GET_TREE_STATS _IOR('f', 9, long)
106 +#define EXT4_IOC_FIBMAP _IOW('f', 9, ext4_fsblk_t)
107 +#define EXT4_IOC_DEFRAG _IOW('f', 10, struct ext4_ext_defrag_data)
108 +#define EXT4_IOC_GROUP_INFO _IOW('f', 11, struct ext4_group_data_info)
109 +#define EXT4_IOC_FREE_BLOCKS_INFO _IOW('f', 12, struct ext4_extents_info)
110 +#define EXT4_IOC_EXTENTS_INFO _IOW('f', 13, struct ext4_extents_info)
111 +#define EXT4_IOC_RESERVE_BLOCK _IOW('f', 14, struct ext4_extents_info)
112 +#define EXT4_IOC_MOVE_VICTIM _IOW('f', 15, struct ext4_extents_info)
113 +#define EXT4_IOC_BLOCK_RELEASE _IO('f', 16)
116 * ioctl commands in 32 bit emulation
117 @@ -316,6 +328,42 @@ struct ext4_new_group_data {
118 #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
119 #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
121 +/* Used for defrag */
122 +#define DEFRAG_MAX_ENT 32
123 +#define DEFRAG_FORCE_TRY 1
124 +#define DEFRAG_FORCE_VICTIM 2
125 +#define DEFRAG_FORCE_GATHER 3
127 +struct ext4_extent_data {
128 + ext4_lblk_t block; /* start logical block number */
129 + ext4_fsblk_t start; /* start physical block number */
130 + int len; /* blocks count */
133 +struct ext4_ext_defrag_data {
134 + ext4_lblk_t start_offset; /* start offset to defrag in blocks */
135 + ext4_lblk_t defrag_size; /* size of defrag in blocks */
136 + ext4_fsblk_t goal; /* block offset for allocation */
137 + int flag; /* free space mode flag */
138 + struct ext4_extent_data ext;
141 +struct ext4_group_data_info {
142 + int s_blocks_per_group; /* blocks per group */
143 + int s_inodes_per_group; /* inodes per group */
146 +struct ext4_extents_info {
147 + unsigned long long ino; /* inode number */
148 + int max_entries; /* maximum extents count */
149 + int entries; /* extent number/count */
150 + ext4_lblk_t f_offset; /* file offset */
151 + ext4_grpblk_t g_offset; /* group offset */
152 + ext4_fsblk_t goal; /* block offset for allocation */
153 + struct ext4_extent_data ext[DEFRAG_MAX_ENT];
156 +#define EXT4_TRANS_META_BLOCKS 4 /* bitmap + group desc + sb + inode */
159 * Mount options
160 @@ -984,6 +1032,17 @@ extern struct ext4_group_desc * ext4_get
161 extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
162 extern void ext4_init_block_alloc_info(struct inode *);
163 extern void ext4_rsv_window_add(struct super_block *sb, struct ext4_reserve_window_node *rsv);
164 +extern void try_to_extend_reservation(struct ext4_reserve_window_node *,
165 + struct super_block *, int);
166 +extern int alloc_new_reservation(struct ext4_reserve_window_node *,
167 + ext4_grpblk_t, struct super_block *,
168 + ext4_group_t, struct buffer_head *);
169 +extern ext4_grpblk_t bitmap_search_next_usable_block(ext4_grpblk_t,
170 + struct buffer_head *, ext4_grpblk_t);
171 +extern int rsv_is_empty(struct ext4_reserve_window *rsv);
172 +extern int goal_in_my_reservation(struct ext4_reserve_window *rsv,
173 + ext4_grpblk_t grp_goal, ext4_group_t group,
174 + struct super_block *sb);
176 /* dir.c */
177 extern int ext4_check_dir_entry(const char *, struct inode *,
178 @@ -993,6 +1052,7 @@ extern int ext4_htree_store_dirent(struc
179 __u32 minor_hash,
180 struct ext4_dir_entry_2 *dirent);
181 extern void ext4_htree_free_dir_info(struct dir_private_info *p);
182 +extern sector_t ext4_bmap(struct address_space *mapping, sector_t block);
184 /* fsync.c */
185 extern int ext4_sync_file (struct file *, struct dentry *, int);
186 @@ -1053,6 +1113,8 @@ extern void ext4_set_aops(struct inode *
187 extern int ext4_writepage_trans_blocks(struct inode *);
188 extern int ext4_block_truncate_page(handle_t *handle, struct page *page,
189 struct address_space *mapping, loff_t from);
190 +extern int ext4_get_block(struct inode *inode, sector_t iblock,
191 + struct buffer_head *bh_result, int create);
193 /* ioctl.c */
194 extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
195 @@ -1102,6 +1164,14 @@ extern void ext4_inode_bitmap_set(struct
196 struct ext4_group_desc *bg, ext4_fsblk_t blk);
197 extern void ext4_inode_table_set(struct super_block *sb,
198 struct ext4_group_desc *bg, ext4_fsblk_t blk);
199 +/* extents.c */
200 +extern handle_t *ext4_ext_journal_restart(handle_t *handle, int needed);
201 +/* defrag.c */
202 +extern int ext4_ext_defrag(struct file *filp, ext4_lblk_t block_start,
203 + ext4_lblk_t defrag_size, ext4_fsblk_t goal,
204 + int flag, struct ext4_extent_data *ext);
205 +extern int ext4_ext_ioctl(struct inode *, struct file *, unsigned int,
206 + unsigned long);
208 static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
210 @@ -1219,6 +1289,7 @@ extern int ext4_get_blocks_wrap(handle_t
211 sector_t block, unsigned long max_blocks,
212 struct buffer_head *bh, int create,
213 int extend_disksize);
214 +extern int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start);
215 #endif /* __KERNEL__ */
217 #endif /* _LINUX_EXT4_FS_H */
218 Index: linux-2.6.24-rc7/include/linux/ext4_fs_extents.h
219 ===================================================================
220 --- linux-2.6.24-rc7.orig/include/linux/ext4_fs_extents.h 2008-01-16 13:52:18.000000000 -0800
221 +++ linux-2.6.24-rc7/include/linux/ext4_fs_extents.h 2008-01-16 14:01:10.000000000 -0800
222 @@ -124,6 +124,19 @@ struct ext4_ext_path {
223 #define EXT4_EXT_CACHE_GAP 1
224 #define EXT4_EXT_CACHE_EXTENT 2
227 + * to be called by ext4_ext_walk_space()
228 + * negative retcode - error
229 + * positive retcode - signal for ext4_ext_walk_space(), see below
230 + * callback must return valid extent (passed or newly created)
231 + */
232 +typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
233 + struct ext4_ext_cache *,
234 + void *);
236 +#define EXT_CONTINUE 0
237 +#define EXT_BREAK 1
238 +#define EXT_REPEAT 2
240 #define EXT_MAX_BLOCK 0xffffffff
242 @@ -225,5 +238,14 @@ extern int ext4_ext_search_left(struct i
243 ext4_lblk_t *, ext4_fsblk_t *);
244 extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
245 ext4_lblk_t *, ext4_fsblk_t *);
246 +extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
247 +extern void ext4_ext_drop_refs(struct ext4_ext_path *path);
248 +extern ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
249 + struct ext4_ext_path *path,
250 + ext4_lblk_t block);
251 +extern int ext4_ext_insert_extent_defrag(handle_t *handle, struct inode *inode,
252 + struct ext4_ext_path *path,
253 + struct ext4_extent *newext, int defrag);
254 +extern ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path);
255 #endif /* _LINUX_EXT4_EXTENTS */