]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/ext4/inode.c
ext4: Fix sub-block zeroing for writes into preallocated extents
[net-next-2.6.git] / fs / ext4 / inode.c
index e91f978c7f12848616855876628189a44a6885f8..d4b634ae06bdce9aee783633a2bd816df54ebcc0 100644 (file)
@@ -2323,6 +2323,13 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
                set_buffer_delay(bh_result);
        } else if (ret > 0) {
                bh_result->b_size = (ret << inode->i_blkbits);
+               /*
+                * With sub-block writes into unwritten extents
+                * we also need to mark the buffer as new so that
+                * the unwritten parts of the buffer gets correctly zeroed.
+                */
+               if (buffer_unwritten(bh_result))
+                       set_buffer_new(bh_result);
                ret = 0;
        }