Whamcloud - gitweb
LU-4478 ldiskfs: fix problem when ldiskfs_acct_on() fails 38/10938/2
authorLi Xi <lixi@ddn.com>
Wed, 2 Jul 2014 04:15:03 +0000 (12:15 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 9 Jul 2014 15:36:10 +0000 (15:36 +0000)
ldiskfs_fill_super() does not handle the failure ldiskfs_acct_on()
returns correctly. This patch fixes the problem for RHEL6.5 kernel.

Signed-off-by: Li Xi <lixi@ddn.com>
Change-Id: Id6e9af30ac81b54c2873b8c2f2a8efd398398a8d
Reviewed-on: http://review.whamcloud.com/10938
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
ldiskfs/kernel_patches/patches/rhel6.5/ext4-quota-first-class.patch

index b7c2a0b..fdb57d7 100644 (file)
@@ -28,11 +28,11 @@ Some changes introduced by this patch that should be pointed out are:
 
 Signed-off-by: Aditya Kali <adityakali@google.com>
 ---
 
 Signed-off-by: Aditya Kali <adityakali@google.com>
 ---
-Index: linux-stage/fs/ext4/ext4.h
+Index: linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/ext4.h
 ===================================================================
 ===================================================================
---- linux-stage.orig/fs/ext4/ext4.h    2012-06-26 11:26:23.345235745 +0200
-+++ linux-stage/fs/ext4/ext4.h 2012-06-26 11:37:38.250355000 +0200
-@@ -162,6 +162,8 @@ typedef struct ext4_io_end {
+--- linux-2.6.32-431.17.1.el6.x86_64.orig/fs/ext4/ext4.h
++++ linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/ext4.h
+@@ -187,6 +187,8 @@ typedef struct ext4_io_end {
   */
  #define       EXT4_BAD_INO             1      /* Bad blocks inode */
  #define EXT4_ROOT_INO          2      /* Root inode */
   */
  #define       EXT4_BAD_INO             1      /* Bad blocks inode */
  #define EXT4_ROOT_INO          2      /* Root inode */
@@ -41,7 +41,7 @@ Index: linux-stage/fs/ext4/ext4.h
  #define EXT4_BOOT_LOADER_INO   5      /* Boot loader inode */
  #define EXT4_UNDEL_DIR_INO     6      /* Undelete directory inode */
  #define EXT4_RESIZE_INO                7      /* Reserved group descriptors inode */
  #define EXT4_BOOT_LOADER_INO   5      /* Boot loader inode */
  #define EXT4_UNDEL_DIR_INO     6      /* Undelete directory inode */
  #define EXT4_RESIZE_INO                7      /* Reserved group descriptors inode */
-@@ -1016,7 +1018,9 @@ struct ext4_super_block {
+@@ -1046,7 +1048,9 @@ struct ext4_super_block {
        __u8    s_last_error_func[32];  /* function where the error happened */
  #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
        __u8    s_mount_opts[64];
        __u8    s_last_error_func[32];  /* function where the error happened */
  #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
        __u8    s_mount_opts[64];
@@ -52,7 +52,7 @@ Index: linux-stage/fs/ext4/ext4.h
  };
  
  #ifdef __KERNEL__
  };
  
  #ifdef __KERNEL__
-@@ -1090,6 +1094,7 @@ struct ext4_sb_info {
+@@ -1121,6 +1125,7 @@ struct ext4_sb_info {
  #ifdef CONFIG_QUOTA
        char *s_qf_names[MAXQUOTAS];            /* Names of quota files with journalled quota */
        int s_jquota_fmt;                       /* Format of quota to use */
  #ifdef CONFIG_QUOTA
        char *s_qf_names[MAXQUOTAS];            /* Names of quota files with journalled quota */
        int s_jquota_fmt;                       /* Format of quota to use */
@@ -60,7 +60,7 @@ Index: linux-stage/fs/ext4/ext4.h
  #endif
        unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
        struct rb_root system_blks;
  #endif
        unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
        struct rb_root system_blks;
-@@ -1189,6 +1194,8 @@ static inline struct timespec ext4_curre
+@@ -1221,6 +1226,8 @@ static inline struct timespec ext4_curre
  static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
  {
        return ino == EXT4_ROOT_INO ||
  static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
  {
        return ino == EXT4_ROOT_INO ||
@@ -69,7 +69,7 @@ Index: linux-stage/fs/ext4/ext4.h
                ino == EXT4_JOURNAL_INO ||
                ino == EXT4_RESIZE_INO ||
                (ino >= EXT4_FIRST_INO(sb) &&
                ino == EXT4_JOURNAL_INO ||
                ino == EXT4_RESIZE_INO ||
                (ino >= EXT4_FIRST_INO(sb) &&
-@@ -1293,6 +1300,7 @@ EXT4_INODE_BIT_FNS(state, state_flags)
+@@ -1325,6 +1332,7 @@ EXT4_INODE_BIT_FNS(state, state_flags)
  #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM               0x0010
  #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK      0x0020
  #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE    0x0040
  #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM               0x0010
  #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK      0x0020
  #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE    0x0040
@@ -77,7 +77,7 @@ Index: linux-stage/fs/ext4/ext4.h
  
  #define EXT4_FEATURE_INCOMPAT_COMPRESSION     0x0001
  #define EXT4_FEATURE_INCOMPAT_FILETYPE                0x0002
  
  #define EXT4_FEATURE_INCOMPAT_COMPRESSION     0x0001
  #define EXT4_FEATURE_INCOMPAT_FILETYPE                0x0002
-@@ -1325,7 +1333,8 @@ EXT4_INODE_BIT_FNS(state, state_flags)
+@@ -1357,7 +1365,8 @@ EXT4_INODE_BIT_FNS(state, state_flags)
                                         EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
                                         EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
                                         EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
                                         EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
                                         EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
                                         EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
@@ -87,10 +87,10 @@ Index: linux-stage/fs/ext4/ext4.h
  
  /*
   * Default values for user and/or group using reserved blocks
  
  /*
   * Default values for user and/or group using reserved blocks
-Index: linux-stage/fs/ext4/ext4_jbd2.h
+Index: linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/ext4_jbd2.h
 ===================================================================
 ===================================================================
---- linux-stage.orig/fs/ext4/ext4_jbd2.h       2012-06-26 11:35:31.025105000 +0200
-+++ linux-stage/fs/ext4/ext4_jbd2.h    2012-06-26 11:37:38.250631000 +0200
+--- linux-2.6.32-431.17.1.el6.x86_64.orig/fs/ext4/ext4_jbd2.h
++++ linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/ext4_jbd2.h
 @@ -89,14 +89,20 @@
  #ifdef CONFIG_QUOTA
  /* Amount of blocks needed for quota update - we know that the structure was
 @@ -89,14 +89,20 @@
  #ifdef CONFIG_QUOTA
  /* Amount of blocks needed for quota update - we know that the structure was
@@ -103,13 +103,14 @@ Index: linux-stage/fs/ext4/ext4_jbd2.h
   * but inode, sb and group updates are done only once */
 -#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
 -              (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
   * but inode, sb and group updates are done only once */
 -#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
 -              (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
+-
+-#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
+-              (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
 +#define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
 +              EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
 +              (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
 +               +3+DQUOT_INIT_REWRITE) : 0)
 +#define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
 +              EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
 +              (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
 +               +3+DQUOT_INIT_REWRITE) : 0)
--#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
--              (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
++
 +#define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
 +              EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
 +              (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
 +#define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
 +              EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
 +              (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
@@ -117,11 +118,11 @@ Index: linux-stage/fs/ext4/ext4_jbd2.h
  #else
  #define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
  #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
  #else
  #define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
  #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
-Index: linux-stage/fs/ext4/super.c
+Index: linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/super.c
 ===================================================================
 ===================================================================
---- linux-stage.orig/fs/ext4/super.c   2012-06-26 11:37:30.905374000 +0200
-+++ linux-stage/fs/ext4/super.c        2012-06-26 11:38:30.997488000 +0200
-@@ -86,6 +86,11 @@ wait_queue_head_t aio_wq[WQ_HASH_SZ];
+--- linux-2.6.32-431.17.1.el6.x86_64.orig/fs/ext4/super.c
++++ linux-2.6.32-431.17.1.el6.x86_64/fs/ext4/super.c
+@@ -116,6 +116,11 @@ void ext4_kvfree(void *ptr)
  
  static int bigendian_extents;
  
  
  static int bigendian_extents;
  
@@ -133,7 +134,7 @@ Index: linux-stage/fs/ext4/super.c
  ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
                               struct ext4_group_desc *bg)
  {
  ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
                               struct ext4_group_desc *bg)
  {
-@@ -670,6 +675,12 @@ static void ext4_put_super(struct super_
+@@ -704,6 +709,12 @@ static void ext4_put_super(struct super_
  
        ext4_unregister_li_request(sb);
  
  
        ext4_unregister_li_request(sb);
  
@@ -146,7 +147,7 @@ Index: linux-stage/fs/ext4/super.c
        flush_workqueue(sbi->dio_unwritten_wq);
        destroy_workqueue(sbi->dio_unwritten_wq);
  
        flush_workqueue(sbi->dio_unwritten_wq);
        destroy_workqueue(sbi->dio_unwritten_wq);
  
-@@ -2142,14 +2153,22 @@ static void ext4_orphan_cleanup(struct s
+@@ -2173,14 +2184,22 @@ static void ext4_orphan_cleanup(struct s
  #ifdef CONFIG_QUOTA
        /* Needed for iput() to work correctly and not trash data */
        sb->s_flags |= MS_ACTIVE;
  #ifdef CONFIG_QUOTA
        /* Needed for iput() to work correctly and not trash data */
        sb->s_flags |= MS_ACTIVE;
@@ -177,7 +178,7 @@ Index: linux-stage/fs/ext4/super.c
                }
        }
  #endif
                }
        }
  #endif
-@@ -2193,10 +2212,14 @@ static void ext4_orphan_cleanup(struct s
+@@ -2224,10 +2243,14 @@ static void ext4_orphan_cleanup(struct s
                ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
                       PLURAL(nr_truncates));
  #ifdef CONFIG_QUOTA
                ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
                       PLURAL(nr_truncates));
  #ifdef CONFIG_QUOTA
@@ -196,7 +197,7 @@ Index: linux-stage/fs/ext4/super.c
        }
  #endif
        sb->s_flags = s_flags; /* Restore MS_RDONLY status */
        }
  #endif
        sb->s_flags = s_flags; /* Restore MS_RDONLY status */
-@@ -3395,6 +3418,15 @@ static int ext4_fill_super(struct super_
+@@ -3486,6 +3509,15 @@ static int ext4_fill_super(struct super_
  #ifdef CONFIG_QUOTA
        sb->s_qcop = &ext4_qctl_operations;
        sb->dq_op = &ext4_quota_operations;
  #ifdef CONFIG_QUOTA
        sb->s_qcop = &ext4_qctl_operations;
        sb->dq_op = &ext4_quota_operations;
@@ -212,7 +213,7 @@ Index: linux-stage/fs/ext4/super.c
  #endif
        INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
        mutex_init(&sbi->s_orphan_lock);
  #endif
        INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
        mutex_init(&sbi->s_orphan_lock);
-@@ -3622,8 +3654,31 @@ no_journal:
+@@ -3729,8 +3761,31 @@ no_journal:
        } else
                descr = "out journal";
  
        } else
                descr = "out journal";
  
@@ -227,7 +228,7 @@ Index: linux-stage/fs/ext4/super.c
 +              if (ret) {
 +                      ext4_msg(sb, KERN_ERR, "Can't enable usage tracking on "
 +                               "a filesystem with the QUOTA feature set");
 +              if (ret) {
 +                      ext4_msg(sb, KERN_ERR, "Can't enable usage tracking on "
 +                               "a filesystem with the QUOTA feature set");
-+                      goto failed_mount4;
++                      goto failed_mount8;
 +              }
 +      }
 +#else
 +              }
 +      }
 +#else
@@ -246,7 +247,18 @@ Index: linux-stage/fs/ext4/super.c
                 *sbi->s_es->s_mount_opts ? "; " : "");
  
        lock_kernel();
                 *sbi->s_es->s_mount_opts ? "; " : "");
  
        lock_kernel();
-@@ -3981,6 +4036,12 @@ static int ext4_commit_super(struct supe
+@@ -3741,6 +3796,10 @@ cantfind_ext4:
+               ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
+       goto failed_mount;
++#ifdef CONFIG_QUOTA
++failed_mount8:
++      kobject_del(&sbi->s_kobj);
++#endif
+ failed_mount7:
+       ext4_unregister_li_request(sb);
+ failed_mount6:
+@@ -4088,6 +4147,12 @@ static int ext4_commit_super(struct supe
        es->s_free_inodes_count =
                cpu_to_le32(percpu_counter_sum_positive(
                                &EXT4_SB(sb)->s_freeinodes_counter));
        es->s_free_inodes_count =
                cpu_to_le32(percpu_counter_sum_positive(
                                &EXT4_SB(sb)->s_freeinodes_counter));
@@ -259,7 +271,7 @@ Index: linux-stage/fs/ext4/super.c
        sb->s_dirt = 0;
        BUFFER_TRACE(sbh, "marking dirty");
        mark_buffer_dirty(sbh);
        sb->s_dirt = 0;
        BUFFER_TRACE(sbh, "marking dirty");
        mark_buffer_dirty(sbh);
-@@ -4531,6 +4592,22 @@ static int ext4_quota_on(struct super_bl
+@@ -4650,6 +4715,22 @@ static int ext4_quota_on(struct super_bl
        int err;
        struct path path;
  
        int err;
        struct path path;
  
@@ -282,7 +294,7 @@ Index: linux-stage/fs/ext4/super.c
        if (!test_opt(sb, QUOTA))
                return -EINVAL;
        /* When remounting, no checks are needed and in fact, name is NULL */
        if (!test_opt(sb, QUOTA))
                return -EINVAL;
        /* When remounting, no checks are needed and in fact, name is NULL */
-@@ -4630,9 +4707,114 @@ static int ext4_quota_off(struct super_b
+@@ -4749,9 +4830,114 @@ static int ext4_quota_off(struct super_b
                iput(inode);
        }
  
                iput(inode);
        }