Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[muen/linux.git] / fs / ext4 / mballoc.c
index 6884e81c1465ae8a08071134d67c857654b94b2d..6eae2b91aafa20b21fd19c61bb15fa7add625935 100644 (file)
@@ -470,6 +470,8 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b,
                                              "freeing block already freed "
                                              "(bit %u)",
                                              first + i);
+                       ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
+                                       EXT4_GROUP_INFO_BBITMAP_CORRUPT);
                }
                mb_clear_bit(first + i, e4b->bd_info->bb_bitmap);
        }
@@ -747,10 +749,8 @@ void ext4_mb_generate_buddy(struct super_block *sb,
                 * corrupt and update bb_free using bitmap value
                 */
                grp->bb_free = free;
-               if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
-                       percpu_counter_sub(&sbi->s_freeclusters_counter,
-                                          grp->bb_free);
-               set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state);
+               ext4_mark_group_bitmap_corrupted(sb, group,
+                                       EXT4_GROUP_INFO_BBITMAP_CORRUPT);
        }
        mb_set_largest_free_order(sb, grp);
 
@@ -1454,12 +1454,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
                                      "freeing already freed block "
                                      "(bit %u); block bitmap corrupt.",
                                      block);
-               if (!EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))
-                       percpu_counter_sub(&sbi->s_freeclusters_counter,
-                                          e4b->bd_info->bb_free);
-               /* Mark the block group as corrupt. */
-               set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT,
-                       &e4b->bd_info->bb_state);
+               ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
+                               EXT4_GROUP_INFO_BBITMAP_CORRUPT);
                mb_regenerate_buddy(e4b);
                goto done;
        }
@@ -1956,6 +1952,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
                                        "%d free clusters as per "
                                        "group info. But bitmap says 0",
                                        free);
+                       ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
+                                       EXT4_GROUP_INFO_BBITMAP_CORRUPT);
                        break;
                }
 
@@ -1966,6 +1964,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
                                        "%d free clusters as per "
                                        "group info. But got %d blocks",
                                        free, ex.fe_len);
+                       ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
+                                       EXT4_GROUP_INFO_BBITMAP_CORRUPT);
                        /*
                         * The number of free blocks differs. This mostly
                         * indicate that the bitmap is corrupt. So exit
@@ -2516,8 +2516,7 @@ static void ext4_groupinfo_destroy_slabs(void)
        int i;
 
        for (i = 0; i < NR_GRPINFO_CACHES; i++) {
-               if (ext4_groupinfo_caches[i])
-                       kmem_cache_destroy(ext4_groupinfo_caches[i]);
+               kmem_cache_destroy(ext4_groupinfo_caches[i]);
                ext4_groupinfo_caches[i] = NULL;
        }
 }