[patch] block: fix off-by-one in init_page_buffers

From: Jeff Moyer
Date: Wed Jun 20 2012 - 14:01:36 EST


Hi,

This commit:

commit 080399aaaf3531f5b8761ec0ac30ff98891e8686
Author: Jeff Moyer <jmoyer@xxxxxxxxxx>
Date: Fri May 11 16:34:10 2012 +0200

block: don't mark buffers beyond end of disk as mapped

introduced a bug whereby the last block on the device was treated as
beyond the end of the device. This causes the mount program to hang
when trying to (erroneously) mount an extended partition, as reported by
Torsten Hilbrich here: https://lkml.org/lkml/2012/6/18/54, and also
reported independently here:
http://www.sysresccd.org/forums/viewtopic.php?f=13&t=4511.

The attached patch was tested by myself and Torsten and found to resolve
the problem. I also instrumented the init_page_buffers routine to
ensure that the end_block is indeed the last block of the device.

Comments, as always, are appreciated.

--

This needs backporting to the stable trees where the offending commit
was backported. I'm sure that includes 3.0 and 3.3, but not sure where
else it was committed. Is there an easy way to tell what trees got the
commit?

CC: stable@xxxxxxxxxxxxxxx, npiggin@xxxxxxxxx
Reported-and-Tested-by: Torsten Hilbrich <torsten.hilbrich@xxxxxxxxxxx>
Signed-off-by: Jeff Moyer <jmoyer@xxxxxxxxxx>

diff --git a/fs/buffer.c b/fs/buffer.c
index 838a9cf..769b30b 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -930,7 +930,7 @@ init_page_buffers(struct page *page, struct block_device *bdev,
bh->b_blocknr = block;
if (uptodate)
set_buffer_uptodate(bh);
- if (block < end_block)
+ if (block <= end_block)
set_buffer_mapped(bh);
}
block++;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/