Add fix-uninit-bitmap-blocks patch
[ext4-patch-queue.git] / fix-uninit-bitmap-blocks
blobb2756bf0b957858c229d374dcf134e0fd3dc0d8c
1 ext4: fix initialization of UNINIT bitmap blocks
3 From: Frederic Bohe <frederic.bohe@bull.net>
5 We must always initialize uninitialized bitmap blocks even if the
6 buffer head is marked uptodate, since it could have been read in by a
7 userspace program.  So always initialized the bitmap block if it is
8 marked uninitialzied and not dirty; it will marked initialized as soon
9 as we allocate a block or inode out of that bitmap.
11 Signed-off-by: Frederic Bohe <frederic.bohe@bull.net>
12 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 ---
15  balloc.c  |    4 +++-
16  ialloc.c  |    4 +++-
17  mballoc.c |    4 +++-
18  3 files changed, 9 insertions(+), 3 deletions(-)
20 Index: linux-2.6.27-rc5+patch_queue/fs/ext4/balloc.c
21 ===================================================================
22 --- linux-2.6.27-rc5+patch_queue.orig/fs/ext4/balloc.c  2008-09-15 10:59:27.000000000 +0200
23 +++ linux-2.6.27-rc5+patch_queue/fs/ext4/balloc.c       2008-09-15 14:03:04.000000000 +0200
24 @@ -318,9 +318,11 @@ ext4_read_block_bitmap(struct super_bloc
25                             block_group, bitmap_blk);
26                 return NULL;
27         }
28 -       if (bh_uptodate_or_lock(bh))
29 +       if (buffer_uptodate(bh) &&
30 +           !(desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)))
31                 return bh;
33 +       lock_buffer(bh);
34         spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
35         if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
36                 ext4_init_block_bitmap(sb, bh, block_group, desc);
37 Index: linux-2.6.27-rc5+patch_queue/fs/ext4/ialloc.c
38 ===================================================================
39 --- linux-2.6.27-rc5+patch_queue.orig/fs/ext4/ialloc.c  2008-09-15 10:59:27.000000000 +0200
40 +++ linux-2.6.27-rc5+patch_queue/fs/ext4/ialloc.c       2008-09-15 11:12:16.000000000 +0200
41 @@ -115,9 +115,11 @@ ext4_read_inode_bitmap(struct super_bloc
42                             block_group, bitmap_blk);
43                 return NULL;
44         }
45 -       if (bh_uptodate_or_lock(bh))
46 +       if (buffer_uptodate(bh) &&
47 +           !(desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)))
48                 return bh;
50 +       lock_buffer(bh);
51         spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
52         if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
53                 ext4_init_inode_bitmap(sb, bh, block_group, desc);
54 Index: linux-2.6.27-rc5+patch_queue/fs/ext4/mballoc.c
55 ===================================================================
56 --- linux-2.6.27-rc5+patch_queue.orig/fs/ext4/mballoc.c 2008-09-15 10:59:27.000000000 +0200
57 +++ linux-2.6.27-rc5+patch_queue/fs/ext4/mballoc.c      2008-09-15 14:02:44.000000000 +0200
58 @@ -785,9 +785,11 @@ static int ext4_mb_init_cache(struct pag
59                 if (bh[i] == NULL)
60                         goto out;
62 -               if (bh_uptodate_or_lock(bh[i]))
63 +               if (buffer_uptodate(bh[i]) &&
64 +                   !(desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)))
65                         continue;
67 +               lock_buffer(bh[i]);
68                 spin_lock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
69                 if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
70                         ext4_init_block_bitmap(sb, bh[i],
75 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
76 the body of a message to majordomo@vger.kernel.org
77 More majordomo info at  http://vger.kernel.org/majordomo-info.html