diff options
author | Mingming Cao <cmm@us.ibm.com> | 2006-05-03 22:55:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-05-03 23:05:41 -0400 |
commit | 5dea5176e5c32ef9f0d1a41d28427b3bf6881b3a (patch) | |
tree | f7b6639fa6490bb9a519f50acf0c76fa087d295b /fs/ext3/inode.c | |
parent | 8683dc9990158c221e05959935e7dd50a956c574 (diff) |
[PATCH] ext3: multile block allocate little endian fixes
Some places in ext3 multiple block allocation code (in 2.6.17-rc3) don't
handle the little endian well. This was resulting in *wrong* block numbers
being assigned to in-memory block variables and then stored on disk
eventually. The following patch has been verified to fix an ext3
filesystem failure when run ltp test on a 64 bit machine.
Signed-off-by; Mingming Cao <cmm@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext3/inode.c')
-rw-r--r-- | fs/ext3/inode.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 48ae0339af17..2edd7eec88fd 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -711,7 +711,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode, | |||
711 | * direct blocks blocks | 711 | * direct blocks blocks |
712 | */ | 712 | */ |
713 | if (num == 0 && blks > 1) { | 713 | if (num == 0 && blks > 1) { |
714 | current_block = le32_to_cpu(where->key + 1); | 714 | current_block = le32_to_cpu(where->key) + 1; |
715 | for (i = 1; i < blks; i++) | 715 | for (i = 1; i < blks; i++) |
716 | *(where->p + i ) = cpu_to_le32(current_block++); | 716 | *(where->p + i ) = cpu_to_le32(current_block++); |
717 | } | 717 | } |
@@ -724,7 +724,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode, | |||
724 | if (block_i) { | 724 | if (block_i) { |
725 | block_i->last_alloc_logical_block = block + blks - 1; | 725 | block_i->last_alloc_logical_block = block + blks - 1; |
726 | block_i->last_alloc_physical_block = | 726 | block_i->last_alloc_physical_block = |
727 | le32_to_cpu(where[num].key + blks - 1); | 727 | le32_to_cpu(where[num].key) + blks - 1; |
728 | } | 728 | } |
729 | 729 | ||
730 | /* We are done with atomic stuff, now do the rest of housekeeping */ | 730 | /* We are done with atomic stuff, now do the rest of housekeeping */ |
@@ -814,11 +814,13 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, | |||
814 | 814 | ||
815 | /* Simplest case - block found, no allocation needed */ | 815 | /* Simplest case - block found, no allocation needed */ |
816 | if (!partial) { | 816 | if (!partial) { |
817 | first_block = chain[depth - 1].key; | 817 | first_block = le32_to_cpu(chain[depth - 1].key); |
818 | clear_buffer_new(bh_result); | 818 | clear_buffer_new(bh_result); |
819 | count++; | 819 | count++; |
820 | /*map more blocks*/ | 820 | /*map more blocks*/ |
821 | while (count < maxblocks && count <= blocks_to_boundary) { | 821 | while (count < maxblocks && count <= blocks_to_boundary) { |
822 | unsigned long blk; | ||
823 | |||
822 | if (!verify_chain(chain, partial)) { | 824 | if (!verify_chain(chain, partial)) { |
823 | /* | 825 | /* |
824 | * Indirect block might be removed by | 826 | * Indirect block might be removed by |
@@ -831,8 +833,9 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode, | |||
831 | count = 0; | 833 | count = 0; |
832 | break; | 834 | break; |
833 | } | 835 | } |
834 | if (le32_to_cpu(*(chain[depth-1].p+count) == | 836 | blk = le32_to_cpu(*(chain[depth-1].p + count)); |
835 | (first_block + count))) | 837 | |
838 | if (blk == first_block + count) | ||
836 | count++; | 839 | count++; |
837 | else | 840 | else |
838 | break; | 841 | break; |