Whamcloud - gitweb
LU-12477 ldiskfs: remove obsolete ext4 patches
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-corrupted-inode-block-bitmaps-handling-patches.patch
diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
deleted file mode 100644 (file)
index 3b845e2..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
-index db5b7a3..332078f 100644
---- a/fs/ext4/balloc.c
-+++ b/fs/ext4/balloc.c
-@@ -99,12 +99,11 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
-               /* If checksum is bad mark all blocks used to prevent allocation
-                * essentially implementing a per-group read-only flag. */
-               if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
--                      ext4_error(sb, "Checksum bad for group %u",
-+                      ext4_corrupted_block_group(sb, block_group,
-+                                      EXT4_GROUP_INFO_BBITMAP_CORRUPT |
-+                                      EXT4_GROUP_INFO_IBITMAP_CORRUPT,
-+                                      "Checksum bad for group %u",
-                                       block_group);
--                      ext4_free_blks_set(sb, gdp, 0);
--                      ext4_free_inodes_set(sb, gdp, 0);
--                      ext4_itable_unused_set(sb, gdp, 0);
--                      memset(bh->b_data, 0xff, sb->s_blocksize);
-                       return 0;
-               }
-               memset(bh->b_data, 0, sb->s_blocksize);
-@@ -279,8 +278,10 @@ static int ext4_valid_block_bitmap(struct super_block *sb,
-               return 1;
- err_out:
--      ext4_error(sb, "Invalid block bitmap - block_group = %d, block = %llu",
--                      block_group, bitmap_blk);
-+      ext4_corrupted_block_group(sb, block_group,
-+                                 EXT4_GROUP_INFO_BBITMAP_CORRUPT,
-+                                 "Invalid block bitmap - block_group = %d, block = %llu",
-+                                 block_group, bitmap_blk);
-       return 0;
- }
- /**
-diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
-index a18fd36..949d7be 100644
---- a/fs/ext4/ext4.h
-+++ b/fs/ext4/ext4.h
-@@ -78,6 +78,18 @@ typedef __u32 ext4_lblk_t;
- /* data type for block group number */
- typedef unsigned int ext4_group_t;
-+void __ext4_corrupted_block_group(struct super_block *sb,
-+                                ext4_group_t group, unsigned int flags,
-+                                const char *function,
-+                                unsigned int line);
-+
-+#define ext4_corrupted_block_group(sb, group, flags, fmt...)          \
-+      do {                                                            \
-+              __ext4_warning(sb, __func__, __LINE__, ## fmt);         \
-+              __ext4_corrupted_block_group(sb, group, flags,          \
-+                      __func__, __LINE__);                            \
-+      } while (0)
-+
- /*
-  * Flags used in mballoc's allocation_context flags field.
-  *
-@@ -2257,9 +2269,19 @@ struct ext4_group_info {
- #define EXT4_GROUP_INFO_NEED_INIT_BIT         0
- #define EXT4_GROUP_INFO_WAS_TRIMMED_BIT               1
-+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT   2
-+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT               \
-+              (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT)
-+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT   3
-+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT               \
-+              (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT)
- #define EXT4_MB_GRP_NEED_INIT(grp)    \
-       (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
-+#define EXT4_MB_GRP_BBITMAP_CORRUPT(grp)      \
-+      (test_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
-+#define EXT4_MB_GRP_IBITMAP_CORRUPT(grp)      \
-+      (test_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &((grp)->bb_state)))
- #define EXT4_MB_GRP_WAS_TRIMMED(grp)  \
-       (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
-diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
-index 532dcaa..6082e54 100644
---- a/fs/ext4/ialloc.c
-+++ b/fs/ext4/ialloc.c
-@@ -78,11 +78,10 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb,
-       /* If checksum is bad mark all blocks and inodes use to prevent
-        * allocation, essentially implementing a per-group read-only flag. */
-       if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
--              ext4_error(sb, "Checksum bad for group %u", block_group);
--              ext4_free_blks_set(sb, gdp, 0);
--              ext4_free_inodes_set(sb, gdp, 0);
--              ext4_itable_unused_set(sb, gdp, 0);
--              memset(bh->b_data, 0xff, sb->s_blocksize);
-+              ext4_corrupted_block_group(sb, block_group,
-+                              EXT4_GROUP_INFO_BBITMAP_CORRUPT |
-+                              EXT4_GROUP_INFO_IBITMAP_CORRUPT,
-+                              "Checksum bad for group %u", block_group);
-               return 0;
-       }
-@@ -195,6 +194,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
-       struct ext4_super_block *es;
-       struct ext4_sb_info *sbi;
-       int fatal = 0, err, count, cleared;
-+      struct ext4_group_info *grp;
-       if (atomic_read(&inode->i_count) > 1) {
-               printk(KERN_ERR "ext4_free_inode: inode has count=%d\n",
-@@ -238,7 +238,9 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
-       block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
-       bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
-       bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
--      if (!bitmap_bh)
-+      /* Don't bother if the inode bitmap is corrupt. */
-+      grp = ext4_get_group_info(sb, block_group);
-+      if (unlikely(EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) || !bitmap_bh)
-               goto error_return;
-       BUFFER_TRACE(bitmap_bh, "get_write_access");
-@@ -286,8 +288,12 @@ out:
-               if (!fatal)
-                       fatal = err;
-               ext4_mark_super_dirty(sb);
--      } else
--              ext4_error(sb, "bit already cleared for inode %lu", ino);
-+      } else {
-+              ext4_corrupted_block_group(sb, block_group,
-+                              EXT4_GROUP_INFO_IBITMAP_CORRUPT,
-+                              "bit already cleared for inode %lu",
-+                              ino);
-+      }
- error_return:
-       brelse(bitmap_bh);
-@@ -820,6 +826,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
-       int free = 0;
-       static int once = 1;
-       ext4_group_t flex_group;
-+      struct ext4_group_info *grp;
-       /* Cannot create files in a deleted directory */
-       if (!dir || !dir->i_nlink)
-@@ -879,10 +886,21 @@ got_group:
-               if (!gdp)
-                       goto fail;
-+              grp = ext4_get_group_info(sb, group);
-+              /* Skip groups with already-known suspicious inode tables */
-+              if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
-+                      if (++group == ngroups)
-+                              group = 0;
-+                      continue;
-+              }
-               brelse(inode_bitmap_bh);
-               inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
--              if (!inode_bitmap_bh)
--                      goto fail;
-+              /* Skip groups with suspicious inode tables */
-+              if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh) {
-+                      if (++group == ngroups)
-+                              group = 0;
-+                      continue;
-+              }
- repeat_in_this_group:
-               ino = ext4_find_next_zero_bit((unsigned long *)
-diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
-index 1d77581..4d6558e 100644
---- a/fs/ext4/mballoc.c
-+++ b/fs/ext4/mballoc.c
-@@ -740,7 +740,6 @@ int ext4_mb_generate_buddy(struct super_block *sb,
-                                     "%u blocks in bitmap, %u in bb, %u in gd",
-                                     free, grp->bb_free,
-                                     ext4_free_blks_count(sb, gdp));
--
-               /*
-                * If we intent to continue, we consider group descritor
-                * corrupt and update bb_free using bitmap value
-@@ -1124,7 +1123,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
-       int block;
-       int pnum;
-       int poff;
--      struct page *page;
-+      struct page *page = NULL;
-       int ret;
-       struct ext4_group_info *grp;
-       struct ext4_sb_info *sbi = EXT4_SB(sb);
-@@ -1149,7 +1148,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
-                */
-               ret = ext4_mb_init_group(sb, group);
-               if (ret)
--                      return ret;
-+                      goto err;
-       }
-       /*
-@@ -1233,6 +1232,8 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
-       return 0;
- err:
-+      ext4_warning(sb, "Error in loading buddy information for %u",
-+                      group);
-       if (page)
-               page_cache_release(page);
-       if (e4b->bd_bitmap_page)
-@@ -1322,6 +1323,10 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
-       BUG_ON(first + count > (sb->s_blocksize << 3));
-       assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
-+      /* Don't bother if the block group is corrupt. */
-+      if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
-+              return;
-+
-       mb_check_buddy(e4b);
-       mb_free_blocks_double(inode, e4b, first, count);
-@@ -1729,6 +1734,11 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
-       if (err)
-               return err;
-+      if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) {
-+              ext4_mb_unload_buddy(e4b);
-+              return 0;
-+      }
-+
-       ext4_lock_group(ac->ac_sb, group);
-       max = mb_find_extent(e4b, 0, ac->ac_g_ex.fe_start,
-                            ac->ac_g_ex.fe_len, &ex);
-@@ -1940,6 +1950,9 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac,
-       BUG_ON(cr < 0 || cr >= 4);
-+      if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp)))
-+              return 0;
-+
-       /* We only do this if the grp has never been initialized */
-       if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
-               int ret = ext4_mb_init_group(ac->ac_sb, group);
-@@ -3458,9 +3471,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap,
-       }
-       if (free != free_in_gdp) {
--              ext4_error(sb, "on-disk bitmap for group %d"
--                      "corrupted: %u blocks free in bitmap, %u - in gd\n",
--                      group, free, free_in_gdp);
-+              ext4_corrupted_block_group(sb, group,
-+                              EXT4_GROUP_INFO_BBITMAP_CORRUPT,
-+                              "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n",
-+                              group, free,
-+                              free_in_gdp);
-               return -EIO;
-       }
-       return 0;
-@@ -3813,17 +3828,9 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
-        * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
--              ext4_error(sb, "pa free mismatch: [pa %p] "
--                              "[phy %lu] [logic %lu] [len %u] [free %u] "
--                              "[error %u] [inode %lu] [freed %u]", pa,
--                              (unsigned long)pa->pa_pstart,
--                              (unsigned long)pa->pa_lstart,
--                              (unsigned)pa->pa_len, (unsigned)pa->pa_free,
--                              (unsigned)pa->pa_error, pa->pa_inode->i_ino,
--                              free);
-               ext4_grp_locked_error(sb, group, 0, 0,
--                                      "free %u, pa_free %u",
--                                      free, pa->pa_free);
-+                                    "free %u, pa_free %u",
-+                                    free, pa->pa_free);
-               /*
-                * pa is already deleted so we use the value obtained
-                * from the bitmap and continue.
-@@ -3883,14 +3890,11 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
-               return 0;
-       bitmap_bh = ext4_read_block_bitmap(sb, group);
--      if (bitmap_bh == NULL) {
--              ext4_error(sb, "Error reading block bitmap for %u", group);
-+      if (bitmap_bh == NULL)
-               return 0;
--      }
-       err = ext4_mb_load_buddy(sb, group, &e4b);
-       if (err) {
--              ext4_error(sb, "Error loading buddy information for %u", group);
-               put_bh(bitmap_bh);
-               return 0;
-       }
-@@ -4054,16 +4058,11 @@ repeat:
-               ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
-               err = ext4_mb_load_buddy(sb, group, &e4b);
--              if (err) {
--                      ext4_error(sb, "Error loading buddy information for %u",
--                                      group);
-+              if (err)
-                       return;
--              }
-               bitmap_bh = ext4_read_block_bitmap(sb, group);
-               if (bitmap_bh == NULL) {
--                      ext4_error(sb, "Error reading block bitmap for %u",
--                                      group);
-                       ext4_mb_unload_buddy(&e4b);
-                       continue;
-               }
-@@ -4324,11 +4323,8 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
-       list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) {
-               ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
--              if (ext4_mb_load_buddy(sb, group, &e4b)) {
--                      ext4_error(sb, "Error loading buddy information for %u",
--                                      group);
-+              if (ext4_mb_load_buddy(sb, group, &e4b))
-                       continue;
--              }
-               ext4_lock_group(sb, group);
-               list_del(&pa->pa_group_list);
-               ext4_get_group_info(sb, group)->bb_prealloc_nr--;
-@@ -4585,7 +4581,7 @@ repeat:
-                       * been updated or not when fail case. So can
-                       * not revert pa_free back, just mark pa_error*/
-                       pa->pa_error++;
--                      ext4_error(sb,
-+                      ext4_corrupted_block_group(sb, 0, 0,
-                               "Updating bitmap error: [err %d] "
-                               "[pa %p] [phy %lu] [logic %lu] "
-                               "[len %u] [free %u] [error %u] "
-@@ -4731,6 +4727,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
-       struct ext4_buddy e4b;
-       int err = 0;
-       int ret;
-+      int skip_error = 0;
-       if (bh) {
-               if (block)
-@@ -4781,6 +4778,10 @@ do_more:
-       overflow = 0;
-       ext4_get_group_no_and_offset(sb, block, &block_group, &bit);
-+      if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(
-+                      ext4_get_group_info(sb, block_group))))
-+              return;
-+
-       /*
-        * Check to see if we are freeing blocks across a group
-        * boundary.
-@@ -4837,8 +4838,10 @@ do_more:
-       trace_ext4_mballoc_free(sb, inode, block_group, bit, count);
-       err = ext4_mb_load_buddy(sb, block_group, &e4b);
--      if (err)
-+      if (err) {
-+              skip_error = 1;
-               goto error_return;
-+      }
-       if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) {
-               struct ext4_free_data *new_entry;
-@@ -4905,8 +4908,9 @@ do_more:
- error_return:
-       if (freed && !(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE))
-               dquot_free_block(inode, freed);
-+      if (!skip_error)
-+              ext4_std_error(sb, err);
-       brelse(bitmap_bh);
--      ext4_std_error(sb, err);
-       return;
- }
-@@ -4991,7 +4995,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
-       err = ext4_mb_load_buddy(sb, block_group, &e4b);
-       if (err)
--              goto error_return;
-+              goto error_brelse;
-       /*
-        * need to update group_info->bb_free and bitmap
-@@ -5026,8 +5030,9 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
-               err = ret;
- error_return:
--      brelse(bitmap_bh);
-       ext4_std_error(sb, err);
-+error_brelse:
-+      brelse(bitmap_bh);
-       return;
- }
-@@ -5094,11 +5099,8 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
-       int ret;
-       ret = ext4_mb_load_buddy(sb, group, &e4b);
--      if (ret) {
--              ext4_error(sb, "Error in loading buddy "
--                              "information for %u", group);
-+      if (ret)
-               return ret;
--      }
-       bitmap = e4b.bd_bitmap;
-       ext4_lock_group(sb, group);
-diff --git a/fs/ext4/super.c b/fs/ext4/super.c
-index a21e903..2fca810 100644
---- a/fs/ext4/super.c
-+++ b/fs/ext4/super.c
-@@ -666,6 +666,32 @@ void __ext4_warning(struct super_block *sb, const char *function,
-       va_end(args);
- }
-+void __ext4_corrupted_block_group(struct super_block *sb, ext4_group_t group,
-+                                unsigned int flags, const char *function,
-+                                unsigned int line)
-+{
-+      struct ext4_group_info *grp = ext4_get_group_info(sb, group);
-+      struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL);
-+
-+      if (flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT &&
-+          !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) {
-+              ext4_free_blks_set(sb, gdp, 0);
-+              set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT,
-+                      &grp->bb_state);
-+      }
-+
-+      if (flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT &&
-+          !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
-+              if (gdp) {
-+                      ext4_free_inodes_set(sb, gdp, 0);
-+                      ext4_itable_unused_set(sb, gdp, 0);
-+              }
-+              set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT,
-+                      &grp->bb_state);
-+      }
-+      save_error_info(sb, function, line);
-+}
-+
- void __ext4_grp_locked_error(const char *function, unsigned int line,
-                            struct super_block *sb, ext4_group_t grp,
-                            unsigned long ino, ext4_fsblk_t block,