More commit description fixups
[ext4-patch-queue.git] / ext4_unwritten_extent_delalloc_fix.patch
blob6d631d702cf19b767704dbb58fe230b0d5b8b640
1 ext4: Handle unwritten extent properly with delayed allocation
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 When using fallocate the buffer_heads are marked unwritten and unmapped.
6 We need to map them in the writepages after a get_block. Otherwise we
7 split the uninit extents, but never write the content to disk.
9 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
10 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 ---
13 fs/ext4/inode.c | 12 ++++++++++--
14 1 file changed, 10 insertions(+), 2 deletions(-)
16 Index: linux-2.6.27-rc1/fs/ext4/inode.c
17 ===================================================================
18 --- linux-2.6.27-rc1.orig/fs/ext4/inode.c 2008-08-11 14:27:43.000000000 -0700
19 +++ linux-2.6.27-rc1/fs/ext4/inode.c 2008-08-11 14:27:48.000000000 -0700
20 @@ -1720,6 +1720,13 @@ static void mpage_put_bnr_to_bhs(struct
21 if (buffer_delay(bh)) {
22 bh->b_blocknr = pblock;
23 clear_buffer_delay(bh);
24 + bh->b_bdev = inode->i_sb->s_bdev;
25 + } else if (buffer_unwritten(bh)) {
26 + bh->b_blocknr = pblock;
27 + clear_buffer_unwritten(bh);
28 + set_buffer_mapped(bh);
29 + set_buffer_new(bh);
30 + bh->b_bdev = inode->i_sb->s_bdev;
31 } else if (buffer_mapped(bh))
32 BUG_ON(bh->b_blocknr != pblock);
34 @@ -1793,7 +1800,7 @@ static void mpage_da_map_blocks(struct m
35 * If blocks are delayed marked, we need to
36 * put actual blocknr and drop delayed bit
38 - if (buffer_delay(lbh))
39 + if (buffer_delay(lbh) || buffer_unwritten(lbh))
40 mpage_put_bnr_to_bhs(mpd, next, &new);
42 /* go for the remaining blocks */
43 @@ -1802,7 +1809,8 @@ static void mpage_da_map_blocks(struct m
47 -#define BH_FLAGS ((1 << BH_Uptodate) | (1 << BH_Mapped) | (1 << BH_Delay))
48 +#define BH_FLAGS ((1 << BH_Uptodate) | (1 << BH_Mapped) | \
49 + (1 << BH_Delay) | (1 << BH_Unwritten))
52 * mpage_add_bh_to_extent - try to add one more block to extent of blocks