Whamcloud - gitweb
b=22117 Patch to limit mmp interval
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-mmp-2.6.18-vanilla.patch
index 3ce0748..38a0eb1 100644 (file)
@@ -38,7 +38,7 @@ Index: linux-stage/fs/ext3/super.c
        if (sbi->s_dev_proc) {
                remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
                sbi->s_dev_proc = NULL;
-@@ -1375,7 +1379,7 @@ static int ext3_check_descriptors (struc
+@@ -1395,7 +1399,7 @@ static int ext3_check_descriptors (struc
                        return 0;
                }
                if (!ext3_group_desc_csum_verify(sbi, i, gdp)) {
@@ -47,7 +47,7 @@ Index: linux-stage/fs/ext3/super.c
                                   "Checksum for group %d failed (%u!=%u)\n", i,
                                   le16_to_cpu(ext3_group_desc_csum(sbi,i,gdp)),
                                   le16_to_cpu(gdp->bg_checksum));
-@@ -1470,7 +1474,7 @@ static void ext3_orphan_cleanup (struct 
+@@ -1490,7 +1494,7 @@ static void ext3_orphan_cleanup (struct 
                if (inode->i_nlink) {
                        printk(KERN_DEBUG
                                "%s: truncating inode %lu to %Ld bytes\n",
@@ -56,7 +56,7 @@ Index: linux-stage/fs/ext3/super.c
                        jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
                                  inode->i_ino, inode->i_size);
                        ext3_truncate(inode);
-@@ -1478,7 +1482,7 @@ static void ext3_orphan_cleanup (struct 
+@@ -1498,7 +1502,7 @@ static void ext3_orphan_cleanup (struct 
                } else {
                        printk(KERN_DEBUG
                                "%s: deleting unreferenced inode %lu\n",
@@ -65,7 +65,7 @@ Index: linux-stage/fs/ext3/super.c
                        jbd_debug(2, "deleting unreferenced inode %lu\n",
                                  inode->i_ino);
                        nr_orphans++;
-@@ -1548,6 +1552,346 @@ static ext3_fsblk_t descriptor_loc(struc
+@@ -1568,6 +1572,355 @@ static ext3_fsblk_t descriptor_loc(struc
        return (has_super + ext3_group_first_block_no(sb, bg));
  }
  
@@ -149,9 +149,9 @@ Index: linux-stage/fs/ext3/super.c
 + */
 +static int kmmpd(void *data)
 +{
-+      struct super_block *sb = (struct super_block *) data;
++      struct super_block *sb = ((struct mmpd_data *) data)->sb;
++      struct buffer_head *bh = ((struct mmpd_data *) data)->bh;
 +      struct ext3_super_block *es = EXT3_SB(sb)->s_es;
-+      struct buffer_head *bh = NULL;
 +      struct mmp_struct *mmp;
 +      unsigned long mmp_block;
 +      u32 seq = 0;
@@ -163,17 +163,13 @@ Index: linux-stage/fs/ext3/super.c
 +      int retval;
 +
 +      mmp_block = le64_to_cpu(es->s_mmp_block);
-+      retval = read_mmp_block(sb, &bh, mmp_block);
-+      if (retval)
-+              goto failed;
-+
 +      mmp = (struct mmp_struct *)(bh->b_data);
 +      mmp->mmp_time = cpu_to_le64(get_seconds());
 +      /*
 +       * Start with the higher mmp_check_interval and reduce it if
 +       * the MMP block is being updated on time.
 +       */
-+      mmp_check_interval = max(5 * mmp_update_interval,
++      mmp_check_interval = max(5UL * mmp_update_interval,
 +                               EXT3_MMP_MIN_CHECK_INTERVAL);
 +      mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
 +      bdevname(bh->b_bdev, mmp->mmp_bdevname);
@@ -206,7 +202,7 @@ Index: linux-stage/fs/ext3/super.c
 +                  EXT3_FEATURE_INCOMPAT_MMP)) {
 +                      ext3_warning(sb, __func__, "kmmpd being stopped "
 +                                   "since MMP feature has been disabled.");
-+                      EXT3_SB(sb)->s_mmp_tsk = 0;
++                      EXT3_SB(sb)->s_mmp_tsk = NULL;
 +                      goto failed;
 +              }
 +
@@ -214,7 +210,7 @@ Index: linux-stage/fs/ext3/super.c
 +                      ext3_warning(sb, __func__, "kmmpd being stopped "
 +                                   "since filesystem has been remounted as "
 +                                   "readonly.");
-+                      EXT3_SB(sb)->s_mmp_tsk = 0;
++                      EXT3_SB(sb)->s_mmp_tsk = NULL;
 +                      goto failed;
 +              }
 +
@@ -235,19 +231,23 @@ Index: linux-stage/fs/ext3/super.c
 +
 +                      retval = read_mmp_block(sb, &bh_check, mmp_block);
 +                      if (retval) {
-+                              EXT3_SB(sb)->s_mmp_tsk = 0;
++                              ext3_error(sb, __func__, "error reading MMP"
++                                         "data: %d", retval);
++                              EXT3_SB(sb)->s_mmp_tsk = NULL;
 +                              goto failed;
 +                      }
 +
 +                      mmp_check = (struct mmp_struct *)(bh_check->b_data);
-+                      if (mmp->mmp_time != mmp_check->mmp_time ||
++                      if (mmp->mmp_seq != mmp_check->mmp_seq ||
 +                          memcmp(mmp->mmp_nodename, mmp_check->mmp_nodename,
-+                                 sizeof(mmp->mmp_nodename)))
++                                 sizeof(mmp->mmp_nodename))) {
 +                              dump_mmp_msg(sb, mmp_check, __func__,
 +                                           "Error while updating MMP info. "
 +                                           "The filesystem seems to have "
 +                                           "been multiply mounted.");
-+
++                              ext3_error(sb, __func__, "abort");
++                              goto failed;
++                      }
 +                      put_bh(bh_check);
 +              }
 +
@@ -255,8 +255,9 @@ Index: linux-stage/fs/ext3/super.c
 +               * Adjust the mmp_check_interval depending on how much time
 +               * it took for the MMP block to be written.
 +               */
-+              mmp_check_interval = max(5 * diff / HZ,
-+                               (unsigned long) EXT3_MMP_MIN_CHECK_INTERVAL);
++              mmp_check_interval = max(min(5 * diff / HZ,
++                                           EXT3_MMP_MAX_CHECK_INTERVAL),
++                                       EXT3_MMP_MIN_CHECK_INTERVAL);
 +              mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
 +      }
 +
@@ -297,6 +298,7 @@ Index: linux-stage/fs/ext3/super.c
 +      struct ext3_super_block *es = EXT3_SB(sb)->s_es;
 +      struct buffer_head *bh = NULL;
 +      struct mmp_struct *mmp = NULL;
++      struct mmpd_data *mmpd_data;
 +      u32 seq;
 +      unsigned int mmp_check_interval = le16_to_cpu(es->s_mmp_update_interval);
 +      unsigned int wait_time = 0;
@@ -388,20 +390,27 @@ Index: linux-stage/fs/ext3/super.c
 +              goto failed;
 +      }
 +
++      mmpd_data = kmalloc(sizeof(struct mmpd_data *), GFP_KERNEL);
++      if (!mmpd_data) {
++              ext3_warning(sb, KERN_ERR, "not enough memory for mmpd_data");
++              goto failed;
++      }
++      mmpd_data->sb = sb;
++      mmpd_data->bh = bh;
++
 +      /*
 +       * Start a kernel thread to update the MMP block periodically.
 +       */
-+      EXT3_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, sb, "kmmpd-%02x:%02x",
-+                                           MAJOR(sb->s_dev),
-+                                           MINOR(sb->s_dev));
++      EXT3_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, mmpd_data, "kmmpd-%s",
++                                           bdevname(bh->b_bdev,
++                                                    mmp->mmp_bdevname));
 +      if (IS_ERR(EXT3_SB(sb)->s_mmp_tsk)) {
-+              EXT3_SB(sb)->s_mmp_tsk = 0;
++              EXT3_SB(sb)->s_mmp_tsk = NULL;
 +              ext3_warning(sb, __func__, "Unable to create kmmpd thread "
 +                           "for %s.", sb->s_id);
 +              goto failed;
 +      }
 +
-+      brelse(bh);
 +      return 0;
 +
 +failed:
@@ -412,7 +421,7 @@ Index: linux-stage/fs/ext3/super.c
  
  static int ext3_fill_super (struct super_block *sb, void *data, int silent)
  {
-@@ -1880,6 +2224,11 @@ static int ext3_fill_super (struct super
+@@ -1901,6 +2254,11 @@ static int ext3_fill_super (struct super
                          EXT3_HAS_INCOMPAT_FEATURE(sb,
                                    EXT3_FEATURE_INCOMPAT_RECOVER));
  
@@ -424,7 +433,7 @@ Index: linux-stage/fs/ext3/super.c
        /*
         * The first inode we look at is the journal inode.  Don't try
         * root first: it may be modified in the journal!
-@@ -2012,6 +2361,8 @@ cantfind_ext3:
+@@ -2033,6 +2391,8 @@ cantfind_ext3:
  failed_mount4:
        journal_destroy(sbi->s_journal);
  failed_mount3:
@@ -433,7 +442,7 @@ Index: linux-stage/fs/ext3/super.c
        percpu_counter_destroy(&sbi->s_freeblocks_counter);
        percpu_counter_destroy(&sbi->s_freeinodes_counter);
        percpu_counter_destroy(&sbi->s_dirs_counter);
-@@ -2388,9 +2739,9 @@ static void ext3_clear_journal_err(struc
+@@ -2409,9 +2769,9 @@ static void ext3_clear_journal_err(struc
                char nbuf[16];
  
                errstr = ext3_decode_error(sb, j_errno, nbuf);
@@ -445,7 +454,7 @@ Index: linux-stage/fs/ext3/super.c
                             "filesystem check.");
  
                EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
-@@ -2510,7 +2861,7 @@ static int ext3_remount (struct super_bl
+@@ -2531,7 +2891,7 @@ static int ext3_remount (struct super_bl
        ext3_fsblk_t n_blocks_count = 0;
        unsigned long old_sb_flags;
        struct ext3_mount_options old_opts;
@@ -454,7 +463,7 @@ Index: linux-stage/fs/ext3/super.c
  #ifdef CONFIG_QUOTA
        int i;
  #endif
-@@ -2536,7 +2887,7 @@ static int ext3_remount (struct super_bl
+@@ -2557,7 +2917,7 @@ static int ext3_remount (struct super_bl
        }
  
        if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
@@ -463,7 +472,7 @@ Index: linux-stage/fs/ext3/super.c
  
        sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
-@@ -2609,6 +2960,13 @@ static int ext3_remount (struct super_bl
+@@ -2630,6 +2990,13 @@ static int ext3_remount (struct super_bl
                        }
                        if (!ext3_setup_super (sb, es, 0))
                                sb->s_flags &= ~MS_RDONLY;
@@ -518,7 +527,7 @@ Index: linux-stage/include/linux/ext3_fs.h
  #define EXT3_FEATURE_RO_COMPAT_SUPP   (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
                                         EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
                                         EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
-@@ -871,6 +877,39 @@ ext3_group_first_block_no(struct super_b
+@@ -871,6 +877,50 @@ ext3_group_first_block_no(struct super_b
  #define ERR_BAD_DX_DIR        -75000
  
  /*
@@ -544,6 +553,12 @@ Index: linux-stage/include/linux/ext3_fs.h
 +      __le32  mmp_pad2[227];
 +};
 +
++/* arguments passed to the mmp thread */
++struct mmpd_data {
++      struct buffer_head *bh; /* bh from initial read_mmp_block() */
++      struct super_block *sb;  /* super block of the fs */
++};
++
 +/*
 + * Default interval in seconds to update the MMP sequence number.
 + */
@@ -552,7 +567,12 @@ Index: linux-stage/include/linux/ext3_fs.h
 +/*
 + * Minimum interval for MMP checking in seconds.
 + */
-+#define EXT3_MMP_MIN_CHECK_INTERVAL   5
++#define EXT3_MMP_MIN_CHECK_INTERVAL   5UL
++
++/*
++ * Maximum interval for MMP checking in seconds.
++ */
++#define EXT3_MMP_MAX_CHECK_INTERVAL   300UL
 +
 +/*
   * Function prototypes
@@ -562,11 +582,12 @@ Index: linux-stage/include/linux/ext3_fs_sb.h
 ===================================================================
 --- linux-stage.orig/include/linux/ext3_fs_sb.h
 +++ linux-stage/include/linux/ext3_fs_sb.h
-@@ -156,6 +156,7 @@ struct ext3_sb_info {
+@@ -157,6 +157,8 @@ struct ext3_sb_info {
        /* locality groups */
        struct ext3_locality_group *s_locality_groups;
  
-+      struct task_struct *s_mmp_tsk;  /* Kernel thread for multiple mount protection */
++      /* Kernel thread for multiple mount protection */
++      struct task_struct *s_mmp_tsk;
  };
  
  #define EXT3_GROUP_INFO(sb, group)                                       \