From: Chris Mason This patch fixes a problem we're hitting on ia64 with page sizes > 4k. When the page size is greater than the block size, and parts of the page fall past the end of the device, readpage will fail because blkdev_get_block returns -EIO for blocks past i_size. The attached patch changes blkdev_get_block to return holes when reading past the end of the device, which allows us to read that last valid 4k block and then fill the rest of the page with zeros. Writes will still fail with -EIO. --- 25-akpm/fs/block_dev.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff -puN fs/block_dev.c~blkdev-fix-final-page fs/block_dev.c --- 25/fs/block_dev.c~blkdev-fix-final-page Tue Mar 9 13:56:22 2004 +++ 25-akpm/fs/block_dev.c Tue Mar 9 13:56:22 2004 @@ -116,9 +116,18 @@ static int blkdev_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh, int create) { - if (iblock >= max_block(I_BDEV(inode))) - return -EIO; + if (iblock >= max_block(I_BDEV(inode))) { + if (create) + return -EIO; + /* + * for reads, we're just trying to fill a partial page. + * return a hole, they will have to call get_block again + * before they can fill it, and they will get -EIO at that + * time + */ + return 0; + } bh->b_bdev = I_BDEV(inode); bh->b_blocknr = iblock; set_buffer_mapped(bh); _