More patch description fixups. Standardize case.
[ext4-patch-queue.git] / large-file-blocktype.patch
blobde9e64235df10d91f8fdcfc73e89bfbc5b10cf17
1 ext4: Introduce ext4_lblk_t
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 This patch adds a new data type ext4_lblk_t to represent
6 the logical file blocks.
8 This is the preparatory patch to support large files in ext4
9 The follow up patch with convert the ext4_inode i_blocks to
10 represent the number of blocks in file system block size. This
11 changes makes it possible to have a block number 2**32 -1 which
12 will result in overflow if the block number is represented by
13 signed long. This patch convert all the block number to type
14 ext4_lblk_t which is typedef to __u32
16 Also remove dead code ext4_ext_walk_space
18 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
19 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
20 Signed-off-by: Eric Sandeen <sandeen@redhat.com>
21 ---
23 fs/ext4/dir.c | 2
24 fs/ext4/extents.c | 218 +++++++++++-----------------------------
25 fs/ext4/inode.c | 34 +++---
26 fs/ext4/namei.c | 54 +++++----
27 fs/ext4/super.c | 4
28 include/linux/ext4_fs.h | 29 +++--
29 include/linux/ext4_fs_extents.h | 19 ---
30 include/linux/ext4_fs_i.h | 9 +
31 8 files changed, 143 insertions(+), 226 deletions(-)
34 Index: linux-2.6.24-rc7/fs/ext4/dir.c
35 ===================================================================
36 --- linux-2.6.24-rc7.orig/fs/ext4/dir.c 2008-01-15 11:34:23.000000000 -0800
37 +++ linux-2.6.24-rc7/fs/ext4/dir.c 2008-01-15 11:34:23.000000000 -0800
38 @@ -124,7 +124,7 @@ static int ext4_readdir(struct file * fi
39 offset = filp->f_pos & (sb->s_blocksize - 1);
41 while (!error && !stored && filp->f_pos < inode->i_size) {
42 - unsigned long blk = filp->f_pos >> EXT4_BLOCK_SIZE_BITS(sb);
43 + ext4_lblk_t blk = filp->f_pos >> EXT4_BLOCK_SIZE_BITS(sb);
44 struct buffer_head map_bh;
45 struct buffer_head *bh = NULL;
47 Index: linux-2.6.24-rc7/fs/ext4/extents.c
48 ===================================================================
49 --- linux-2.6.24-rc7.orig/fs/ext4/extents.c 2008-01-06 13:45:38.000000000 -0800
50 +++ linux-2.6.24-rc7/fs/ext4/extents.c 2008-01-16 13:48:31.000000000 -0800
51 @@ -144,7 +144,7 @@ static int ext4_ext_dirty(handle_t *hand
53 static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
54 struct ext4_ext_path *path,
55 - ext4_fsblk_t block)
56 + ext4_lblk_t block)
58 struct ext4_inode_info *ei = EXT4_I(inode);
59 ext4_fsblk_t bg_start;
60 @@ -367,13 +367,14 @@ static void ext4_ext_drop_refs(struct ex
61 * the header must be checked before calling this
63 static void
64 -ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int block)
65 +ext4_ext_binsearch_idx(struct inode *inode,
66 + struct ext4_ext_path *path, ext4_lblk_t block)
68 struct ext4_extent_header *eh = path->p_hdr;
69 struct ext4_extent_idx *r, *l, *m;
72 - ext_debug("binsearch for %d(idx): ", block);
73 + ext_debug("binsearch for %lu(idx): ", (unsigned long)block);
75 l = EXT_FIRST_INDEX(eh) + 1;
76 r = EXT_LAST_INDEX(eh);
77 @@ -425,7 +426,8 @@ ext4_ext_binsearch_idx(struct inode *ino
78 * the header must be checked before calling this
80 static void
81 -ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block)
82 +ext4_ext_binsearch(struct inode *inode,
83 + struct ext4_ext_path *path, ext4_lblk_t block)
85 struct ext4_extent_header *eh = path->p_hdr;
86 struct ext4_extent *r, *l, *m;
87 @@ -438,7 +440,7 @@ ext4_ext_binsearch(struct inode *inode,
88 return;
91 - ext_debug("binsearch for %d: ", block);
92 + ext_debug("binsearch for %lu: ", (unsigned long)block);
94 l = EXT_FIRST_EXTENT(eh) + 1;
95 r = EXT_LAST_EXTENT(eh);
96 @@ -494,7 +496,8 @@ int ext4_ext_tree_init(handle_t *handle,
99 struct ext4_ext_path *
100 -ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path)
101 +ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
102 + struct ext4_ext_path *path)
104 struct ext4_extent_header *eh;
105 struct buffer_head *bh;
106 @@ -979,8 +982,8 @@ repeat:
107 /* refill path */
108 ext4_ext_drop_refs(path);
109 path = ext4_ext_find_extent(inode,
110 - le32_to_cpu(newext->ee_block),
111 - path);
112 + (ext4_lblk_t)le32_to_cpu(newext->ee_block),
113 + path);
114 if (IS_ERR(path))
115 err = PTR_ERR(path);
116 } else {
117 @@ -992,8 +995,8 @@ repeat:
118 /* refill path */
119 ext4_ext_drop_refs(path);
120 path = ext4_ext_find_extent(inode,
121 - le32_to_cpu(newext->ee_block),
122 - path);
123 + (ext4_lblk_t)le32_to_cpu(newext->ee_block),
124 + path);
125 if (IS_ERR(path)) {
126 err = PTR_ERR(path);
127 goto out;
128 @@ -1021,7 +1024,7 @@ out:
129 * allocated block. Thus, index entries have to be consistent
130 * with leaves.
132 -static unsigned long
133 +static ext4_lblk_t
134 ext4_ext_next_allocated_block(struct ext4_ext_path *path)
136 int depth;
137 @@ -1054,7 +1057,7 @@ ext4_ext_next_allocated_block(struct ext
138 * ext4_ext_next_leaf_block:
139 * returns first allocated block from next leaf or EXT_MAX_BLOCK
141 -static unsigned ext4_ext_next_leaf_block(struct inode *inode,
142 +static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
143 struct ext4_ext_path *path)
145 int depth;
146 @@ -1072,7 +1075,8 @@ static unsigned ext4_ext_next_leaf_block
147 while (depth >= 0) {
148 if (path[depth].p_idx !=
149 EXT_LAST_INDEX(path[depth].p_hdr))
150 - return le32_to_cpu(path[depth].p_idx[1].ei_block);
151 + return (ext4_lblk_t)
152 + le32_to_cpu(path[depth].p_idx[1].ei_block);
153 depth--;
156 @@ -1239,7 +1243,7 @@ unsigned int ext4_ext_check_overlap(stru
157 struct ext4_extent *newext,
158 struct ext4_ext_path *path)
160 - unsigned long b1, b2;
161 + ext4_lblk_t b1, b2;
162 unsigned int depth, len1;
163 unsigned int ret = 0;
165 @@ -1260,7 +1264,7 @@ unsigned int ext4_ext_check_overlap(stru
166 goto out;
169 - /* check for wrap through zero */
170 + /* check for wrap through zero on extent logical start block*/
171 if (b1 + len1 < b1) {
172 len1 = EXT_MAX_BLOCK - b1;
173 newext->ee_len = cpu_to_le16(len1);
174 @@ -1290,7 +1294,8 @@ int ext4_ext_insert_extent(handle_t *han
175 struct ext4_extent *ex, *fex;
176 struct ext4_extent *nearex; /* nearest extent */
177 struct ext4_ext_path *npath = NULL;
178 - int depth, len, err, next;
179 + int depth, len, err;
180 + ext4_lblk_t next;
181 unsigned uninitialized = 0;
183 BUG_ON(ext4_ext_get_actual_len(newext) == 0);
184 @@ -1435,114 +1440,8 @@ cleanup:
185 return err;
188 -int ext4_ext_walk_space(struct inode *inode, unsigned long block,
189 - unsigned long num, ext_prepare_callback func,
190 - void *cbdata)
192 - struct ext4_ext_path *path = NULL;
193 - struct ext4_ext_cache cbex;
194 - struct ext4_extent *ex;
195 - unsigned long next, start = 0, end = 0;
196 - unsigned long last = block + num;
197 - int depth, exists, err = 0;
199 - BUG_ON(func == NULL);
200 - BUG_ON(inode == NULL);
202 - while (block < last && block != EXT_MAX_BLOCK) {
203 - num = last - block;
204 - /* find extent for this block */
205 - path = ext4_ext_find_extent(inode, block, path);
206 - if (IS_ERR(path)) {
207 - err = PTR_ERR(path);
208 - path = NULL;
209 - break;
212 - depth = ext_depth(inode);
213 - BUG_ON(path[depth].p_hdr == NULL);
214 - ex = path[depth].p_ext;
215 - next = ext4_ext_next_allocated_block(path);
217 - exists = 0;
218 - if (!ex) {
219 - /* there is no extent yet, so try to allocate
220 - * all requested space */
221 - start = block;
222 - end = block + num;
223 - } else if (le32_to_cpu(ex->ee_block) > block) {
224 - /* need to allocate space before found extent */
225 - start = block;
226 - end = le32_to_cpu(ex->ee_block);
227 - if (block + num < end)
228 - end = block + num;
229 - } else if (block >= le32_to_cpu(ex->ee_block)
230 - + ext4_ext_get_actual_len(ex)) {
231 - /* need to allocate space after found extent */
232 - start = block;
233 - end = block + num;
234 - if (end >= next)
235 - end = next;
236 - } else if (block >= le32_to_cpu(ex->ee_block)) {
237 - /*
238 - * some part of requested space is covered
239 - * by found extent
240 - */
241 - start = block;
242 - end = le32_to_cpu(ex->ee_block)
243 - + ext4_ext_get_actual_len(ex);
244 - if (block + num < end)
245 - end = block + num;
246 - exists = 1;
247 - } else {
248 - BUG();
250 - BUG_ON(end <= start);
252 - if (!exists) {
253 - cbex.ec_block = start;
254 - cbex.ec_len = end - start;
255 - cbex.ec_start = 0;
256 - cbex.ec_type = EXT4_EXT_CACHE_GAP;
257 - } else {
258 - cbex.ec_block = le32_to_cpu(ex->ee_block);
259 - cbex.ec_len = ext4_ext_get_actual_len(ex);
260 - cbex.ec_start = ext_pblock(ex);
261 - cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
264 - BUG_ON(cbex.ec_len == 0);
265 - err = func(inode, path, &cbex, cbdata);
266 - ext4_ext_drop_refs(path);
268 - if (err < 0)
269 - break;
270 - if (err == EXT_REPEAT)
271 - continue;
272 - else if (err == EXT_BREAK) {
273 - err = 0;
274 - break;
277 - if (ext_depth(inode) != depth) {
278 - /* depth was changed. we have to realloc path */
279 - kfree(path);
280 - path = NULL;
283 - block = cbex.ec_block + cbex.ec_len;
286 - if (path) {
287 - ext4_ext_drop_refs(path);
288 - kfree(path);
291 - return err;
294 static void
295 -ext4_ext_put_in_cache(struct inode *inode, __u32 block,
296 +ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
297 __u32 len, ext4_fsblk_t start, int type)
299 struct ext4_ext_cache *cex;
300 @@ -1561,10 +1460,11 @@ ext4_ext_put_in_cache(struct inode *inod
302 static void
303 ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
304 - unsigned long block)
305 + ext4_lblk_t block)
307 int depth = ext_depth(inode);
308 - unsigned long lblock, len;
309 + unsigned long len;
310 + ext4_lblk_t lblock;
311 struct ext4_extent *ex;
313 ex = path[depth].p_ext;
314 @@ -1582,15 +1482,17 @@ ext4_ext_put_gap_in_cache(struct inode *
315 (unsigned long) ext4_ext_get_actual_len(ex));
316 } else if (block >= le32_to_cpu(ex->ee_block)
317 + ext4_ext_get_actual_len(ex)) {
318 + ext4_lblk_t next;
319 lblock = le32_to_cpu(ex->ee_block)
320 + ext4_ext_get_actual_len(ex);
321 - len = ext4_ext_next_allocated_block(path);
323 + next = ext4_ext_next_allocated_block(path);
324 ext_debug("cache gap(after): [%lu:%lu] %lu",
325 (unsigned long) le32_to_cpu(ex->ee_block),
326 (unsigned long) ext4_ext_get_actual_len(ex),
327 (unsigned long) block);
328 - BUG_ON(len == lblock);
329 - len = len - lblock;
330 + BUG_ON(next == lblock);
331 + len = next - lblock;
332 } else {
333 lblock = len = 0;
334 BUG();
335 @@ -1601,7 +1503,7 @@ ext4_ext_put_gap_in_cache(struct inode *
338 static int
339 -ext4_ext_in_cache(struct inode *inode, unsigned long block,
340 +ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
341 struct ext4_extent *ex)
343 struct ext4_ext_cache *cex;
344 @@ -1714,7 +1616,7 @@ int ext4_ext_calc_credits_for_insert(str
346 static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
347 struct ext4_extent *ex,
348 - unsigned long from, unsigned long to)
349 + ext4_lblk_t from, ext4_lblk_t to)
351 struct buffer_head *bh;
352 unsigned short ee_len = ext4_ext_get_actual_len(ex);
353 @@ -1738,11 +1640,12 @@ static int ext4_remove_blocks(handle_t *
354 if (from >= le32_to_cpu(ex->ee_block)
355 && to == le32_to_cpu(ex->ee_block) + ee_len - 1) {
356 /* tail removal */
357 - unsigned long num;
358 + ext4_lblk_t num;
359 ext4_fsblk_t start;
361 num = le32_to_cpu(ex->ee_block) + ee_len - from;
362 start = ext_pblock(ex) + ee_len - num;
363 - ext_debug("free last %lu blocks starting %llu\n", num, start);
364 + ext_debug("free last %u blocks starting %llu\n", num, start);
365 for (i = 0; i < num; i++) {
366 bh = sb_find_get_block(inode->i_sb, start + i);
367 ext4_forget(handle, 0, inode, bh, start + i);
368 @@ -1750,30 +1653,32 @@ static int ext4_remove_blocks(handle_t *
369 ext4_free_blocks(handle, inode, start, num);
370 } else if (from == le32_to_cpu(ex->ee_block)
371 && to <= le32_to_cpu(ex->ee_block) + ee_len - 1) {
372 - printk("strange request: removal %lu-%lu from %u:%u\n",
373 + printk(KERN_INFO "strange request: removal %u-%u from %u:%u\n",
374 from, to, le32_to_cpu(ex->ee_block), ee_len);
375 } else {
376 - printk("strange request: removal(2) %lu-%lu from %u:%u\n",
377 - from, to, le32_to_cpu(ex->ee_block), ee_len);
378 + printk(KERN_INFO "strange request: removal(2) "
379 + "%u-%u from %u:%u\n",
380 + from, to, le32_to_cpu(ex->ee_block), ee_len);
382 return 0;
385 static int
386 ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
387 - struct ext4_ext_path *path, unsigned long start)
388 + struct ext4_ext_path *path, ext4_lblk_t start)
390 int err = 0, correct_index = 0;
391 int depth = ext_depth(inode), credits;
392 struct ext4_extent_header *eh;
393 - unsigned a, b, block, num;
394 - unsigned long ex_ee_block;
395 + ext4_lblk_t a, b, block;
396 + unsigned num;
397 + ext4_lblk_t ex_ee_block;
398 unsigned short ex_ee_len;
399 unsigned uninitialized = 0;
400 struct ext4_extent *ex;
402 /* the header must be checked already in ext4_ext_remove_space() */
403 - ext_debug("truncate since %lu in leaf\n", start);
404 + ext_debug("truncate since %u in leaf\n", start);
405 if (!path[depth].p_hdr)
406 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
407 eh = path[depth].p_hdr;
408 @@ -1904,7 +1809,7 @@ ext4_ext_more_to_rm(struct ext4_ext_path
409 return 1;
412 -int ext4_ext_remove_space(struct inode *inode, unsigned long start)
413 +int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start)
415 struct super_block *sb = inode->i_sb;
416 int depth = ext_depth(inode);
417 @@ -1912,7 +1817,7 @@ int ext4_ext_remove_space(struct inode *
418 handle_t *handle;
419 int i = 0, err = 0;
421 - ext_debug("truncate since %lu\n", start);
422 + ext_debug("truncate since %u\n", start);
424 /* probably first extent we're gonna free will be last in block */
425 handle = ext4_journal_start(inode, depth + 1);
426 @@ -2094,17 +1999,19 @@ void ext4_ext_release(struct super_block
427 * b> Splits in two extents: Write is happening at either end of the extent
428 * c> Splits in three extents: Somone is writing in middle of the extent
430 -int ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode,
431 - struct ext4_ext_path *path,
432 - ext4_fsblk_t iblock,
433 - unsigned long max_blocks)
434 +static int ext4_ext_convert_to_initialized(handle_t *handle,
435 + struct inode *inode,
436 + struct ext4_ext_path *path,
437 + ext4_lblk_t iblock,
438 + unsigned long max_blocks)
440 struct ext4_extent *ex, newex;
441 struct ext4_extent *ex1 = NULL;
442 struct ext4_extent *ex2 = NULL;
443 struct ext4_extent *ex3 = NULL;
444 struct ext4_extent_header *eh;
445 - unsigned int allocated, ee_block, ee_len, depth;
446 + ext4_lblk_t ee_block;
447 + unsigned int allocated, ee_len, depth;
448 ext4_fsblk_t newblock;
449 int err = 0;
450 int ret = 0;
451 @@ -2226,7 +2133,7 @@ out:
454 int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
455 - ext4_fsblk_t iblock,
456 + ext4_lblk_t iblock,
457 unsigned long max_blocks, struct buffer_head *bh_result,
458 int create, int extend_disksize)
460 @@ -2238,8 +2145,9 @@ int ext4_ext_get_blocks(handle_t *handle
461 unsigned long allocated = 0;
463 __clear_bit(BH_New, &bh_result->b_state);
464 - ext_debug("blocks %d/%lu requested for inode %u\n", (int) iblock,
465 - max_blocks, (unsigned) inode->i_ino);
466 + ext_debug("blocks %lu/%lu requested for inode %u\n",
467 + (unsigned long) iblock, max_blocks,
468 + (unsigned) inode->i_ino);
469 mutex_lock(&EXT4_I(inode)->truncate_mutex);
471 /* check in cache */
472 @@ -2288,7 +2196,7 @@ int ext4_ext_get_blocks(handle_t *handle
474 ex = path[depth].p_ext;
475 if (ex) {
476 - unsigned long ee_block = le32_to_cpu(ex->ee_block);
477 + ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block);
478 ext4_fsblk_t ee_start = ext_pblock(ex);
479 unsigned short ee_len;
481 @@ -2423,7 +2331,7 @@ void ext4_ext_truncate(struct inode * in
483 struct address_space *mapping = inode->i_mapping;
484 struct super_block *sb = inode->i_sb;
485 - unsigned long last_block;
486 + ext4_lblk_t last_block;
487 handle_t *handle;
488 int err = 0;
490 @@ -2516,7 +2424,8 @@ int ext4_ext_writepage_trans_blocks(stru
491 long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
493 handle_t *handle;
494 - ext4_fsblk_t block, max_blocks;
495 + ext4_lblk_t block;
496 + unsigned long max_blocks;
497 ext4_fsblk_t nblocks = 0;
498 int ret = 0;
499 int ret2 = 0;
500 @@ -2561,8 +2470,9 @@ retry:
501 if (!ret) {
502 ext4_error(inode->i_sb, "ext4_fallocate",
503 "ext4_ext_get_blocks returned 0! inode#%lu"
504 - ", block=%llu, max_blocks=%llu",
505 - inode->i_ino, block, max_blocks);
506 + ", block=%lu, max_blocks=%lu",
507 + inode->i_ino, (unsigned long)block,
508 + (unsigned long)max_blocks);
509 ret = -EIO;
510 ext4_mark_inode_dirty(handle, inode);
511 ret2 = ext4_journal_stop(handle);
512 Index: linux-2.6.24-rc7/fs/ext4/inode.c
513 ===================================================================
514 --- linux-2.6.24-rc7.orig/fs/ext4/inode.c 2008-01-06 13:45:38.000000000 -0800
515 +++ linux-2.6.24-rc7/fs/ext4/inode.c 2008-01-16 13:47:34.000000000 -0800
516 @@ -105,7 +105,7 @@ int ext4_forget(handle_t *handle, int is
518 static unsigned long blocks_for_truncate(struct inode *inode)
520 - unsigned long needed;
521 + ext4_lblk_t needed;
523 needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
525 @@ -282,7 +282,8 @@ static int verify_chain(Indirect *from,
528 static int ext4_block_to_path(struct inode *inode,
529 - long i_block, int offsets[4], int *boundary)
530 + ext4_lblk_t i_block,
531 + ext4_lblk_t offsets[4], int *boundary)
533 int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb);
534 int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb);
535 @@ -349,7 +350,8 @@ static int ext4_block_to_path(struct ino
536 * or when it reads all @depth-1 indirect blocks successfully and finds
537 * the whole chain, all way to the data (returns %NULL, *err == 0).
539 -static Indirect *ext4_get_branch(struct inode *inode, int depth, int *offsets,
540 +static Indirect *ext4_get_branch(struct inode *inode, int depth,
541 + ext4_lblk_t *offsets,
542 Indirect chain[4], int *err)
544 struct super_block *sb = inode->i_sb;
545 @@ -445,7 +447,7 @@ static ext4_fsblk_t ext4_find_near(struc
546 * stores it in *@goal and returns zero.
549 -static ext4_fsblk_t ext4_find_goal(struct inode *inode, long block,
550 +static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block,
551 Indirect chain[4], Indirect *partial)
553 struct ext4_block_alloc_info *block_i;
554 @@ -590,7 +592,7 @@ failed_out:
556 static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
557 int indirect_blks, int *blks, ext4_fsblk_t goal,
558 - int *offsets, Indirect *branch)
559 + ext4_lblk_t *offsets, Indirect *branch)
561 int blocksize = inode->i_sb->s_blocksize;
562 int i, n = 0;
563 @@ -680,7 +682,7 @@ failed:
564 * chain to new block and return 0.
566 static int ext4_splice_branch(handle_t *handle, struct inode *inode,
567 - long block, Indirect *where, int num, int blks)
568 + ext4_lblk_t block, Indirect *where, int num, int blks)
570 int i;
571 int err = 0;
572 @@ -784,12 +786,12 @@ err_out:
573 * return < 0, error case.
575 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
576 - sector_t iblock, unsigned long maxblocks,
577 + ext4_lblk_t iblock, unsigned long maxblocks,
578 struct buffer_head *bh_result,
579 int create, int extend_disksize)
581 int err = -EIO;
582 - int offsets[4];
583 + ext4_lblk_t offsets[4];
584 Indirect chain[4];
585 Indirect *partial;
586 ext4_fsblk_t goal;
587 @@ -803,7 +805,8 @@ int ext4_get_blocks_handle(handle_t *han
589 J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
590 J_ASSERT(handle != NULL || create == 0);
591 - depth = ext4_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
592 + depth = ext4_block_to_path(inode, iblock, offsets,
593 + &blocks_to_boundary);
595 if (depth == 0)
596 goto out;
597 @@ -996,7 +999,7 @@ get_block:
598 * `handle' can be NULL if create is zero
600 struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
601 - long block, int create, int *errp)
602 + ext4_lblk_t block, int create, int *errp)
604 struct buffer_head dummy;
605 int fatal = 0, err;
606 @@ -1063,7 +1066,7 @@ err:
609 struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
610 - int block, int create, int *err)
611 + ext4_lblk_t block, int create, int *err)
613 struct buffer_head * bh;
615 @@ -1828,7 +1831,8 @@ int ext4_block_truncate_page(handle_t *h
617 ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
618 unsigned offset = from & (PAGE_CACHE_SIZE-1);
619 - unsigned blocksize, iblock, length, pos;
620 + unsigned blocksize, length, pos;
621 + ext4_lblk_t iblock;
622 struct inode *inode = mapping->host;
623 struct buffer_head *bh;
624 int err = 0;
625 @@ -1964,7 +1968,7 @@ static inline int all_zeroes(__le32 *p,
626 * (no partially truncated stuff there). */
628 static Indirect *ext4_find_shared(struct inode *inode, int depth,
629 - int offsets[4], Indirect chain[4], __le32 *top)
630 + ext4_lblk_t offsets[4], Indirect chain[4], __le32 *top)
632 Indirect *partial, *p;
633 int k, err;
634 @@ -2289,12 +2293,12 @@ void ext4_truncate(struct inode *inode)
635 __le32 *i_data = ei->i_data;
636 int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
637 struct address_space *mapping = inode->i_mapping;
638 - int offsets[4];
639 + ext4_lblk_t offsets[4];
640 Indirect chain[4];
641 Indirect *partial;
642 __le32 nr = 0;
643 int n;
644 - long last_block;
645 + ext4_lblk_t last_block;
646 unsigned blocksize = inode->i_sb->s_blocksize;
647 struct page *page;
649 Index: linux-2.6.24-rc7/fs/ext4/namei.c
650 ===================================================================
651 --- linux-2.6.24-rc7.orig/fs/ext4/namei.c 2008-01-15 11:34:23.000000000 -0800
652 +++ linux-2.6.24-rc7/fs/ext4/namei.c 2008-01-16 13:47:30.000000000 -0800
653 @@ -51,7 +51,7 @@
655 static struct buffer_head *ext4_append(handle_t *handle,
656 struct inode *inode,
657 - u32 *block, int *err)
658 + ext4_lblk_t *block, int *err)
660 struct buffer_head *bh;
662 @@ -144,8 +144,8 @@ struct dx_map_entry
663 u16 size;
666 -static inline unsigned dx_get_block (struct dx_entry *entry);
667 -static void dx_set_block (struct dx_entry *entry, unsigned value);
668 +static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
669 +static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
670 static inline unsigned dx_get_hash (struct dx_entry *entry);
671 static void dx_set_hash (struct dx_entry *entry, unsigned value);
672 static unsigned dx_get_count (struct dx_entry *entries);
673 @@ -166,7 +166,8 @@ static void dx_sort_map(struct dx_map_en
674 static struct ext4_dir_entry_2 *dx_move_dirents (char *from, char *to,
675 struct dx_map_entry *offsets, int count);
676 static struct ext4_dir_entry_2* dx_pack_dirents (char *base, int size);
677 -static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block);
678 +static void dx_insert_block(struct dx_frame *frame,
679 + u32 hash, ext4_lblk_t block);
680 static int ext4_htree_next_block(struct inode *dir, __u32 hash,
681 struct dx_frame *frame,
682 struct dx_frame *frames,
683 @@ -181,12 +182,12 @@ static int ext4_dx_add_entry(handle_t *h
684 * Mask them off for now.
687 -static inline unsigned dx_get_block (struct dx_entry *entry)
688 +static inline ext4_lblk_t dx_get_block(struct dx_entry *entry)
690 return le32_to_cpu(entry->block) & 0x00ffffff;
693 -static inline void dx_set_block (struct dx_entry *entry, unsigned value)
694 +static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value)
696 entry->block = cpu_to_le32(value);
698 @@ -243,8 +244,8 @@ static void dx_show_index (char * label,
699 int i, n = dx_get_count (entries);
700 printk("%s index ", label);
701 for (i = 0; i < n; i++) {
702 - printk("%x->%u ", i? dx_get_hash(entries + i) :
703 - 0, dx_get_block(entries + i));
704 + printk("%x->%lu ", i? dx_get_hash(entries + i) :
705 + 0, (unsigned long)dx_get_block(entries + i));
707 printk("\n");
709 @@ -297,7 +298,8 @@ struct stats dx_show_entries(struct dx_h
710 printk("%i indexed blocks...\n", count);
711 for (i = 0; i < count; i++, entries++)
713 - u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0;
714 + ext4_lblk_t block = dx_get_block(entries);
715 + ext4_lblk_t hash = i ? dx_get_hash(entries): 0;
716 u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash;
717 struct stats stats;
718 printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range);
719 @@ -561,7 +563,7 @@ static inline struct ext4_dir_entry_2 *e
720 * into the tree. If there is an error it is returned in err.
722 static int htree_dirblock_to_tree(struct file *dir_file,
723 - struct inode *dir, int block,
724 + struct inode *dir, ext4_lblk_t block,
725 struct dx_hash_info *hinfo,
726 __u32 start_hash, __u32 start_minor_hash)
728 @@ -569,7 +571,8 @@ static int htree_dirblock_to_tree(struct
729 struct ext4_dir_entry_2 *de, *top;
730 int err, count = 0;
732 - dxtrace(printk("In htree dirblock_to_tree: block %d\n", block));
733 + dxtrace(printk(KERN_INFO "In htree dirblock_to_tree: block %lu\n",
734 + (unsigned long)block));
735 if (!(bh = ext4_bread (NULL, dir, block, 0, &err)))
736 return err;
738 @@ -621,9 +624,9 @@ int ext4_htree_fill_tree(struct file *di
739 struct ext4_dir_entry_2 *de;
740 struct dx_frame frames[2], *frame;
741 struct inode *dir;
742 - int block, err;
743 + ext4_lblk_t block;
744 int count = 0;
745 - int ret;
746 + int ret, err;
747 __u32 hashval;
749 dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
750 @@ -753,7 +756,7 @@ static void dx_sort_map (struct dx_map_e
751 } while(more);
754 -static void dx_insert_block(struct dx_frame *frame, u32 hash, u32 block)
755 +static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block)
757 struct dx_entry *entries = frame->entries;
758 struct dx_entry *old = frame->at, *new = old + 1;
759 @@ -848,13 +851,14 @@ static struct buffer_head * ext4_find_en
760 struct super_block * sb;
761 struct buffer_head * bh_use[NAMEI_RA_SIZE];
762 struct buffer_head * bh, *ret = NULL;
763 - unsigned long start, block, b;
764 + ext4_lblk_t start, block, b;
765 int ra_max = 0; /* Number of bh's in the readahead
766 buffer, bh_use[] */
767 int ra_ptr = 0; /* Current index into readahead
768 buffer */
769 int num = 0;
770 - int nblocks, i, err;
771 + ext4_lblk_t nblocks;
772 + int i, err;
773 struct inode *dir = dentry->d_parent->d_inode;
774 int namelen;
775 const u8 *name;
776 @@ -915,7 +919,8 @@ restart:
777 if (!buffer_uptodate(bh)) {
778 /* read error, skip block & hope for the best */
779 ext4_error(sb, __FUNCTION__, "reading directory #%lu "
780 - "offset %lu", dir->i_ino, block);
781 + "offset %lu", dir->i_ino,
782 + (unsigned long)block);
783 brelse(bh);
784 goto next;
786 @@ -962,7 +967,7 @@ static struct buffer_head * ext4_dx_find
787 struct dx_frame frames[2], *frame;
788 struct ext4_dir_entry_2 *de, *top;
789 struct buffer_head *bh;
790 - unsigned long block;
791 + ext4_lblk_t block;
792 int retval;
793 int namelen = dentry->d_name.len;
794 const u8 *name = dentry->d_name.name;
795 @@ -1174,7 +1179,7 @@ static struct ext4_dir_entry_2 *do_split
796 unsigned blocksize = dir->i_sb->s_blocksize;
797 unsigned count, continued;
798 struct buffer_head *bh2;
799 - u32 newblock;
800 + ext4_lblk_t newblock;
801 u32 hash2;
802 struct dx_map_entry *map;
803 char *data1 = (*bh)->b_data, *data2;
804 @@ -1221,8 +1226,9 @@ static struct ext4_dir_entry_2 *do_split
805 split = count - move;
806 hash2 = map[split].hash;
807 continued = hash2 == map[split - 1].hash;
808 - dxtrace(printk("Split block %i at %x, %i/%i\n",
809 - dx_get_block(frame->at), hash2, split, count-split));
810 + dxtrace(printk(KERN_INFO "Split block %lu at %x, %i/%i\n",
811 + (unsigned long)dx_get_block(frame->at),
812 + hash2, split, count-split));
814 /* Fancy dance to stay within two buffers */
815 de2 = dx_move_dirents(data1, data2, map + split, count - split);
816 @@ -1374,7 +1380,7 @@ static int make_indexed_dir(handle_t *ha
817 int retval;
818 unsigned blocksize;
819 struct dx_hash_info hinfo;
820 - u32 block;
821 + ext4_lblk_t block;
822 struct fake_dirent *fde;
824 blocksize = dir->i_sb->s_blocksize;
825 @@ -1455,7 +1461,7 @@ static int ext4_add_entry (handle_t *han
826 int retval;
827 int dx_fallback=0;
828 unsigned blocksize;
829 - u32 block, blocks;
830 + ext4_lblk_t block, blocks;
832 sb = dir->i_sb;
833 blocksize = sb->s_blocksize;
834 @@ -1532,7 +1538,7 @@ static int ext4_dx_add_entry(handle_t *h
835 dx_get_count(entries), dx_get_limit(entries)));
836 /* Need to split index? */
837 if (dx_get_count(entries) == dx_get_limit(entries)) {
838 - u32 newblock;
839 + ext4_lblk_t newblock;
840 unsigned icount = dx_get_count(entries);
841 int levels = frame - frames;
842 struct dx_entry *entries2;
843 Index: linux-2.6.24-rc7/fs/ext4/super.c
844 ===================================================================
845 --- linux-2.6.24-rc7.orig/fs/ext4/super.c 2008-01-15 11:34:23.000000000 -0800
846 +++ linux-2.6.24-rc7/fs/ext4/super.c 2008-01-16 13:47:34.000000000 -0800
847 @@ -2914,7 +2914,7 @@ static ssize_t ext4_quota_read(struct su
848 size_t len, loff_t off)
850 struct inode *inode = sb_dqopt(sb)->files[type];
851 - sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
852 + ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
853 int err = 0;
854 int offset = off & (sb->s_blocksize - 1);
855 int tocopy;
856 @@ -2952,7 +2952,7 @@ static ssize_t ext4_quota_write(struct s
857 const char *data, size_t len, loff_t off)
859 struct inode *inode = sb_dqopt(sb)->files[type];
860 - sector_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
861 + ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
862 int err = 0;
863 int offset = off & (sb->s_blocksize - 1);
864 int tocopy;
865 Index: linux-2.6.24-rc7/include/linux/ext4_fs.h
866 ===================================================================
867 --- linux-2.6.24-rc7.orig/include/linux/ext4_fs.h 2008-01-15 11:34:23.000000000 -0800
868 +++ linux-2.6.24-rc7/include/linux/ext4_fs.h 2008-01-16 13:47:34.000000000 -0800
869 @@ -935,11 +935,14 @@ extern unsigned long ext4_count_free (st
870 /* inode.c */
871 int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
872 struct buffer_head *bh, ext4_fsblk_t blocknr);
873 -struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *);
874 -struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *);
875 +struct buffer_head *ext4_getblk(handle_t *, struct inode *,
876 + ext4_lblk_t, int, int *);
877 +struct buffer_head *ext4_bread(handle_t *, struct inode *,
878 + ext4_lblk_t, int, int *);
879 int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
880 - sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
881 - int create, int extend_disksize);
882 + ext4_lblk_t iblock, unsigned long maxblocks,
883 + struct buffer_head *bh_result,
884 + int create, int extend_disksize);
886 extern void ext4_read_inode (struct inode *);
887 extern int ext4_write_inode (struct inode *, int);
888 @@ -1068,7 +1071,7 @@ extern const struct inode_operations ext
889 extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
890 extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
891 extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
892 - ext4_fsblk_t iblock,
893 + ext4_lblk_t iblock,
894 unsigned long max_blocks, struct buffer_head *bh_result,
895 int create, int extend_disksize);
896 extern void ext4_ext_truncate(struct inode *, struct page *);
897 @@ -1081,11 +1084,17 @@ ext4_get_blocks_wrap(handle_t *handle, s
898 unsigned long max_blocks, struct buffer_head *bh,
899 int create, int extend_disksize)
901 - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
902 - return ext4_ext_get_blocks(handle, inode, block, max_blocks,
903 - bh, create, extend_disksize);
904 - return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
905 - create, extend_disksize);
906 + int retval;
907 + if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {
908 + retval = ext4_ext_get_blocks(handle, inode,
909 + (ext4_lblk_t)block, max_blocks,
910 + bh, create, extend_disksize);
911 + } else {
912 + retval = ext4_get_blocks_handle(handle, inode,
913 + (ext4_lblk_t)block, max_blocks,
914 + bh, create, extend_disksize);
916 + return retval;
920 Index: linux-2.6.24-rc7/include/linux/ext4_fs_extents.h
921 ===================================================================
922 --- linux-2.6.24-rc7.orig/include/linux/ext4_fs_extents.h 2008-01-06 13:45:38.000000000 -0800
923 +++ linux-2.6.24-rc7/include/linux/ext4_fs_extents.h 2008-01-16 13:47:27.000000000 -0800
924 @@ -124,20 +124,6 @@ struct ext4_ext_path {
925 #define EXT4_EXT_CACHE_GAP 1
926 #define EXT4_EXT_CACHE_EXTENT 2
929 - * to be called by ext4_ext_walk_space()
930 - * negative retcode - error
931 - * positive retcode - signal for ext4_ext_walk_space(), see below
932 - * callback must return valid extent (passed or newly created)
933 - */
934 -typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
935 - struct ext4_ext_cache *,
936 - void *);
938 -#define EXT_CONTINUE 0
939 -#define EXT_BREAK 1
940 -#define EXT_REPEAT 2
943 #define EXT_MAX_BLOCK 0xffffffff
945 @@ -233,8 +219,7 @@ extern int ext4_ext_try_to_merge(struct
946 struct ext4_extent *);
947 extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
948 extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
949 -extern int ext4_ext_walk_space(struct inode *, unsigned long, unsigned long, ext_prepare_callback, void *);
950 -extern struct ext4_ext_path * ext4_ext_find_extent(struct inode *, int, struct ext4_ext_path *);
952 +extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
953 + struct ext4_ext_path *);
954 #endif /* _LINUX_EXT4_EXTENTS */
956 Index: linux-2.6.24-rc7/include/linux/ext4_fs_i.h
957 ===================================================================
958 --- linux-2.6.24-rc7.orig/include/linux/ext4_fs_i.h 2008-01-06 13:45:38.000000000 -0800
959 +++ linux-2.6.24-rc7/include/linux/ext4_fs_i.h 2008-01-16 13:47:34.000000000 -0800
960 @@ -27,6 +27,9 @@ typedef int ext4_grpblk_t;
961 /* data type for filesystem-wide blocks number */
962 typedef unsigned long long ext4_fsblk_t;
964 +/* data type for file logical block number */
965 +typedef __u32 ext4_lblk_t;
967 struct ext4_reserve_window {
968 ext4_fsblk_t _rsv_start; /* First byte reserved */
969 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
970 @@ -48,7 +51,7 @@ struct ext4_block_alloc_info {
971 * most-recently-allocated block in this file.
972 * We use this for detecting linearly ascending allocation requests.
974 - __u32 last_alloc_logical_block;
975 + ext4_lblk_t last_alloc_logical_block;
977 * Was i_next_alloc_goal in ext4_inode_info
978 * is the *physical* companion to i_next_alloc_block.
979 @@ -67,7 +70,7 @@ struct ext4_block_alloc_info {
981 struct ext4_ext_cache {
982 ext4_fsblk_t ec_start;
983 - __u32 ec_block;
984 + ext4_lblk_t ec_block;
985 __u32 ec_len; /* must be 32bit to return holes */
986 __u32 ec_type;
988 @@ -95,7 +98,7 @@ struct ext4_inode_info {
989 /* block reservation info */
990 struct ext4_block_alloc_info *i_block_alloc_info;
992 - __u32 i_dir_start_lookup;
993 + ext4_lblk_t i_dir_start_lookup;
994 #ifdef CONFIG_EXT4DEV_FS_XATTR
996 * Extended attributes can be read independently of the main file