diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 281 |
1 files changed, 121 insertions, 160 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 875db944b22f..7c17ae275af4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -37,11 +37,14 @@ | |||
37 | #include <linux/namei.h> | 37 | #include <linux/namei.h> |
38 | #include <linux/uio.h> | 38 | #include <linux/uio.h> |
39 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
40 | |||
40 | #include "ext4_jbd2.h" | 41 | #include "ext4_jbd2.h" |
41 | #include "xattr.h" | 42 | #include "xattr.h" |
42 | #include "acl.h" | 43 | #include "acl.h" |
43 | #include "ext4_extents.h" | 44 | #include "ext4_extents.h" |
44 | 45 | ||
46 | #include <trace/events/ext4.h> | ||
47 | |||
45 | #define MPAGE_DA_EXTENT_TAIL 0x01 | 48 | #define MPAGE_DA_EXTENT_TAIL 0x01 |
46 | 49 | ||
47 | static inline int ext4_begin_ordered_truncate(struct inode *inode, | 50 | static inline int ext4_begin_ordered_truncate(struct inode *inode, |
@@ -78,7 +81,7 @@ static int ext4_inode_is_fast_symlink(struct inode *inode) | |||
78 | * If the handle isn't valid we're not journaling so there's nothing to do. | 81 | * If the handle isn't valid we're not journaling so there's nothing to do. |
79 | */ | 82 | */ |
80 | int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, | 83 | int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, |
81 | struct buffer_head *bh, ext4_fsblk_t blocknr) | 84 | struct buffer_head *bh, ext4_fsblk_t blocknr) |
82 | { | 85 | { |
83 | int err; | 86 | int err; |
84 | 87 | ||
@@ -90,7 +93,7 @@ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, | |||
90 | BUFFER_TRACE(bh, "enter"); | 93 | BUFFER_TRACE(bh, "enter"); |
91 | 94 | ||
92 | jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, " | 95 | jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, " |
93 | "data mode %lx\n", | 96 | "data mode %x\n", |
94 | bh, is_metadata, inode->i_mode, | 97 | bh, is_metadata, inode->i_mode, |
95 | test_opt(inode->i_sb, DATA_FLAGS)); | 98 | test_opt(inode->i_sb, DATA_FLAGS)); |
96 | 99 | ||
@@ -329,8 +332,8 @@ static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v) | |||
329 | */ | 332 | */ |
330 | 333 | ||
331 | static int ext4_block_to_path(struct inode *inode, | 334 | static int ext4_block_to_path(struct inode *inode, |
332 | ext4_lblk_t i_block, | 335 | ext4_lblk_t i_block, |
333 | ext4_lblk_t offsets[4], int *boundary) | 336 | ext4_lblk_t offsets[4], int *boundary) |
334 | { | 337 | { |
335 | int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb); | 338 | int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb); |
336 | int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb); | 339 | int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb); |
@@ -362,9 +365,9 @@ static int ext4_block_to_path(struct inode *inode, | |||
362 | final = ptrs; | 365 | final = ptrs; |
363 | } else { | 366 | } else { |
364 | ext4_warning(inode->i_sb, "ext4_block_to_path", | 367 | ext4_warning(inode->i_sb, "ext4_block_to_path", |
365 | "block %lu > max in inode %lu", | 368 | "block %lu > max in inode %lu", |
366 | i_block + direct_blocks + | 369 | i_block + direct_blocks + |
367 | indirect_blocks + double_blocks, inode->i_ino); | 370 | indirect_blocks + double_blocks, inode->i_ino); |
368 | } | 371 | } |
369 | if (boundary) | 372 | if (boundary) |
370 | *boundary = final - 1 - (i_block & (ptrs - 1)); | 373 | *boundary = final - 1 - (i_block & (ptrs - 1)); |
@@ -379,25 +382,25 @@ static int __ext4_check_blockref(const char *function, struct inode *inode, | |||
379 | 382 | ||
380 | while (bref < p+max) { | 383 | while (bref < p+max) { |
381 | blk = le32_to_cpu(*bref++); | 384 | blk = le32_to_cpu(*bref++); |
382 | if (blk && | 385 | if (blk && |
383 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), | 386 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), |
384 | blk, 1))) { | 387 | blk, 1))) { |
385 | ext4_error(inode->i_sb, function, | 388 | ext4_error(inode->i_sb, function, |
386 | "invalid block reference %u " | 389 | "invalid block reference %u " |
387 | "in inode #%lu", blk, inode->i_ino); | 390 | "in inode #%lu", blk, inode->i_ino); |
388 | return -EIO; | 391 | return -EIO; |
389 | } | 392 | } |
390 | } | 393 | } |
391 | return 0; | 394 | return 0; |
392 | } | 395 | } |
393 | 396 | ||
394 | 397 | ||
395 | #define ext4_check_indirect_blockref(inode, bh) \ | 398 | #define ext4_check_indirect_blockref(inode, bh) \ |
396 | __ext4_check_blockref(__func__, inode, (__le32 *)(bh)->b_data, \ | 399 | __ext4_check_blockref(__func__, inode, (__le32 *)(bh)->b_data, \ |
397 | EXT4_ADDR_PER_BLOCK((inode)->i_sb)) | 400 | EXT4_ADDR_PER_BLOCK((inode)->i_sb)) |
398 | 401 | ||
399 | #define ext4_check_inode_blockref(inode) \ | 402 | #define ext4_check_inode_blockref(inode) \ |
400 | __ext4_check_blockref(__func__, inode, EXT4_I(inode)->i_data, \ | 403 | __ext4_check_blockref(__func__, inode, EXT4_I(inode)->i_data, \ |
401 | EXT4_NDIR_BLOCKS) | 404 | EXT4_NDIR_BLOCKS) |
402 | 405 | ||
403 | /** | 406 | /** |
@@ -447,7 +450,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth, | |||
447 | bh = sb_getblk(sb, le32_to_cpu(p->key)); | 450 | bh = sb_getblk(sb, le32_to_cpu(p->key)); |
448 | if (unlikely(!bh)) | 451 | if (unlikely(!bh)) |
449 | goto failure; | 452 | goto failure; |
450 | 453 | ||
451 | if (!bh_uptodate_or_lock(bh)) { | 454 | if (!bh_uptodate_or_lock(bh)) { |
452 | if (bh_submit_read(bh) < 0) { | 455 | if (bh_submit_read(bh) < 0) { |
453 | put_bh(bh); | 456 | put_bh(bh); |
@@ -459,7 +462,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth, | |||
459 | goto failure; | 462 | goto failure; |
460 | } | 463 | } |
461 | } | 464 | } |
462 | 465 | ||
463 | add_chain(++p, bh, (__le32 *)bh->b_data + *++offsets); | 466 | add_chain(++p, bh, (__le32 *)bh->b_data + *++offsets); |
464 | /* Reader: end */ | 467 | /* Reader: end */ |
465 | if (!p->key) | 468 | if (!p->key) |
@@ -552,7 +555,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind) | |||
552 | * returns it. | 555 | * returns it. |
553 | */ | 556 | */ |
554 | static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block, | 557 | static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block, |
555 | Indirect *partial) | 558 | Indirect *partial) |
556 | { | 559 | { |
557 | /* | 560 | /* |
558 | * XXX need to get goal block from mballoc's data structures | 561 | * XXX need to get goal block from mballoc's data structures |
@@ -574,7 +577,7 @@ static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block, | |||
574 | * direct and indirect blocks. | 577 | * direct and indirect blocks. |
575 | */ | 578 | */ |
576 | static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, | 579 | static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, |
577 | int blocks_to_boundary) | 580 | int blocks_to_boundary) |
578 | { | 581 | { |
579 | unsigned int count = 0; | 582 | unsigned int count = 0; |
580 | 583 | ||
@@ -610,9 +613,9 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, | |||
610 | * direct blocks | 613 | * direct blocks |
611 | */ | 614 | */ |
612 | static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, | 615 | static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, |
613 | ext4_lblk_t iblock, ext4_fsblk_t goal, | 616 | ext4_lblk_t iblock, ext4_fsblk_t goal, |
614 | int indirect_blks, int blks, | 617 | int indirect_blks, int blks, |
615 | ext4_fsblk_t new_blocks[4], int *err) | 618 | ext4_fsblk_t new_blocks[4], int *err) |
616 | { | 619 | { |
617 | struct ext4_allocation_request ar; | 620 | struct ext4_allocation_request ar; |
618 | int target, i; | 621 | int target, i; |
@@ -683,10 +686,10 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, | |||
683 | } | 686 | } |
684 | if (!*err) { | 687 | if (!*err) { |
685 | if (target == blks) { | 688 | if (target == blks) { |
686 | /* | 689 | /* |
687 | * save the new block number | 690 | * save the new block number |
688 | * for the first direct block | 691 | * for the first direct block |
689 | */ | 692 | */ |
690 | new_blocks[index] = current_block; | 693 | new_blocks[index] = current_block; |
691 | } | 694 | } |
692 | blk_allocated += ar.len; | 695 | blk_allocated += ar.len; |
@@ -728,9 +731,9 @@ failed_out: | |||
728 | * as described above and return 0. | 731 | * as described above and return 0. |
729 | */ | 732 | */ |
730 | static int ext4_alloc_branch(handle_t *handle, struct inode *inode, | 733 | static int ext4_alloc_branch(handle_t *handle, struct inode *inode, |
731 | ext4_lblk_t iblock, int indirect_blks, | 734 | ext4_lblk_t iblock, int indirect_blks, |
732 | int *blks, ext4_fsblk_t goal, | 735 | int *blks, ext4_fsblk_t goal, |
733 | ext4_lblk_t *offsets, Indirect *branch) | 736 | ext4_lblk_t *offsets, Indirect *branch) |
734 | { | 737 | { |
735 | int blocksize = inode->i_sb->s_blocksize; | 738 | int blocksize = inode->i_sb->s_blocksize; |
736 | int i, n = 0; | 739 | int i, n = 0; |
@@ -777,7 +780,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, | |||
777 | * the chain to point to the new allocated | 780 | * the chain to point to the new allocated |
778 | * data blocks numbers | 781 | * data blocks numbers |
779 | */ | 782 | */ |
780 | for (i=1; i < num; i++) | 783 | for (i = 1; i < num; i++) |
781 | *(branch[n].p + i) = cpu_to_le32(++current_block); | 784 | *(branch[n].p + i) = cpu_to_le32(++current_block); |
782 | } | 785 | } |
783 | BUFFER_TRACE(bh, "marking uptodate"); | 786 | BUFFER_TRACE(bh, "marking uptodate"); |
@@ -820,7 +823,8 @@ failed: | |||
820 | * chain to new block and return 0. | 823 | * chain to new block and return 0. |
821 | */ | 824 | */ |
822 | static int ext4_splice_branch(handle_t *handle, struct inode *inode, | 825 | static int ext4_splice_branch(handle_t *handle, struct inode *inode, |
823 | ext4_lblk_t block, Indirect *where, int num, int blks) | 826 | ext4_lblk_t block, Indirect *where, int num, |
827 | int blks) | ||
824 | { | 828 | { |
825 | int i; | 829 | int i; |
826 | int err = 0; | 830 | int err = 0; |
@@ -852,10 +856,6 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, | |||
852 | } | 856 | } |
853 | 857 | ||
854 | /* We are done with atomic stuff, now do the rest of housekeeping */ | 858 | /* We are done with atomic stuff, now do the rest of housekeeping */ |
855 | |||
856 | inode->i_ctime = ext4_current_time(inode); | ||
857 | ext4_mark_inode_dirty(handle, inode); | ||
858 | |||
859 | /* had we spliced it onto indirect block? */ | 859 | /* had we spliced it onto indirect block? */ |
860 | if (where->bh) { | 860 | if (where->bh) { |
861 | /* | 861 | /* |
@@ -874,8 +874,8 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, | |||
874 | } else { | 874 | } else { |
875 | /* | 875 | /* |
876 | * OK, we spliced it into the inode itself on a direct block. | 876 | * OK, we spliced it into the inode itself on a direct block. |
877 | * Inode was dirtied above. | ||
878 | */ | 877 | */ |
878 | ext4_mark_inode_dirty(handle, inode); | ||
879 | jbd_debug(5, "splicing direct\n"); | 879 | jbd_debug(5, "splicing direct\n"); |
880 | } | 880 | } |
881 | return err; | 881 | return err; |
@@ -921,9 +921,9 @@ err_out: | |||
921 | * blocks. | 921 | * blocks. |
922 | */ | 922 | */ |
923 | static int ext4_ind_get_blocks(handle_t *handle, struct inode *inode, | 923 | static int ext4_ind_get_blocks(handle_t *handle, struct inode *inode, |
924 | ext4_lblk_t iblock, unsigned int maxblocks, | 924 | ext4_lblk_t iblock, unsigned int maxblocks, |
925 | struct buffer_head *bh_result, | 925 | struct buffer_head *bh_result, |
926 | int flags) | 926 | int flags) |
927 | { | 927 | { |
928 | int err = -EIO; | 928 | int err = -EIO; |
929 | ext4_lblk_t offsets[4]; | 929 | ext4_lblk_t offsets[4]; |
@@ -939,7 +939,7 @@ static int ext4_ind_get_blocks(handle_t *handle, struct inode *inode, | |||
939 | J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); | 939 | J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); |
940 | J_ASSERT(handle != NULL || (flags & EXT4_GET_BLOCKS_CREATE) == 0); | 940 | J_ASSERT(handle != NULL || (flags & EXT4_GET_BLOCKS_CREATE) == 0); |
941 | depth = ext4_block_to_path(inode, iblock, offsets, | 941 | depth = ext4_block_to_path(inode, iblock, offsets, |
942 | &blocks_to_boundary); | 942 | &blocks_to_boundary); |
943 | 943 | ||
944 | if (depth == 0) | 944 | if (depth == 0) |
945 | goto out; | 945 | goto out; |
@@ -987,8 +987,8 @@ static int ext4_ind_get_blocks(handle_t *handle, struct inode *inode, | |||
987 | * Block out ext4_truncate while we alter the tree | 987 | * Block out ext4_truncate while we alter the tree |
988 | */ | 988 | */ |
989 | err = ext4_alloc_branch(handle, inode, iblock, indirect_blks, | 989 | err = ext4_alloc_branch(handle, inode, iblock, indirect_blks, |
990 | &count, goal, | 990 | &count, goal, |
991 | offsets + (partial - chain), partial); | 991 | offsets + (partial - chain), partial); |
992 | 992 | ||
993 | /* | 993 | /* |
994 | * The ext4_splice_branch call will free and forget any buffers | 994 | * The ext4_splice_branch call will free and forget any buffers |
@@ -999,8 +999,8 @@ static int ext4_ind_get_blocks(handle_t *handle, struct inode *inode, | |||
999 | */ | 999 | */ |
1000 | if (!err) | 1000 | if (!err) |
1001 | err = ext4_splice_branch(handle, inode, iblock, | 1001 | err = ext4_splice_branch(handle, inode, iblock, |
1002 | partial, indirect_blks, count); | 1002 | partial, indirect_blks, count); |
1003 | else | 1003 | else |
1004 | goto cleanup; | 1004 | goto cleanup; |
1005 | 1005 | ||
1006 | set_buffer_new(bh_result); | 1006 | set_buffer_new(bh_result); |
@@ -1172,7 +1172,7 @@ int ext4_get_blocks(handle_t *handle, struct inode *inode, sector_t block, | |||
1172 | up_read((&EXT4_I(inode)->i_data_sem)); | 1172 | up_read((&EXT4_I(inode)->i_data_sem)); |
1173 | 1173 | ||
1174 | if (retval > 0 && buffer_mapped(bh)) { | 1174 | if (retval > 0 && buffer_mapped(bh)) { |
1175 | int ret = check_block_validity(inode, block, | 1175 | int ret = check_block_validity(inode, block, |
1176 | bh->b_blocknr, retval); | 1176 | bh->b_blocknr, retval); |
1177 | if (ret != 0) | 1177 | if (ret != 0) |
1178 | return ret; | 1178 | return ret; |
@@ -1254,7 +1254,7 @@ int ext4_get_blocks(handle_t *handle, struct inode *inode, sector_t block, | |||
1254 | 1254 | ||
1255 | up_write((&EXT4_I(inode)->i_data_sem)); | 1255 | up_write((&EXT4_I(inode)->i_data_sem)); |
1256 | if (retval > 0 && buffer_mapped(bh)) { | 1256 | if (retval > 0 && buffer_mapped(bh)) { |
1257 | int ret = check_block_validity(inode, block, | 1257 | int ret = check_block_validity(inode, block, |
1258 | bh->b_blocknr, retval); | 1258 | bh->b_blocknr, retval); |
1259 | if (ret != 0) | 1259 | if (ret != 0) |
1260 | return ret; | 1260 | return ret; |
@@ -1405,8 +1405,7 @@ static int walk_page_buffers(handle_t *handle, | |||
1405 | 1405 | ||
1406 | for (bh = head, block_start = 0; | 1406 | for (bh = head, block_start = 0; |
1407 | ret == 0 && (bh != head || !block_start); | 1407 | ret == 0 && (bh != head || !block_start); |
1408 | block_start = block_end, bh = next) | 1408 | block_start = block_end, bh = next) { |
1409 | { | ||
1410 | next = bh->b_this_page; | 1409 | next = bh->b_this_page; |
1411 | block_end = block_start + blocksize; | 1410 | block_end = block_start + blocksize; |
1412 | if (block_end <= from || block_start >= to) { | 1411 | if (block_end <= from || block_start >= to) { |
@@ -1447,7 +1446,7 @@ static int walk_page_buffers(handle_t *handle, | |||
1447 | * write. | 1446 | * write. |
1448 | */ | 1447 | */ |
1449 | static int do_journal_get_write_access(handle_t *handle, | 1448 | static int do_journal_get_write_access(handle_t *handle, |
1450 | struct buffer_head *bh) | 1449 | struct buffer_head *bh) |
1451 | { | 1450 | { |
1452 | if (!buffer_mapped(bh) || buffer_freed(bh)) | 1451 | if (!buffer_mapped(bh) || buffer_freed(bh)) |
1453 | return 0; | 1452 | return 0; |
@@ -1455,27 +1454,24 @@ static int do_journal_get_write_access(handle_t *handle, | |||
1455 | } | 1454 | } |
1456 | 1455 | ||
1457 | static int ext4_write_begin(struct file *file, struct address_space *mapping, | 1456 | static int ext4_write_begin(struct file *file, struct address_space *mapping, |
1458 | loff_t pos, unsigned len, unsigned flags, | 1457 | loff_t pos, unsigned len, unsigned flags, |
1459 | struct page **pagep, void **fsdata) | 1458 | struct page **pagep, void **fsdata) |
1460 | { | 1459 | { |
1461 | struct inode *inode = mapping->host; | 1460 | struct inode *inode = mapping->host; |
1462 | int ret, needed_blocks; | 1461 | int ret, needed_blocks; |
1463 | handle_t *handle; | 1462 | handle_t *handle; |
1464 | int retries = 0; | 1463 | int retries = 0; |
1465 | struct page *page; | 1464 | struct page *page; |
1466 | pgoff_t index; | 1465 | pgoff_t index; |
1467 | unsigned from, to; | 1466 | unsigned from, to; |
1468 | 1467 | ||
1469 | trace_mark(ext4_write_begin, | 1468 | trace_ext4_write_begin(inode, pos, len, flags); |
1470 | "dev %s ino %lu pos %llu len %u flags %u", | ||
1471 | inode->i_sb->s_id, inode->i_ino, | ||
1472 | (unsigned long long) pos, len, flags); | ||
1473 | /* | 1469 | /* |
1474 | * Reserve one block more for addition to orphan list in case | 1470 | * Reserve one block more for addition to orphan list in case |
1475 | * we allocate blocks but write fails for some reason | 1471 | * we allocate blocks but write fails for some reason |
1476 | */ | 1472 | */ |
1477 | needed_blocks = ext4_writepage_trans_blocks(inode) + 1; | 1473 | needed_blocks = ext4_writepage_trans_blocks(inode) + 1; |
1478 | index = pos >> PAGE_CACHE_SHIFT; | 1474 | index = pos >> PAGE_CACHE_SHIFT; |
1479 | from = pos & (PAGE_CACHE_SIZE - 1); | 1475 | from = pos & (PAGE_CACHE_SIZE - 1); |
1480 | to = from + len; | 1476 | to = from + len; |
1481 | 1477 | ||
@@ -1523,7 +1519,7 @@ retry: | |||
1523 | ext4_journal_stop(handle); | 1519 | ext4_journal_stop(handle); |
1524 | if (pos + len > inode->i_size) { | 1520 | if (pos + len > inode->i_size) { |
1525 | vmtruncate(inode, inode->i_size); | 1521 | vmtruncate(inode, inode->i_size); |
1526 | /* | 1522 | /* |
1527 | * If vmtruncate failed early the inode might | 1523 | * If vmtruncate failed early the inode might |
1528 | * still be on the orphan list; we need to | 1524 | * still be on the orphan list; we need to |
1529 | * make sure the inode is removed from the | 1525 | * make sure the inode is removed from the |
@@ -1550,9 +1546,9 @@ static int write_end_fn(handle_t *handle, struct buffer_head *bh) | |||
1550 | } | 1546 | } |
1551 | 1547 | ||
1552 | static int ext4_generic_write_end(struct file *file, | 1548 | static int ext4_generic_write_end(struct file *file, |
1553 | struct address_space *mapping, | 1549 | struct address_space *mapping, |
1554 | loff_t pos, unsigned len, unsigned copied, | 1550 | loff_t pos, unsigned len, unsigned copied, |
1555 | struct page *page, void *fsdata) | 1551 | struct page *page, void *fsdata) |
1556 | { | 1552 | { |
1557 | int i_size_changed = 0; | 1553 | int i_size_changed = 0; |
1558 | struct inode *inode = mapping->host; | 1554 | struct inode *inode = mapping->host; |
@@ -1603,18 +1599,15 @@ static int ext4_generic_write_end(struct file *file, | |||
1603 | * buffers are managed internally. | 1599 | * buffers are managed internally. |
1604 | */ | 1600 | */ |
1605 | static int ext4_ordered_write_end(struct file *file, | 1601 | static int ext4_ordered_write_end(struct file *file, |
1606 | struct address_space *mapping, | 1602 | struct address_space *mapping, |
1607 | loff_t pos, unsigned len, unsigned copied, | 1603 | loff_t pos, unsigned len, unsigned copied, |
1608 | struct page *page, void *fsdata) | 1604 | struct page *page, void *fsdata) |
1609 | { | 1605 | { |
1610 | handle_t *handle = ext4_journal_current_handle(); | 1606 | handle_t *handle = ext4_journal_current_handle(); |
1611 | struct inode *inode = mapping->host; | 1607 | struct inode *inode = mapping->host; |
1612 | int ret = 0, ret2; | 1608 | int ret = 0, ret2; |
1613 | 1609 | ||
1614 | trace_mark(ext4_ordered_write_end, | 1610 | trace_ext4_ordered_write_end(inode, pos, len, copied); |
1615 | "dev %s ino %lu pos %llu len %u copied %u", | ||
1616 | inode->i_sb->s_id, inode->i_ino, | ||
1617 | (unsigned long long) pos, len, copied); | ||
1618 | ret = ext4_jbd2_file_inode(handle, inode); | 1611 | ret = ext4_jbd2_file_inode(handle, inode); |
1619 | 1612 | ||
1620 | if (ret == 0) { | 1613 | if (ret == 0) { |
@@ -1636,7 +1629,7 @@ static int ext4_ordered_write_end(struct file *file, | |||
1636 | 1629 | ||
1637 | if (pos + len > inode->i_size) { | 1630 | if (pos + len > inode->i_size) { |
1638 | vmtruncate(inode, inode->i_size); | 1631 | vmtruncate(inode, inode->i_size); |
1639 | /* | 1632 | /* |
1640 | * If vmtruncate failed early the inode might still be | 1633 | * If vmtruncate failed early the inode might still be |
1641 | * on the orphan list; we need to make sure the inode | 1634 | * on the orphan list; we need to make sure the inode |
1642 | * is removed from the orphan list in that case. | 1635 | * is removed from the orphan list in that case. |
@@ -1650,18 +1643,15 @@ static int ext4_ordered_write_end(struct file *file, | |||
1650 | } | 1643 | } |
1651 | 1644 | ||
1652 | static int ext4_writeback_write_end(struct file *file, | 1645 | static int ext4_writeback_write_end(struct file *file, |
1653 | struct address_space *mapping, | 1646 | struct address_space *mapping, |
1654 | loff_t pos, unsigned len, unsigned copied, | 1647 | loff_t pos, unsigned len, unsigned copied, |
1655 | struct page *page, void *fsdata) | 1648 | struct page *page, void *fsdata) |
1656 | { | 1649 | { |
1657 | handle_t *handle = ext4_journal_current_handle(); | 1650 | handle_t *handle = ext4_journal_current_handle(); |
1658 | struct inode *inode = mapping->host; | 1651 | struct inode *inode = mapping->host; |
1659 | int ret = 0, ret2; | 1652 | int ret = 0, ret2; |
1660 | 1653 | ||
1661 | trace_mark(ext4_writeback_write_end, | 1654 | trace_ext4_writeback_write_end(inode, pos, len, copied); |
1662 | "dev %s ino %lu pos %llu len %u copied %u", | ||
1663 | inode->i_sb->s_id, inode->i_ino, | ||
1664 | (unsigned long long) pos, len, copied); | ||
1665 | ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, | 1655 | ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, |
1666 | page, fsdata); | 1656 | page, fsdata); |
1667 | copied = ret2; | 1657 | copied = ret2; |
@@ -1681,7 +1671,7 @@ static int ext4_writeback_write_end(struct file *file, | |||
1681 | 1671 | ||
1682 | if (pos + len > inode->i_size) { | 1672 | if (pos + len > inode->i_size) { |
1683 | vmtruncate(inode, inode->i_size); | 1673 | vmtruncate(inode, inode->i_size); |
1684 | /* | 1674 | /* |
1685 | * If vmtruncate failed early the inode might still be | 1675 | * If vmtruncate failed early the inode might still be |
1686 | * on the orphan list; we need to make sure the inode | 1676 | * on the orphan list; we need to make sure the inode |
1687 | * is removed from the orphan list in that case. | 1677 | * is removed from the orphan list in that case. |
@@ -1694,9 +1684,9 @@ static int ext4_writeback_write_end(struct file *file, | |||
1694 | } | 1684 | } |
1695 | 1685 | ||
1696 | static int ext4_journalled_write_end(struct file *file, | 1686 | static int ext4_journalled_write_end(struct file *file, |
1697 | struct address_space *mapping, | 1687 | struct address_space *mapping, |
1698 | loff_t pos, unsigned len, unsigned copied, | 1688 | loff_t pos, unsigned len, unsigned copied, |
1699 | struct page *page, void *fsdata) | 1689 | struct page *page, void *fsdata) |
1700 | { | 1690 | { |
1701 | handle_t *handle = ext4_journal_current_handle(); | 1691 | handle_t *handle = ext4_journal_current_handle(); |
1702 | struct inode *inode = mapping->host; | 1692 | struct inode *inode = mapping->host; |
@@ -1705,10 +1695,7 @@ static int ext4_journalled_write_end(struct file *file, | |||
1705 | unsigned from, to; | 1695 | unsigned from, to; |
1706 | loff_t new_i_size; | 1696 | loff_t new_i_size; |
1707 | 1697 | ||
1708 | trace_mark(ext4_journalled_write_end, | 1698 | trace_ext4_journalled_write_end(inode, pos, len, copied); |
1709 | "dev %s ino %lu pos %llu len %u copied %u", | ||
1710 | inode->i_sb->s_id, inode->i_ino, | ||
1711 | (unsigned long long) pos, len, copied); | ||
1712 | from = pos & (PAGE_CACHE_SIZE - 1); | 1699 | from = pos & (PAGE_CACHE_SIZE - 1); |
1713 | to = from + len; | 1700 | to = from + len; |
1714 | 1701 | ||
@@ -1747,7 +1734,7 @@ static int ext4_journalled_write_end(struct file *file, | |||
1747 | ret = ret2; | 1734 | ret = ret2; |
1748 | if (pos + len > inode->i_size) { | 1735 | if (pos + len > inode->i_size) { |
1749 | vmtruncate(inode, inode->i_size); | 1736 | vmtruncate(inode, inode->i_size); |
1750 | /* | 1737 | /* |
1751 | * If vmtruncate failed early the inode might still be | 1738 | * If vmtruncate failed early the inode might still be |
1752 | * on the orphan list; we need to make sure the inode | 1739 | * on the orphan list; we need to make sure the inode |
1753 | * is removed from the orphan list in that case. | 1740 | * is removed from the orphan list in that case. |
@@ -1854,7 +1841,7 @@ static void ext4_da_release_space(struct inode *inode, int to_free) | |||
1854 | } | 1841 | } |
1855 | 1842 | ||
1856 | static void ext4_da_page_release_reservation(struct page *page, | 1843 | static void ext4_da_page_release_reservation(struct page *page, |
1857 | unsigned long offset) | 1844 | unsigned long offset) |
1858 | { | 1845 | { |
1859 | int to_release = 0; | 1846 | int to_release = 0; |
1860 | struct buffer_head *head, *bh; | 1847 | struct buffer_head *head, *bh; |
@@ -2554,9 +2541,7 @@ static int ext4_da_writepage(struct page *page, | |||
2554 | struct buffer_head *page_bufs; | 2541 | struct buffer_head *page_bufs; |
2555 | struct inode *inode = page->mapping->host; | 2542 | struct inode *inode = page->mapping->host; |
2556 | 2543 | ||
2557 | trace_mark(ext4_da_writepage, | 2544 | trace_ext4_da_writepage(inode, page); |
2558 | "dev %s ino %lu page_index %lu", | ||
2559 | inode->i_sb->s_id, inode->i_ino, page->index); | ||
2560 | size = i_size_read(inode); | 2545 | size = i_size_read(inode); |
2561 | if (page->index == size >> PAGE_CACHE_SHIFT) | 2546 | if (page->index == size >> PAGE_CACHE_SHIFT) |
2562 | len = size & ~PAGE_CACHE_MASK; | 2547 | len = size & ~PAGE_CACHE_MASK; |
@@ -2667,19 +2652,7 @@ static int ext4_da_writepages(struct address_space *mapping, | |||
2667 | int needed_blocks, ret = 0, nr_to_writebump = 0; | 2652 | int needed_blocks, ret = 0, nr_to_writebump = 0; |
2668 | struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); | 2653 | struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); |
2669 | 2654 | ||
2670 | trace_mark(ext4_da_writepages, | 2655 | trace_ext4_da_writepages(inode, wbc); |
2671 | "dev %s ino %lu nr_t_write %ld " | ||
2672 | "pages_skipped %ld range_start %llu " | ||
2673 | "range_end %llu nonblocking %d " | ||
2674 | "for_kupdate %d for_reclaim %d " | ||
2675 | "for_writepages %d range_cyclic %d", | ||
2676 | inode->i_sb->s_id, inode->i_ino, | ||
2677 | wbc->nr_to_write, wbc->pages_skipped, | ||
2678 | (unsigned long long) wbc->range_start, | ||
2679 | (unsigned long long) wbc->range_end, | ||
2680 | wbc->nonblocking, wbc->for_kupdate, | ||
2681 | wbc->for_reclaim, wbc->for_writepages, | ||
2682 | wbc->range_cyclic); | ||
2683 | 2656 | ||
2684 | /* | 2657 | /* |
2685 | * No pages to write? This is mainly a kludge to avoid starting | 2658 | * No pages to write? This is mainly a kludge to avoid starting |
@@ -2693,13 +2666,13 @@ static int ext4_da_writepages(struct address_space *mapping, | |||
2693 | * If the filesystem has aborted, it is read-only, so return | 2666 | * If the filesystem has aborted, it is read-only, so return |
2694 | * right away instead of dumping stack traces later on that | 2667 | * right away instead of dumping stack traces later on that |
2695 | * will obscure the real source of the problem. We test | 2668 | * will obscure the real source of the problem. We test |
2696 | * EXT4_MOUNT_ABORT instead of sb->s_flag's MS_RDONLY because | 2669 | * EXT4_MF_FS_ABORTED instead of sb->s_flag's MS_RDONLY because |
2697 | * the latter could be true if the filesystem is mounted | 2670 | * the latter could be true if the filesystem is mounted |
2698 | * read-only, and in that case, ext4_da_writepages should | 2671 | * read-only, and in that case, ext4_da_writepages should |
2699 | * *never* be called, so if that ever happens, we would want | 2672 | * *never* be called, so if that ever happens, we would want |
2700 | * the stack trace. | 2673 | * the stack trace. |
2701 | */ | 2674 | */ |
2702 | if (unlikely(sbi->s_mount_opt & EXT4_MOUNT_ABORT)) | 2675 | if (unlikely(sbi->s_mount_flags & EXT4_MF_FS_ABORTED)) |
2703 | return -EROFS; | 2676 | return -EROFS; |
2704 | 2677 | ||
2705 | /* | 2678 | /* |
@@ -2845,14 +2818,7 @@ out_writepages: | |||
2845 | if (!no_nrwrite_index_update) | 2818 | if (!no_nrwrite_index_update) |
2846 | wbc->no_nrwrite_index_update = 0; | 2819 | wbc->no_nrwrite_index_update = 0; |
2847 | wbc->nr_to_write -= nr_to_writebump; | 2820 | wbc->nr_to_write -= nr_to_writebump; |
2848 | trace_mark(ext4_da_writepage_result, | 2821 | trace_ext4_da_writepages_result(inode, wbc, ret, pages_written); |
2849 | "dev %s ino %lu ret %d pages_written %d " | ||
2850 | "pages_skipped %ld congestion %d " | ||
2851 | "more_io %d no_nrwrite_index_update %d", | ||
2852 | inode->i_sb->s_id, inode->i_ino, ret, | ||
2853 | pages_written, wbc->pages_skipped, | ||
2854 | wbc->encountered_congestion, wbc->more_io, | ||
2855 | wbc->no_nrwrite_index_update); | ||
2856 | return ret; | 2822 | return ret; |
2857 | } | 2823 | } |
2858 | 2824 | ||
@@ -2884,8 +2850,8 @@ static int ext4_nonda_switch(struct super_block *sb) | |||
2884 | } | 2850 | } |
2885 | 2851 | ||
2886 | static int ext4_da_write_begin(struct file *file, struct address_space *mapping, | 2852 | static int ext4_da_write_begin(struct file *file, struct address_space *mapping, |
2887 | loff_t pos, unsigned len, unsigned flags, | 2853 | loff_t pos, unsigned len, unsigned flags, |
2888 | struct page **pagep, void **fsdata) | 2854 | struct page **pagep, void **fsdata) |
2889 | { | 2855 | { |
2890 | int ret, retries = 0; | 2856 | int ret, retries = 0; |
2891 | struct page *page; | 2857 | struct page *page; |
@@ -2904,11 +2870,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, | |||
2904 | len, flags, pagep, fsdata); | 2870 | len, flags, pagep, fsdata); |
2905 | } | 2871 | } |
2906 | *fsdata = (void *)0; | 2872 | *fsdata = (void *)0; |
2907 | 2873 | trace_ext4_da_write_begin(inode, pos, len, flags); | |
2908 | trace_mark(ext4_da_write_begin, | ||
2909 | "dev %s ino %lu pos %llu len %u flags %u", | ||
2910 | inode->i_sb->s_id, inode->i_ino, | ||
2911 | (unsigned long long) pos, len, flags); | ||
2912 | retry: | 2874 | retry: |
2913 | /* | 2875 | /* |
2914 | * With delayed allocation, we don't log the i_disksize update | 2876 | * With delayed allocation, we don't log the i_disksize update |
@@ -2959,7 +2921,7 @@ out: | |||
2959 | * when write to the end of file but not require block allocation | 2921 | * when write to the end of file but not require block allocation |
2960 | */ | 2922 | */ |
2961 | static int ext4_da_should_update_i_disksize(struct page *page, | 2923 | static int ext4_da_should_update_i_disksize(struct page *page, |
2962 | unsigned long offset) | 2924 | unsigned long offset) |
2963 | { | 2925 | { |
2964 | struct buffer_head *bh; | 2926 | struct buffer_head *bh; |
2965 | struct inode *inode = page->mapping->host; | 2927 | struct inode *inode = page->mapping->host; |
@@ -2978,9 +2940,9 @@ static int ext4_da_should_update_i_disksize(struct page *page, | |||
2978 | } | 2940 | } |
2979 | 2941 | ||
2980 | static int ext4_da_write_end(struct file *file, | 2942 | static int ext4_da_write_end(struct file *file, |
2981 | struct address_space *mapping, | 2943 | struct address_space *mapping, |
2982 | loff_t pos, unsigned len, unsigned copied, | 2944 | loff_t pos, unsigned len, unsigned copied, |
2983 | struct page *page, void *fsdata) | 2945 | struct page *page, void *fsdata) |
2984 | { | 2946 | { |
2985 | struct inode *inode = mapping->host; | 2947 | struct inode *inode = mapping->host; |
2986 | int ret = 0, ret2; | 2948 | int ret = 0, ret2; |
@@ -3001,10 +2963,7 @@ static int ext4_da_write_end(struct file *file, | |||
3001 | } | 2963 | } |
3002 | } | 2964 | } |
3003 | 2965 | ||
3004 | trace_mark(ext4_da_write_end, | 2966 | trace_ext4_da_write_end(inode, pos, len, copied); |
3005 | "dev %s ino %lu pos %llu len %u copied %u", | ||
3006 | inode->i_sb->s_id, inode->i_ino, | ||
3007 | (unsigned long long) pos, len, copied); | ||
3008 | start = pos & (PAGE_CACHE_SIZE - 1); | 2967 | start = pos & (PAGE_CACHE_SIZE - 1); |
3009 | end = start + copied - 1; | 2968 | end = start + copied - 1; |
3010 | 2969 | ||
@@ -3081,7 +3040,7 @@ int ext4_alloc_da_blocks(struct inode *inode) | |||
3081 | * not strictly speaking necessary (and for users of | 3040 | * not strictly speaking necessary (and for users of |
3082 | * laptop_mode, not even desirable). However, to do otherwise | 3041 | * laptop_mode, not even desirable). However, to do otherwise |
3083 | * would require replicating code paths in: | 3042 | * would require replicating code paths in: |
3084 | * | 3043 | * |
3085 | * ext4_da_writepages() -> | 3044 | * ext4_da_writepages() -> |
3086 | * write_cache_pages() ---> (via passed in callback function) | 3045 | * write_cache_pages() ---> (via passed in callback function) |
3087 | * __mpage_da_writepage() --> | 3046 | * __mpage_da_writepage() --> |
@@ -3101,7 +3060,7 @@ int ext4_alloc_da_blocks(struct inode *inode) | |||
3101 | * write out the pages, but rather only collect contiguous | 3060 | * write out the pages, but rather only collect contiguous |
3102 | * logical block extents, call the multi-block allocator, and | 3061 | * logical block extents, call the multi-block allocator, and |
3103 | * then update the buffer heads with the block allocations. | 3062 | * then update the buffer heads with the block allocations. |
3104 | * | 3063 | * |
3105 | * For now, though, we'll cheat by calling filemap_flush(), | 3064 | * For now, though, we'll cheat by calling filemap_flush(), |
3106 | * which will map the blocks, and start the I/O, but not | 3065 | * which will map the blocks, and start the I/O, but not |
3107 | * actually wait for the I/O to complete. | 3066 | * actually wait for the I/O to complete. |
@@ -3237,7 +3196,7 @@ static int bput_one(handle_t *handle, struct buffer_head *bh) | |||
3237 | * | 3196 | * |
3238 | */ | 3197 | */ |
3239 | static int __ext4_normal_writepage(struct page *page, | 3198 | static int __ext4_normal_writepage(struct page *page, |
3240 | struct writeback_control *wbc) | 3199 | struct writeback_control *wbc) |
3241 | { | 3200 | { |
3242 | struct inode *inode = page->mapping->host; | 3201 | struct inode *inode = page->mapping->host; |
3243 | 3202 | ||
@@ -3249,15 +3208,13 @@ static int __ext4_normal_writepage(struct page *page, | |||
3249 | } | 3208 | } |
3250 | 3209 | ||
3251 | static int ext4_normal_writepage(struct page *page, | 3210 | static int ext4_normal_writepage(struct page *page, |
3252 | struct writeback_control *wbc) | 3211 | struct writeback_control *wbc) |
3253 | { | 3212 | { |
3254 | struct inode *inode = page->mapping->host; | 3213 | struct inode *inode = page->mapping->host; |
3255 | loff_t size = i_size_read(inode); | 3214 | loff_t size = i_size_read(inode); |
3256 | loff_t len; | 3215 | loff_t len; |
3257 | 3216 | ||
3258 | trace_mark(ext4_normal_writepage, | 3217 | trace_ext4_normal_writepage(inode, page); |
3259 | "dev %s ino %lu page_index %lu", | ||
3260 | inode->i_sb->s_id, inode->i_ino, page->index); | ||
3261 | J_ASSERT(PageLocked(page)); | 3218 | J_ASSERT(PageLocked(page)); |
3262 | if (page->index == size >> PAGE_CACHE_SHIFT) | 3219 | if (page->index == size >> PAGE_CACHE_SHIFT) |
3263 | len = size & ~PAGE_CACHE_MASK; | 3220 | len = size & ~PAGE_CACHE_MASK; |
@@ -3287,7 +3244,7 @@ static int ext4_normal_writepage(struct page *page, | |||
3287 | } | 3244 | } |
3288 | 3245 | ||
3289 | static int __ext4_journalled_writepage(struct page *page, | 3246 | static int __ext4_journalled_writepage(struct page *page, |
3290 | struct writeback_control *wbc) | 3247 | struct writeback_control *wbc) |
3291 | { | 3248 | { |
3292 | struct address_space *mapping = page->mapping; | 3249 | struct address_space *mapping = page->mapping; |
3293 | struct inode *inode = mapping->host; | 3250 | struct inode *inode = mapping->host; |
@@ -3337,15 +3294,13 @@ out: | |||
3337 | } | 3294 | } |
3338 | 3295 | ||
3339 | static int ext4_journalled_writepage(struct page *page, | 3296 | static int ext4_journalled_writepage(struct page *page, |
3340 | struct writeback_control *wbc) | 3297 | struct writeback_control *wbc) |
3341 | { | 3298 | { |
3342 | struct inode *inode = page->mapping->host; | 3299 | struct inode *inode = page->mapping->host; |
3343 | loff_t size = i_size_read(inode); | 3300 | loff_t size = i_size_read(inode); |
3344 | loff_t len; | 3301 | loff_t len; |
3345 | 3302 | ||
3346 | trace_mark(ext4_journalled_writepage, | 3303 | trace_ext4_journalled_writepage(inode, page); |
3347 | "dev %s ino %lu page_index %lu", | ||
3348 | inode->i_sb->s_id, inode->i_ino, page->index); | ||
3349 | J_ASSERT(PageLocked(page)); | 3304 | J_ASSERT(PageLocked(page)); |
3350 | if (page->index == size >> PAGE_CACHE_SHIFT) | 3305 | if (page->index == size >> PAGE_CACHE_SHIFT) |
3351 | len = size & ~PAGE_CACHE_MASK; | 3306 | len = size & ~PAGE_CACHE_MASK; |
@@ -3442,8 +3397,8 @@ static int ext4_releasepage(struct page *page, gfp_t wait) | |||
3442 | * VFS code falls back into buffered path in that case so we are safe. | 3397 | * VFS code falls back into buffered path in that case so we are safe. |
3443 | */ | 3398 | */ |
3444 | static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, | 3399 | static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, |
3445 | const struct iovec *iov, loff_t offset, | 3400 | const struct iovec *iov, loff_t offset, |
3446 | unsigned long nr_segs) | 3401 | unsigned long nr_segs) |
3447 | { | 3402 | { |
3448 | struct file *file = iocb->ki_filp; | 3403 | struct file *file = iocb->ki_filp; |
3449 | struct inode *inode = file->f_mapping->host; | 3404 | struct inode *inode = file->f_mapping->host; |
@@ -3763,7 +3718,8 @@ static inline int all_zeroes(__le32 *p, __le32 *q) | |||
3763 | * (no partially truncated stuff there). */ | 3718 | * (no partially truncated stuff there). */ |
3764 | 3719 | ||
3765 | static Indirect *ext4_find_shared(struct inode *inode, int depth, | 3720 | static Indirect *ext4_find_shared(struct inode *inode, int depth, |
3766 | ext4_lblk_t offsets[4], Indirect chain[4], __le32 *top) | 3721 | ext4_lblk_t offsets[4], Indirect chain[4], |
3722 | __le32 *top) | ||
3767 | { | 3723 | { |
3768 | Indirect *partial, *p; | 3724 | Indirect *partial, *p; |
3769 | int k, err; | 3725 | int k, err; |
@@ -3819,8 +3775,10 @@ no_top: | |||
3819 | * than `count' because there can be holes in there. | 3775 | * than `count' because there can be holes in there. |
3820 | */ | 3776 | */ |
3821 | static void ext4_clear_blocks(handle_t *handle, struct inode *inode, | 3777 | static void ext4_clear_blocks(handle_t *handle, struct inode *inode, |
3822 | struct buffer_head *bh, ext4_fsblk_t block_to_free, | 3778 | struct buffer_head *bh, |
3823 | unsigned long count, __le32 *first, __le32 *last) | 3779 | ext4_fsblk_t block_to_free, |
3780 | unsigned long count, __le32 *first, | ||
3781 | __le32 *last) | ||
3824 | { | 3782 | { |
3825 | __le32 *p; | 3783 | __le32 *p; |
3826 | if (try_to_extend_transaction(handle, inode)) { | 3784 | if (try_to_extend_transaction(handle, inode)) { |
@@ -3837,10 +3795,11 @@ static void ext4_clear_blocks(handle_t *handle, struct inode *inode, | |||
3837 | } | 3795 | } |
3838 | 3796 | ||
3839 | /* | 3797 | /* |
3840 | * Any buffers which are on the journal will be in memory. We find | 3798 | * Any buffers which are on the journal will be in memory. We |
3841 | * them on the hash table so jbd2_journal_revoke() will run jbd2_journal_forget() | 3799 | * find them on the hash table so jbd2_journal_revoke() will |
3842 | * on them. We've already detached each block from the file, so | 3800 | * run jbd2_journal_forget() on them. We've already detached |
3843 | * bforget() in jbd2_journal_forget() should be safe. | 3801 | * each block from the file, so bforget() in |
3802 | * jbd2_journal_forget() should be safe. | ||
3844 | * | 3803 | * |
3845 | * AKPM: turn on bforget in jbd2_journal_forget()!!! | 3804 | * AKPM: turn on bforget in jbd2_journal_forget()!!! |
3846 | */ | 3805 | */ |
@@ -4212,7 +4171,7 @@ void ext4_truncate(struct inode *inode) | |||
4212 | (__le32*)partial->bh->b_data+addr_per_block, | 4171 | (__le32*)partial->bh->b_data+addr_per_block, |
4213 | (chain+n-1) - partial); | 4172 | (chain+n-1) - partial); |
4214 | BUFFER_TRACE(partial->bh, "call brelse"); | 4173 | BUFFER_TRACE(partial->bh, "call brelse"); |
4215 | brelse (partial->bh); | 4174 | brelse(partial->bh); |
4216 | partial--; | 4175 | partial--; |
4217 | } | 4176 | } |
4218 | do_indirects: | 4177 | do_indirects: |
@@ -4453,8 +4412,9 @@ void ext4_get_inode_flags(struct ext4_inode_info *ei) | |||
4453 | if (flags & S_DIRSYNC) | 4412 | if (flags & S_DIRSYNC) |
4454 | ei->i_flags |= EXT4_DIRSYNC_FL; | 4413 | ei->i_flags |= EXT4_DIRSYNC_FL; |
4455 | } | 4414 | } |
4415 | |||
4456 | static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, | 4416 | static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, |
4457 | struct ext4_inode_info *ei) | 4417 | struct ext4_inode_info *ei) |
4458 | { | 4418 | { |
4459 | blkcnt_t i_blocks ; | 4419 | blkcnt_t i_blocks ; |
4460 | struct inode *inode = &(ei->vfs_inode); | 4420 | struct inode *inode = &(ei->vfs_inode); |
@@ -4569,7 +4529,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4569 | EXT4_GOOD_OLD_INODE_SIZE + | 4529 | EXT4_GOOD_OLD_INODE_SIZE + |
4570 | ei->i_extra_isize; | 4530 | ei->i_extra_isize; |
4571 | if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC)) | 4531 | if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC)) |
4572 | ei->i_state |= EXT4_STATE_XATTR; | 4532 | ei->i_state |= EXT4_STATE_XATTR; |
4573 | } | 4533 | } |
4574 | } else | 4534 | } else |
4575 | ei->i_extra_isize = 0; | 4535 | ei->i_extra_isize = 0; |
@@ -4588,7 +4548,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4588 | 4548 | ||
4589 | ret = 0; | 4549 | ret = 0; |
4590 | if (ei->i_file_acl && | 4550 | if (ei->i_file_acl && |
4591 | ((ei->i_file_acl < | 4551 | ((ei->i_file_acl < |
4592 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + | 4552 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + |
4593 | EXT4_SB(sb)->s_gdb_count)) || | 4553 | EXT4_SB(sb)->s_gdb_count)) || |
4594 | (ei->i_file_acl >= ext4_blocks_count(EXT4_SB(sb)->s_es)))) { | 4554 | (ei->i_file_acl >= ext4_blocks_count(EXT4_SB(sb)->s_es)))) { |
@@ -4603,15 +4563,15 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4603 | !ext4_inode_is_fast_symlink(inode))) | 4563 | !ext4_inode_is_fast_symlink(inode))) |
4604 | /* Validate extent which is part of inode */ | 4564 | /* Validate extent which is part of inode */ |
4605 | ret = ext4_ext_check_inode(inode); | 4565 | ret = ext4_ext_check_inode(inode); |
4606 | } else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 4566 | } else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
4607 | (S_ISLNK(inode->i_mode) && | 4567 | (S_ISLNK(inode->i_mode) && |
4608 | !ext4_inode_is_fast_symlink(inode))) { | 4568 | !ext4_inode_is_fast_symlink(inode))) { |
4609 | /* Validate block references which are part of inode */ | 4569 | /* Validate block references which are part of inode */ |
4610 | ret = ext4_check_inode_blockref(inode); | 4570 | ret = ext4_check_inode_blockref(inode); |
4611 | } | 4571 | } |
4612 | if (ret) { | 4572 | if (ret) { |
4613 | brelse(bh); | 4573 | brelse(bh); |
4614 | goto bad_inode; | 4574 | goto bad_inode; |
4615 | } | 4575 | } |
4616 | 4576 | ||
4617 | if (S_ISREG(inode->i_mode)) { | 4577 | if (S_ISREG(inode->i_mode)) { |
@@ -4642,7 +4602,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4642 | } else { | 4602 | } else { |
4643 | brelse(bh); | 4603 | brelse(bh); |
4644 | ret = -EIO; | 4604 | ret = -EIO; |
4645 | ext4_error(inode->i_sb, __func__, | 4605 | ext4_error(inode->i_sb, __func__, |
4646 | "bogus i_mode (%o) for inode=%lu", | 4606 | "bogus i_mode (%o) for inode=%lu", |
4647 | inode->i_mode, inode->i_ino); | 4607 | inode->i_mode, inode->i_ino); |
4648 | goto bad_inode; | 4608 | goto bad_inode; |
@@ -4795,8 +4755,9 @@ static int ext4_do_update_inode(handle_t *handle, | |||
4795 | cpu_to_le32(new_encode_dev(inode->i_rdev)); | 4755 | cpu_to_le32(new_encode_dev(inode->i_rdev)); |
4796 | raw_inode->i_block[2] = 0; | 4756 | raw_inode->i_block[2] = 0; |
4797 | } | 4757 | } |
4798 | } else for (block = 0; block < EXT4_N_BLOCKS; block++) | 4758 | } else |
4799 | raw_inode->i_block[block] = ei->i_data[block]; | 4759 | for (block = 0; block < EXT4_N_BLOCKS; block++) |
4760 | raw_inode->i_block[block] = ei->i_data[block]; | ||
4800 | 4761 | ||
4801 | raw_inode->i_disk_version = cpu_to_le32(inode->i_version); | 4762 | raw_inode->i_disk_version = cpu_to_le32(inode->i_version); |
4802 | if (ei->i_extra_isize) { | 4763 | if (ei->i_extra_isize) { |
@@ -5150,7 +5111,7 @@ int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks) | |||
5150 | * Give this, we know that the caller already has write access to iloc->bh. | 5111 | * Give this, we know that the caller already has write access to iloc->bh. |
5151 | */ | 5112 | */ |
5152 | int ext4_mark_iloc_dirty(handle_t *handle, | 5113 | int ext4_mark_iloc_dirty(handle_t *handle, |
5153 | struct inode *inode, struct ext4_iloc *iloc) | 5114 | struct inode *inode, struct ext4_iloc *iloc) |
5154 | { | 5115 | { |
5155 | int err = 0; | 5116 | int err = 0; |
5156 | 5117 | ||