diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 67d8bec55fb7..e5fc3788c007 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4042,6 +4042,10 @@ void ext4_set_aops(struct inode *inode) * because it might have data in pagecache (eg, if called from ext4_zero_range, * ext4_punch_hole, etc) which needs to be properly zeroed out. Otherwise a * racing writeback can come later and flush the stale pagecache to disk. + * + * Return the loaded bh if it actually needs zeroing - in written, dirty + * unwritten, or delalloc state. Return NULL if it's clean (i.e., a hole or + * a clean unwritten block). */ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from) { @@ -4083,7 +4087,12 @@ static struct buffer_head *ext4_load_tail_bh(struct inode *inode, loff_t from) err = ext4_get_block(inode, iblock, bh, 0); if (err < 0) goto unlock; - /* unmapped? It's a hole - nothing to do */ + /* + * It's a hole or a clean unwritten block - nothing to do. + * Note that a lookup-only get_block (without + * EXT4_GET_BLOCKS_CREATE) never sets BH_Mapped for clean + * unwritten extents. + */ if (!buffer_mapped(bh)) { BUFFER_TRACE(bh, "still unmapped"); goto unlock;