Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dea5176 authored by Mingming Cao's avatar Mingming Cao Committed by Linus Torvalds
Browse files

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8683dc99
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -711,7 +711,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode,
	 * direct blocks blocks
	 * direct blocks blocks
	 */
	 */
	if (num == 0 && blks > 1) {
	if (num == 0 && blks > 1) {
		current_block = le32_to_cpu(where->key + 1);
		current_block = le32_to_cpu(where->key) + 1;
		for (i = 1; i < blks; i++)
		for (i = 1; i < blks; i++)
			*(where->p + i ) = cpu_to_le32(current_block++);
			*(where->p + i ) = cpu_to_le32(current_block++);
	}
	}
@@ -724,7 +724,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode,
	if (block_i) {
	if (block_i) {
		block_i->last_alloc_logical_block = block + blks - 1;
		block_i->last_alloc_logical_block = block + blks - 1;
		block_i->last_alloc_physical_block =
		block_i->last_alloc_physical_block =
				le32_to_cpu(where[num].key + blks - 1);
				le32_to_cpu(where[num].key) + blks - 1;
	}
	}


	/* We are done with atomic stuff, now do the rest of housekeeping */
	/* 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,


	/* Simplest case - block found, no allocation needed */
	/* Simplest case - block found, no allocation needed */
	if (!partial) {
	if (!partial) {
		first_block = chain[depth - 1].key;
		first_block = le32_to_cpu(chain[depth - 1].key);
		clear_buffer_new(bh_result);
		clear_buffer_new(bh_result);
		count++;
		count++;
		/*map more blocks*/
		/*map more blocks*/
		while (count < maxblocks && count <= blocks_to_boundary) {
		while (count < maxblocks && count <= blocks_to_boundary) {
			unsigned long blk;

			if (!verify_chain(chain, partial)) {
			if (!verify_chain(chain, partial)) {
				/*
				/*
				 * Indirect block might be removed by
				 * Indirect block might be removed by
@@ -831,8 +833,9 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
				count = 0;
				count = 0;
				break;
				break;
			}
			}
			if (le32_to_cpu(*(chain[depth-1].p+count) ==
			blk = le32_to_cpu(*(chain[depth-1].p + count));
					(first_block + count)))

			if (blk == first_block + count)
				count++;
				count++;
			else
			else
				break;
				break;