diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index bbea2dccd584384cafb7b2f1730baab05cd2d46f..2b00bf84c05bca35f13eb671b56ac2cdb17048f4 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -474,7 +474,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
 	endoff = (loff_t)end_blk << blkbits;
 
 	index = startoff >> PAGE_SHIFT;
-	end = endoff >> PAGE_SHIFT;
+	end = (endoff - 1) >> PAGE_SHIFT;
 
 	pagevec_init(&pvec, 0);
 	do {