aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-08-03 13:50:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-08-03 13:50:44 -0400
commit8f616cd5249e03c9e1b371623d85e76d4b86bbc1 (patch)
tree94cbd990ac45743ac75203a7e1bd6a8fb63c5bc2 /fs/ext4/super.c
parent7e31aa11fc672bbe0dd0da59513c9efe3809ced7 (diff)
parent7d55992d60caa390460bad1a974eb2b3c11538f4 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: remove write-only variables from ext4_ordered_write_end ext4: unexport jbd2_journal_update_superblock ext4: Cleanup whitespace and other miscellaneous style issues ext4: improve ext4_fill_flex_info() a bit ext4: Cleanup the block reservation code path ext4: don't assume extents can't cross block groups when truncating ext4: Fix lack of credits BUG() when deleting a badly fragmented inode ext4: Fix ext4_ext_journal_restart() ext4: fix ext4_da_write_begin error path jbd2: don't abort if flushing file data failed ext4: don't read inode block if the buffer has a write error ext4: Don't allow lg prealloc list to be grow large. ext4: Convert the usage of NR_CPUS to nr_cpu_ids. ext4: Improve error handling in mballoc ext4: lock block groups when initializing ext4: sync up block and inode bitmap reading functions ext4: Allow read/only mounts with corrupted block group checksums ext4: Fix data corruption when writing to prealloc area
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c316
1 files changed, 167 insertions, 149 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1e69f29a8c55..d5d77958b861 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -49,20 +49,19 @@ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
49 unsigned long journal_devnum); 49 unsigned long journal_devnum);
50static int ext4_create_journal(struct super_block *, struct ext4_super_block *, 50static int ext4_create_journal(struct super_block *, struct ext4_super_block *,
51 unsigned int); 51 unsigned int);
52static void ext4_commit_super (struct super_block * sb, 52static void ext4_commit_super(struct super_block *sb,
53 struct ext4_super_block * es, 53 struct ext4_super_block *es, int sync);
54 int sync); 54static void ext4_mark_recovery_complete(struct super_block *sb,
55static void ext4_mark_recovery_complete(struct super_block * sb, 55 struct ext4_super_block *es);
56 struct ext4_super_block * es); 56static void ext4_clear_journal_err(struct super_block *sb,
57static void ext4_clear_journal_err(struct super_block * sb, 57 struct ext4_super_block *es);
58 struct ext4_super_block * es);
59static int ext4_sync_fs(struct super_block *sb, int wait); 58static int ext4_sync_fs(struct super_block *sb, int wait);
60static const char *ext4_decode_error(struct super_block * sb, int errno, 59static const char *ext4_decode_error(struct super_block *sb, int errno,
61 char nbuf[16]); 60 char nbuf[16]);
62static int ext4_remount (struct super_block * sb, int * flags, char * data); 61static int ext4_remount(struct super_block *sb, int *flags, char *data);
63static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf); 62static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
64static void ext4_unlockfs(struct super_block *sb); 63static void ext4_unlockfs(struct super_block *sb);
65static void ext4_write_super (struct super_block * sb); 64static void ext4_write_super(struct super_block *sb);
66static void ext4_write_super_lockfs(struct super_block *sb); 65static void ext4_write_super_lockfs(struct super_block *sb);
67 66
68 67
@@ -211,15 +210,15 @@ static void ext4_handle_error(struct super_block *sb)
211 if (sb->s_flags & MS_RDONLY) 210 if (sb->s_flags & MS_RDONLY)
212 return; 211 return;
213 212
214 if (!test_opt (sb, ERRORS_CONT)) { 213 if (!test_opt(sb, ERRORS_CONT)) {
215 journal_t *journal = EXT4_SB(sb)->s_journal; 214 journal_t *journal = EXT4_SB(sb)->s_journal;
216 215
217 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; 216 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
218 if (journal) 217 if (journal)
219 jbd2_journal_abort(journal, -EIO); 218 jbd2_journal_abort(journal, -EIO);
220 } 219 }
221 if (test_opt (sb, ERRORS_RO)) { 220 if (test_opt(sb, ERRORS_RO)) {
222 printk (KERN_CRIT "Remounting filesystem read-only\n"); 221 printk(KERN_CRIT "Remounting filesystem read-only\n");
223 sb->s_flags |= MS_RDONLY; 222 sb->s_flags |= MS_RDONLY;
224 } 223 }
225 ext4_commit_super(sb, es, 1); 224 ext4_commit_super(sb, es, 1);
@@ -228,13 +227,13 @@ static void ext4_handle_error(struct super_block *sb)
228 sb->s_id); 227 sb->s_id);
229} 228}
230 229
231void ext4_error (struct super_block * sb, const char * function, 230void ext4_error(struct super_block *sb, const char *function,
232 const char * fmt, ...) 231 const char *fmt, ...)
233{ 232{
234 va_list args; 233 va_list args;
235 234
236 va_start(args, fmt); 235 va_start(args, fmt);
237 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function); 236 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function);
238 vprintk(fmt, args); 237 vprintk(fmt, args);
239 printk("\n"); 238 printk("\n");
240 va_end(args); 239 va_end(args);
@@ -242,7 +241,7 @@ void ext4_error (struct super_block * sb, const char * function,
242 ext4_handle_error(sb); 241 ext4_handle_error(sb);
243} 242}
244 243
245static const char *ext4_decode_error(struct super_block * sb, int errno, 244static const char *ext4_decode_error(struct super_block *sb, int errno,
246 char nbuf[16]) 245 char nbuf[16])
247{ 246{
248 char *errstr = NULL; 247 char *errstr = NULL;
@@ -278,8 +277,7 @@ static const char *ext4_decode_error(struct super_block * sb, int errno,
278/* __ext4_std_error decodes expected errors from journaling functions 277/* __ext4_std_error decodes expected errors from journaling functions
279 * automatically and invokes the appropriate error response. */ 278 * automatically and invokes the appropriate error response. */
280 279
281void __ext4_std_error (struct super_block * sb, const char * function, 280void __ext4_std_error(struct super_block *sb, const char *function, int errno)
282 int errno)
283{ 281{
284 char nbuf[16]; 282 char nbuf[16];
285 const char *errstr; 283 const char *errstr;
@@ -292,8 +290,8 @@ void __ext4_std_error (struct super_block * sb, const char * function,
292 return; 290 return;
293 291
294 errstr = ext4_decode_error(sb, errno, nbuf); 292 errstr = ext4_decode_error(sb, errno, nbuf);
295 printk (KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n", 293 printk(KERN_CRIT "EXT4-fs error (device %s) in %s: %s\n",
296 sb->s_id, function, errstr); 294 sb->s_id, function, errstr);
297 295
298 ext4_handle_error(sb); 296 ext4_handle_error(sb);
299} 297}
@@ -308,15 +306,15 @@ void __ext4_std_error (struct super_block * sb, const char * function,
308 * case we take the easy way out and panic immediately. 306 * case we take the easy way out and panic immediately.
309 */ 307 */
310 308
311void ext4_abort (struct super_block * sb, const char * function, 309void ext4_abort(struct super_block *sb, const char *function,
312 const char * fmt, ...) 310 const char *fmt, ...)
313{ 311{
314 va_list args; 312 va_list args;
315 313
316 printk (KERN_CRIT "ext4_abort called.\n"); 314 printk(KERN_CRIT "ext4_abort called.\n");
317 315
318 va_start(args, fmt); 316 va_start(args, fmt);
319 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ",sb->s_id, function); 317 printk(KERN_CRIT "EXT4-fs error (device %s): %s: ", sb->s_id, function);
320 vprintk(fmt, args); 318 vprintk(fmt, args);
321 printk("\n"); 319 printk("\n");
322 va_end(args); 320 va_end(args);
@@ -334,8 +332,8 @@ void ext4_abort (struct super_block * sb, const char * function,
334 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); 332 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
335} 333}
336 334
337void ext4_warning (struct super_block * sb, const char * function, 335void ext4_warning(struct super_block *sb, const char *function,
338 const char * fmt, ...) 336 const char *fmt, ...)
339{ 337{
340 va_list args; 338 va_list args;
341 339
@@ -496,7 +494,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
496 } 494 }
497} 495}
498 496
499static void ext4_put_super (struct super_block * sb) 497static void ext4_put_super(struct super_block *sb)
500{ 498{
501 struct ext4_sb_info *sbi = EXT4_SB(sb); 499 struct ext4_sb_info *sbi = EXT4_SB(sb);
502 struct ext4_super_block *es = sbi->s_es; 500 struct ext4_super_block *es = sbi->s_es;
@@ -647,7 +645,8 @@ static void ext4_clear_inode(struct inode *inode)
647 &EXT4_I(inode)->jinode); 645 &EXT4_I(inode)->jinode);
648} 646}
649 647
650static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb) 648static inline void ext4_show_quota_options(struct seq_file *seq,
649 struct super_block *sb)
651{ 650{
652#if defined(CONFIG_QUOTA) 651#if defined(CONFIG_QUOTA)
653 struct ext4_sb_info *sbi = EXT4_SB(sb); 652 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -822,8 +821,8 @@ static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid,
822} 821}
823 822
824#ifdef CONFIG_QUOTA 823#ifdef CONFIG_QUOTA
825#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") 824#define QTYPE2NAME(t) ((t) == USRQUOTA?"user":"group")
826#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) 825#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
827 826
828static int ext4_dquot_initialize(struct inode *inode, int type); 827static int ext4_dquot_initialize(struct inode *inode, int type);
829static int ext4_dquot_drop(struct inode *inode); 828static int ext4_dquot_drop(struct inode *inode);
@@ -991,12 +990,12 @@ static ext4_fsblk_t get_sb_block(void **data)
991 return sb_block; 990 return sb_block;
992} 991}
993 992
994static int parse_options (char *options, struct super_block *sb, 993static int parse_options(char *options, struct super_block *sb,
995 unsigned int *inum, unsigned long *journal_devnum, 994 unsigned int *inum, unsigned long *journal_devnum,
996 ext4_fsblk_t *n_blocks_count, int is_remount) 995 ext4_fsblk_t *n_blocks_count, int is_remount)
997{ 996{
998 struct ext4_sb_info *sbi = EXT4_SB(sb); 997 struct ext4_sb_info *sbi = EXT4_SB(sb);
999 char * p; 998 char *p;
1000 substring_t args[MAX_OPT_ARGS]; 999 substring_t args[MAX_OPT_ARGS];
1001 int data_opt = 0; 1000 int data_opt = 0;
1002 int option; 1001 int option;
@@ -1009,7 +1008,7 @@ static int parse_options (char *options, struct super_block *sb,
1009 if (!options) 1008 if (!options)
1010 return 1; 1009 return 1;
1011 1010
1012 while ((p = strsep (&options, ",")) != NULL) { 1011 while ((p = strsep(&options, ",")) != NULL) {
1013 int token; 1012 int token;
1014 if (!*p) 1013 if (!*p)
1015 continue; 1014 continue;
@@ -1017,16 +1016,16 @@ static int parse_options (char *options, struct super_block *sb,
1017 token = match_token(p, tokens, args); 1016 token = match_token(p, tokens, args);
1018 switch (token) { 1017 switch (token) {
1019 case Opt_bsd_df: 1018 case Opt_bsd_df:
1020 clear_opt (sbi->s_mount_opt, MINIX_DF); 1019 clear_opt(sbi->s_mount_opt, MINIX_DF);
1021 break; 1020 break;
1022 case Opt_minix_df: 1021 case Opt_minix_df:
1023 set_opt (sbi->s_mount_opt, MINIX_DF); 1022 set_opt(sbi->s_mount_opt, MINIX_DF);
1024 break; 1023 break;
1025 case Opt_grpid: 1024 case Opt_grpid:
1026 set_opt (sbi->s_mount_opt, GRPID); 1025 set_opt(sbi->s_mount_opt, GRPID);
1027 break; 1026 break;
1028 case Opt_nogrpid: 1027 case Opt_nogrpid:
1029 clear_opt (sbi->s_mount_opt, GRPID); 1028 clear_opt(sbi->s_mount_opt, GRPID);
1030 break; 1029 break;
1031 case Opt_resuid: 1030 case Opt_resuid:
1032 if (match_int(&args[0], &option)) 1031 if (match_int(&args[0], &option))
@@ -1043,41 +1042,41 @@ static int parse_options (char *options, struct super_block *sb,
1043 /* *sb_block = match_int(&args[0]); */ 1042 /* *sb_block = match_int(&args[0]); */
1044 break; 1043 break;
1045 case Opt_err_panic: 1044 case Opt_err_panic:
1046 clear_opt (sbi->s_mount_opt, ERRORS_CONT); 1045 clear_opt(sbi->s_mount_opt, ERRORS_CONT);
1047 clear_opt (sbi->s_mount_opt, ERRORS_RO); 1046 clear_opt(sbi->s_mount_opt, ERRORS_RO);
1048 set_opt (sbi->s_mount_opt, ERRORS_PANIC); 1047 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
1049 break; 1048 break;
1050 case Opt_err_ro: 1049 case Opt_err_ro:
1051 clear_opt (sbi->s_mount_opt, ERRORS_CONT); 1050 clear_opt(sbi->s_mount_opt, ERRORS_CONT);
1052 clear_opt (sbi->s_mount_opt, ERRORS_PANIC); 1051 clear_opt(sbi->s_mount_opt, ERRORS_PANIC);
1053 set_opt (sbi->s_mount_opt, ERRORS_RO); 1052 set_opt(sbi->s_mount_opt, ERRORS_RO);
1054 break; 1053 break;
1055 case Opt_err_cont: 1054 case Opt_err_cont:
1056 clear_opt (sbi->s_mount_opt, ERRORS_RO); 1055 clear_opt(sbi->s_mount_opt, ERRORS_RO);
1057 clear_opt (sbi->s_mount_opt, ERRORS_PANIC); 1056 clear_opt(sbi->s_mount_opt, ERRORS_PANIC);
1058 set_opt (sbi->s_mount_opt, ERRORS_CONT); 1057 set_opt(sbi->s_mount_opt, ERRORS_CONT);
1059 break; 1058 break;
1060 case Opt_nouid32: 1059 case Opt_nouid32:
1061 set_opt (sbi->s_mount_opt, NO_UID32); 1060 set_opt(sbi->s_mount_opt, NO_UID32);
1062 break; 1061 break;
1063 case Opt_nocheck: 1062 case Opt_nocheck:
1064 clear_opt (sbi->s_mount_opt, CHECK); 1063 clear_opt(sbi->s_mount_opt, CHECK);
1065 break; 1064 break;
1066 case Opt_debug: 1065 case Opt_debug:
1067 set_opt (sbi->s_mount_opt, DEBUG); 1066 set_opt(sbi->s_mount_opt, DEBUG);
1068 break; 1067 break;
1069 case Opt_oldalloc: 1068 case Opt_oldalloc:
1070 set_opt (sbi->s_mount_opt, OLDALLOC); 1069 set_opt(sbi->s_mount_opt, OLDALLOC);
1071 break; 1070 break;
1072 case Opt_orlov: 1071 case Opt_orlov:
1073 clear_opt (sbi->s_mount_opt, OLDALLOC); 1072 clear_opt(sbi->s_mount_opt, OLDALLOC);
1074 break; 1073 break;
1075#ifdef CONFIG_EXT4DEV_FS_XATTR 1074#ifdef CONFIG_EXT4DEV_FS_XATTR
1076 case Opt_user_xattr: 1075 case Opt_user_xattr:
1077 set_opt (sbi->s_mount_opt, XATTR_USER); 1076 set_opt(sbi->s_mount_opt, XATTR_USER);
1078 break; 1077 break;
1079 case Opt_nouser_xattr: 1078 case Opt_nouser_xattr:
1080 clear_opt (sbi->s_mount_opt, XATTR_USER); 1079 clear_opt(sbi->s_mount_opt, XATTR_USER);
1081 break; 1080 break;
1082#else 1081#else
1083 case Opt_user_xattr: 1082 case Opt_user_xattr:
@@ -1115,7 +1114,7 @@ static int parse_options (char *options, struct super_block *sb,
1115 "journal on remount\n"); 1114 "journal on remount\n");
1116 return 0; 1115 return 0;
1117 } 1116 }
1118 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); 1117 set_opt(sbi->s_mount_opt, UPDATE_JOURNAL);
1119 break; 1118 break;
1120 case Opt_journal_inum: 1119 case Opt_journal_inum:
1121 if (is_remount) { 1120 if (is_remount) {
@@ -1145,7 +1144,7 @@ static int parse_options (char *options, struct super_block *sb,
1145 set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM); 1144 set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM);
1146 break; 1145 break;
1147 case Opt_noload: 1146 case Opt_noload:
1148 set_opt (sbi->s_mount_opt, NOLOAD); 1147 set_opt(sbi->s_mount_opt, NOLOAD);
1149 break; 1148 break;
1150 case Opt_commit: 1149 case Opt_commit:
1151 if (match_int(&args[0], &option)) 1150 if (match_int(&args[0], &option))
@@ -1331,7 +1330,7 @@ set_qf_format:
1331 "on this filesystem, use tune2fs\n"); 1330 "on this filesystem, use tune2fs\n");
1332 return 0; 1331 return 0;
1333 } 1332 }
1334 set_opt (sbi->s_mount_opt, EXTENTS); 1333 set_opt(sbi->s_mount_opt, EXTENTS);
1335 break; 1334 break;
1336 case Opt_noextents: 1335 case Opt_noextents:
1337 /* 1336 /*
@@ -1348,7 +1347,7 @@ set_qf_format:
1348 "-o noextents options\n"); 1347 "-o noextents options\n");
1349 return 0; 1348 return 0;
1350 } 1349 }
1351 clear_opt (sbi->s_mount_opt, EXTENTS); 1350 clear_opt(sbi->s_mount_opt, EXTENTS);
1352 break; 1351 break;
1353 case Opt_i_version: 1352 case Opt_i_version:
1354 set_opt(sbi->s_mount_opt, I_VERSION); 1353 set_opt(sbi->s_mount_opt, I_VERSION);
@@ -1374,9 +1373,9 @@ set_qf_format:
1374 set_opt(sbi->s_mount_opt, DELALLOC); 1373 set_opt(sbi->s_mount_opt, DELALLOC);
1375 break; 1374 break;
1376 default: 1375 default:
1377 printk (KERN_ERR 1376 printk(KERN_ERR
1378 "EXT4-fs: Unrecognized mount option \"%s\" " 1377 "EXT4-fs: Unrecognized mount option \"%s\" "
1379 "or missing value\n", p); 1378 "or missing value\n", p);
1380 return 0; 1379 return 0;
1381 } 1380 }
1382 } 1381 }
@@ -1423,31 +1422,31 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1423 int res = 0; 1422 int res = 0;
1424 1423
1425 if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { 1424 if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
1426 printk (KERN_ERR "EXT4-fs warning: revision level too high, " 1425 printk(KERN_ERR "EXT4-fs warning: revision level too high, "
1427 "forcing read-only mode\n"); 1426 "forcing read-only mode\n");
1428 res = MS_RDONLY; 1427 res = MS_RDONLY;
1429 } 1428 }
1430 if (read_only) 1429 if (read_only)
1431 return res; 1430 return res;
1432 if (!(sbi->s_mount_state & EXT4_VALID_FS)) 1431 if (!(sbi->s_mount_state & EXT4_VALID_FS))
1433 printk (KERN_WARNING "EXT4-fs warning: mounting unchecked fs, " 1432 printk(KERN_WARNING "EXT4-fs warning: mounting unchecked fs, "
1434 "running e2fsck is recommended\n"); 1433 "running e2fsck is recommended\n");
1435 else if ((sbi->s_mount_state & EXT4_ERROR_FS)) 1434 else if ((sbi->s_mount_state & EXT4_ERROR_FS))
1436 printk (KERN_WARNING 1435 printk(KERN_WARNING
1437 "EXT4-fs warning: mounting fs with errors, " 1436 "EXT4-fs warning: mounting fs with errors, "
1438 "running e2fsck is recommended\n"); 1437 "running e2fsck is recommended\n");
1439 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 1438 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
1440 le16_to_cpu(es->s_mnt_count) >= 1439 le16_to_cpu(es->s_mnt_count) >=
1441 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 1440 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
1442 printk (KERN_WARNING 1441 printk(KERN_WARNING
1443 "EXT4-fs warning: maximal mount count reached, " 1442 "EXT4-fs warning: maximal mount count reached, "
1444 "running e2fsck is recommended\n"); 1443 "running e2fsck is recommended\n");
1445 else if (le32_to_cpu(es->s_checkinterval) && 1444 else if (le32_to_cpu(es->s_checkinterval) &&
1446 (le32_to_cpu(es->s_lastcheck) + 1445 (le32_to_cpu(es->s_lastcheck) +
1447 le32_to_cpu(es->s_checkinterval) <= get_seconds())) 1446 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
1448 printk (KERN_WARNING 1447 printk(KERN_WARNING
1449 "EXT4-fs warning: checktime reached, " 1448 "EXT4-fs warning: checktime reached, "
1450 "running e2fsck is recommended\n"); 1449 "running e2fsck is recommended\n");
1451#if 0 1450#if 0
1452 /* @@@ We _will_ want to clear the valid bit if we find 1451 /* @@@ We _will_ want to clear the valid bit if we find
1453 * inconsistencies, to force a fsck at reboot. But for 1452 * inconsistencies, to force a fsck at reboot. But for
@@ -1506,14 +1505,13 @@ static int ext4_fill_flex_info(struct super_block *sb)
1506 1505
1507 flex_group_count = (sbi->s_groups_count + groups_per_flex - 1) / 1506 flex_group_count = (sbi->s_groups_count + groups_per_flex - 1) /
1508 groups_per_flex; 1507 groups_per_flex;
1509 sbi->s_flex_groups = kmalloc(flex_group_count * 1508 sbi->s_flex_groups = kzalloc(flex_group_count *
1510 sizeof(struct flex_groups), GFP_KERNEL); 1509 sizeof(struct flex_groups), GFP_KERNEL);
1511 if (sbi->s_flex_groups == NULL) { 1510 if (sbi->s_flex_groups == NULL) {
1512 printk(KERN_ERR "EXT4-fs: not enough memory\n"); 1511 printk(KERN_ERR "EXT4-fs: not enough memory for "
1512 "%lu flex groups\n", flex_group_count);
1513 goto failed; 1513 goto failed;
1514 } 1514 }
1515 memset(sbi->s_flex_groups, 0, flex_group_count *
1516 sizeof(struct flex_groups));
1517 1515
1518 gdp = ext4_get_group_desc(sb, 1, &bh); 1516 gdp = ext4_get_group_desc(sb, 1, &bh);
1519 block_bitmap = ext4_block_bitmap(sb, gdp) - 1; 1517 block_bitmap = ext4_block_bitmap(sb, gdp) - 1;
@@ -1597,16 +1595,14 @@ static int ext4_check_descriptors(struct super_block *sb)
1597 (EXT4_BLOCKS_PER_GROUP(sb) - 1); 1595 (EXT4_BLOCKS_PER_GROUP(sb) - 1);
1598 1596
1599 block_bitmap = ext4_block_bitmap(sb, gdp); 1597 block_bitmap = ext4_block_bitmap(sb, gdp);
1600 if (block_bitmap < first_block || block_bitmap > last_block) 1598 if (block_bitmap < first_block || block_bitmap > last_block) {
1601 {
1602 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " 1599 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
1603 "Block bitmap for group %lu not in group " 1600 "Block bitmap for group %lu not in group "
1604 "(block %llu)!", i, block_bitmap); 1601 "(block %llu)!", i, block_bitmap);
1605 return 0; 1602 return 0;
1606 } 1603 }
1607 inode_bitmap = ext4_inode_bitmap(sb, gdp); 1604 inode_bitmap = ext4_inode_bitmap(sb, gdp);
1608 if (inode_bitmap < first_block || inode_bitmap > last_block) 1605 if (inode_bitmap < first_block || inode_bitmap > last_block) {
1609 {
1610 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " 1606 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
1611 "Inode bitmap for group %lu not in group " 1607 "Inode bitmap for group %lu not in group "
1612 "(block %llu)!", i, inode_bitmap); 1608 "(block %llu)!", i, inode_bitmap);
@@ -1614,26 +1610,28 @@ static int ext4_check_descriptors(struct super_block *sb)
1614 } 1610 }
1615 inode_table = ext4_inode_table(sb, gdp); 1611 inode_table = ext4_inode_table(sb, gdp);
1616 if (inode_table < first_block || 1612 if (inode_table < first_block ||
1617 inode_table + sbi->s_itb_per_group - 1 > last_block) 1613 inode_table + sbi->s_itb_per_group - 1 > last_block) {
1618 {
1619 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " 1614 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
1620 "Inode table for group %lu not in group " 1615 "Inode table for group %lu not in group "
1621 "(block %llu)!", i, inode_table); 1616 "(block %llu)!", i, inode_table);
1622 return 0; 1617 return 0;
1623 } 1618 }
1619 spin_lock(sb_bgl_lock(sbi, i));
1624 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) { 1620 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
1625 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " 1621 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
1626 "Checksum for group %lu failed (%u!=%u)\n", 1622 "Checksum for group %lu failed (%u!=%u)\n",
1627 i, le16_to_cpu(ext4_group_desc_csum(sbi, i, 1623 i, le16_to_cpu(ext4_group_desc_csum(sbi, i,
1628 gdp)), le16_to_cpu(gdp->bg_checksum)); 1624 gdp)), le16_to_cpu(gdp->bg_checksum));
1629 return 0; 1625 if (!(sb->s_flags & MS_RDONLY))
1626 return 0;
1630 } 1627 }
1628 spin_unlock(sb_bgl_lock(sbi, i));
1631 if (!flexbg_flag) 1629 if (!flexbg_flag)
1632 first_block += EXT4_BLOCKS_PER_GROUP(sb); 1630 first_block += EXT4_BLOCKS_PER_GROUP(sb);
1633 } 1631 }
1634 1632
1635 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); 1633 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
1636 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb)); 1634 sbi->s_es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
1637 return 1; 1635 return 1;
1638} 1636}
1639 1637
@@ -1654,8 +1652,8 @@ static int ext4_check_descriptors(struct super_block *sb)
1654 * e2fsck was run on this filesystem, and it must have already done the orphan 1652 * e2fsck was run on this filesystem, and it must have already done the orphan
1655 * inode cleanup for us, so we can safely abort without any further action. 1653 * inode cleanup for us, so we can safely abort without any further action.
1656 */ 1654 */
1657static void ext4_orphan_cleanup (struct super_block * sb, 1655static void ext4_orphan_cleanup(struct super_block *sb,
1658 struct ext4_super_block * es) 1656 struct ext4_super_block *es)
1659{ 1657{
1660 unsigned int s_flags = sb->s_flags; 1658 unsigned int s_flags = sb->s_flags;
1661 int nr_orphans = 0, nr_truncates = 0; 1659 int nr_orphans = 0, nr_truncates = 0;
@@ -1732,7 +1730,7 @@ static void ext4_orphan_cleanup (struct super_block * sb,
1732 iput(inode); /* The delete magic happens here! */ 1730 iput(inode); /* The delete magic happens here! */
1733 } 1731 }
1734 1732
1735#define PLURAL(x) (x), ((x)==1) ? "" : "s" 1733#define PLURAL(x) (x), ((x) == 1) ? "" : "s"
1736 1734
1737 if (nr_orphans) 1735 if (nr_orphans)
1738 printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n", 1736 printk(KERN_INFO "EXT4-fs: %s: %d orphan inode%s deleted\n",
@@ -1899,12 +1897,12 @@ static unsigned long ext4_get_stripe_size(struct ext4_sb_info *sbi)
1899 return 0; 1897 return 0;
1900} 1898}
1901 1899
1902static int ext4_fill_super (struct super_block *sb, void *data, int silent) 1900static int ext4_fill_super(struct super_block *sb, void *data, int silent)
1903 __releases(kernel_lock) 1901 __releases(kernel_lock)
1904 __acquires(kernel_lock) 1902 __acquires(kernel_lock)
1905 1903
1906{ 1904{
1907 struct buffer_head * bh; 1905 struct buffer_head *bh;
1908 struct ext4_super_block *es = NULL; 1906 struct ext4_super_block *es = NULL;
1909 struct ext4_sb_info *sbi; 1907 struct ext4_sb_info *sbi;
1910 ext4_fsblk_t block; 1908 ext4_fsblk_t block;
@@ -1953,7 +1951,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1953 } 1951 }
1954 1952
1955 if (!(bh = sb_bread(sb, logical_sb_block))) { 1953 if (!(bh = sb_bread(sb, logical_sb_block))) {
1956 printk (KERN_ERR "EXT4-fs: unable to read superblock\n"); 1954 printk(KERN_ERR "EXT4-fs: unable to read superblock\n");
1957 goto out_fail; 1955 goto out_fail;
1958 } 1956 }
1959 /* 1957 /*
@@ -2026,8 +2024,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2026 set_opt(sbi->s_mount_opt, DELALLOC); 2024 set_opt(sbi->s_mount_opt, DELALLOC);
2027 2025
2028 2026
2029 if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum, 2027 if (!parse_options((char *) data, sb, &journal_inum, &journal_devnum,
2030 NULL, 0)) 2028 NULL, 0))
2031 goto failed_mount; 2029 goto failed_mount;
2032 2030
2033 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 2031 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -2102,7 +2100,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2102 goto failed_mount; 2100 goto failed_mount;
2103 } 2101 }
2104 2102
2105 brelse (bh); 2103 brelse(bh);
2106 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; 2104 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
2107 offset = do_div(logical_sb_block, blocksize); 2105 offset = do_div(logical_sb_block, blocksize);
2108 bh = sb_bread(sb, logical_sb_block); 2106 bh = sb_bread(sb, logical_sb_block);
@@ -2114,8 +2112,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2114 es = (struct ext4_super_block *)(((char *)bh->b_data) + offset); 2112 es = (struct ext4_super_block *)(((char *)bh->b_data) + offset);
2115 sbi->s_es = es; 2113 sbi->s_es = es;
2116 if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) { 2114 if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) {
2117 printk (KERN_ERR 2115 printk(KERN_ERR
2118 "EXT4-fs: Magic mismatch, very weird !\n"); 2116 "EXT4-fs: Magic mismatch, very weird !\n");
2119 goto failed_mount; 2117 goto failed_mount;
2120 } 2118 }
2121 } 2119 }
@@ -2132,9 +2130,9 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2132 if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || 2130 if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
2133 (!is_power_of_2(sbi->s_inode_size)) || 2131 (!is_power_of_2(sbi->s_inode_size)) ||
2134 (sbi->s_inode_size > blocksize)) { 2132 (sbi->s_inode_size > blocksize)) {
2135 printk (KERN_ERR 2133 printk(KERN_ERR
2136 "EXT4-fs: unsupported inode size: %d\n", 2134 "EXT4-fs: unsupported inode size: %d\n",
2137 sbi->s_inode_size); 2135 sbi->s_inode_size);
2138 goto failed_mount; 2136 goto failed_mount;
2139 } 2137 }
2140 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) 2138 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE)
@@ -2166,20 +2164,20 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2166 sbi->s_mount_state = le16_to_cpu(es->s_state); 2164 sbi->s_mount_state = le16_to_cpu(es->s_state);
2167 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); 2165 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
2168 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); 2166 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
2169 for (i=0; i < 4; i++) 2167 for (i = 0; i < 4; i++)
2170 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 2168 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
2171 sbi->s_def_hash_version = es->s_def_hash_version; 2169 sbi->s_def_hash_version = es->s_def_hash_version;
2172 2170
2173 if (sbi->s_blocks_per_group > blocksize * 8) { 2171 if (sbi->s_blocks_per_group > blocksize * 8) {
2174 printk (KERN_ERR 2172 printk(KERN_ERR
2175 "EXT4-fs: #blocks per group too big: %lu\n", 2173 "EXT4-fs: #blocks per group too big: %lu\n",
2176 sbi->s_blocks_per_group); 2174 sbi->s_blocks_per_group);
2177 goto failed_mount; 2175 goto failed_mount;
2178 } 2176 }
2179 if (sbi->s_inodes_per_group > blocksize * 8) { 2177 if (sbi->s_inodes_per_group > blocksize * 8) {
2180 printk (KERN_ERR 2178 printk(KERN_ERR
2181 "EXT4-fs: #inodes per group too big: %lu\n", 2179 "EXT4-fs: #inodes per group too big: %lu\n",
2182 sbi->s_inodes_per_group); 2180 sbi->s_inodes_per_group);
2183 goto failed_mount; 2181 goto failed_mount;
2184 } 2182 }
2185 2183
@@ -2213,10 +2211,10 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2213 sbi->s_groups_count = blocks_count; 2211 sbi->s_groups_count = blocks_count;
2214 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / 2212 db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
2215 EXT4_DESC_PER_BLOCK(sb); 2213 EXT4_DESC_PER_BLOCK(sb);
2216 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), 2214 sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *),
2217 GFP_KERNEL); 2215 GFP_KERNEL);
2218 if (sbi->s_group_desc == NULL) { 2216 if (sbi->s_group_desc == NULL) {
2219 printk (KERN_ERR "EXT4-fs: not enough memory\n"); 2217 printk(KERN_ERR "EXT4-fs: not enough memory\n");
2220 goto failed_mount; 2218 goto failed_mount;
2221 } 2219 }
2222 2220
@@ -2226,13 +2224,13 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2226 block = descriptor_loc(sb, logical_sb_block, i); 2224 block = descriptor_loc(sb, logical_sb_block, i);
2227 sbi->s_group_desc[i] = sb_bread(sb, block); 2225 sbi->s_group_desc[i] = sb_bread(sb, block);
2228 if (!sbi->s_group_desc[i]) { 2226 if (!sbi->s_group_desc[i]) {
2229 printk (KERN_ERR "EXT4-fs: " 2227 printk(KERN_ERR "EXT4-fs: "
2230 "can't read group descriptor %d\n", i); 2228 "can't read group descriptor %d\n", i);
2231 db_count = i; 2229 db_count = i;
2232 goto failed_mount2; 2230 goto failed_mount2;
2233 } 2231 }
2234 } 2232 }
2235 if (!ext4_check_descriptors (sb)) { 2233 if (!ext4_check_descriptors(sb)) {
2236 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n"); 2234 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n");
2237 goto failed_mount2; 2235 goto failed_mount2;
2238 } 2236 }
@@ -2308,11 +2306,11 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2308 EXT4_SB(sb)->s_journal->j_failed_commit) { 2306 EXT4_SB(sb)->s_journal->j_failed_commit) {
2309 printk(KERN_CRIT "EXT4-fs error (device %s): " 2307 printk(KERN_CRIT "EXT4-fs error (device %s): "
2310 "ext4_fill_super: Journal transaction " 2308 "ext4_fill_super: Journal transaction "
2311 "%u is corrupt\n", sb->s_id, 2309 "%u is corrupt\n", sb->s_id,
2312 EXT4_SB(sb)->s_journal->j_failed_commit); 2310 EXT4_SB(sb)->s_journal->j_failed_commit);
2313 if (test_opt (sb, ERRORS_RO)) { 2311 if (test_opt(sb, ERRORS_RO)) {
2314 printk (KERN_CRIT 2312 printk(KERN_CRIT
2315 "Mounting filesystem read-only\n"); 2313 "Mounting filesystem read-only\n");
2316 sb->s_flags |= MS_RDONLY; 2314 sb->s_flags |= MS_RDONLY;
2317 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 2315 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2318 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 2316 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
@@ -2332,9 +2330,9 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2332 goto failed_mount3; 2330 goto failed_mount3;
2333 } else { 2331 } else {
2334 if (!silent) 2332 if (!silent)
2335 printk (KERN_ERR 2333 printk(KERN_ERR
2336 "ext4: No journal on filesystem on %s\n", 2334 "ext4: No journal on filesystem on %s\n",
2337 sb->s_id); 2335 sb->s_id);
2338 goto failed_mount3; 2336 goto failed_mount3;
2339 } 2337 }
2340 2338
@@ -2418,7 +2416,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2418 goto failed_mount4; 2416 goto failed_mount4;
2419 } 2417 }
2420 2418
2421 ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY); 2419 ext4_setup_super(sb, es, sb->s_flags & MS_RDONLY);
2422 2420
2423 /* determine the minimum size of new large inodes, if present */ 2421 /* determine the minimum size of new large inodes, if present */
2424 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) { 2422 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
@@ -2457,12 +2455,12 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2457 ext4_orphan_cleanup(sb, es); 2455 ext4_orphan_cleanup(sb, es);
2458 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; 2456 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
2459 if (needs_recovery) 2457 if (needs_recovery)
2460 printk (KERN_INFO "EXT4-fs: recovery complete.\n"); 2458 printk(KERN_INFO "EXT4-fs: recovery complete.\n");
2461 ext4_mark_recovery_complete(sb, es); 2459 ext4_mark_recovery_complete(sb, es);
2462 printk (KERN_INFO "EXT4-fs: mounted filesystem with %s data mode.\n", 2460 printk(KERN_INFO "EXT4-fs: mounted filesystem with %s data mode.\n",
2463 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ? "journal": 2461 test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ? "journal":
2464 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered": 2462 test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
2465 "writeback"); 2463 "writeback");
2466 2464
2467 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 2465 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
2468 printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - " 2466 printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - "
@@ -2575,14 +2573,14 @@ static journal_t *ext4_get_journal(struct super_block *sb,
2575static journal_t *ext4_get_dev_journal(struct super_block *sb, 2573static journal_t *ext4_get_dev_journal(struct super_block *sb,
2576 dev_t j_dev) 2574 dev_t j_dev)
2577{ 2575{
2578 struct buffer_head * bh; 2576 struct buffer_head *bh;
2579 journal_t *journal; 2577 journal_t *journal;
2580 ext4_fsblk_t start; 2578 ext4_fsblk_t start;
2581 ext4_fsblk_t len; 2579 ext4_fsblk_t len;
2582 int hblock, blocksize; 2580 int hblock, blocksize;
2583 ext4_fsblk_t sb_block; 2581 ext4_fsblk_t sb_block;
2584 unsigned long offset; 2582 unsigned long offset;
2585 struct ext4_super_block * es; 2583 struct ext4_super_block *es;
2586 struct block_device *bdev; 2584 struct block_device *bdev;
2587 2585
2588 bdev = ext4_blkdev_get(j_dev); 2586 bdev = ext4_blkdev_get(j_dev);
@@ -2697,8 +2695,8 @@ static int ext4_load_journal(struct super_block *sb,
2697 "unavailable, cannot proceed.\n"); 2695 "unavailable, cannot proceed.\n");
2698 return -EROFS; 2696 return -EROFS;
2699 } 2697 }
2700 printk (KERN_INFO "EXT4-fs: write access will " 2698 printk(KERN_INFO "EXT4-fs: write access will "
2701 "be enabled during recovery.\n"); 2699 "be enabled during recovery.\n");
2702 } 2700 }
2703 } 2701 }
2704 2702
@@ -2751,8 +2749,8 @@ static int ext4_load_journal(struct super_block *sb,
2751 return 0; 2749 return 0;
2752} 2750}
2753 2751
2754static int ext4_create_journal(struct super_block * sb, 2752static int ext4_create_journal(struct super_block *sb,
2755 struct ext4_super_block * es, 2753 struct ext4_super_block *es,
2756 unsigned int journal_inum) 2754 unsigned int journal_inum)
2757{ 2755{
2758 journal_t *journal; 2756 journal_t *journal;
@@ -2793,9 +2791,8 @@ static int ext4_create_journal(struct super_block * sb,
2793 return 0; 2791 return 0;
2794} 2792}
2795 2793
2796static void ext4_commit_super (struct super_block * sb, 2794static void ext4_commit_super(struct super_block *sb,
2797 struct ext4_super_block * es, 2795 struct ext4_super_block *es, int sync)
2798 int sync)
2799{ 2796{
2800 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; 2797 struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
2801 2798
@@ -2816,8 +2813,8 @@ static void ext4_commit_super (struct super_block * sb,
2816 * remounting) the filesystem readonly, then we will end up with a 2813 * remounting) the filesystem readonly, then we will end up with a
2817 * consistent fs on disk. Record that fact. 2814 * consistent fs on disk. Record that fact.
2818 */ 2815 */
2819static void ext4_mark_recovery_complete(struct super_block * sb, 2816static void ext4_mark_recovery_complete(struct super_block *sb,
2820 struct ext4_super_block * es) 2817 struct ext4_super_block *es)
2821{ 2818{
2822 journal_t *journal = EXT4_SB(sb)->s_journal; 2819 journal_t *journal = EXT4_SB(sb)->s_journal;
2823 2820
@@ -2839,8 +2836,8 @@ static void ext4_mark_recovery_complete(struct super_block * sb,
2839 * has recorded an error from a previous lifetime, move that error to the 2836 * has recorded an error from a previous lifetime, move that error to the
2840 * main filesystem now. 2837 * main filesystem now.
2841 */ 2838 */
2842static void ext4_clear_journal_err(struct super_block * sb, 2839static void ext4_clear_journal_err(struct super_block *sb,
2843 struct ext4_super_block * es) 2840 struct ext4_super_block *es)
2844{ 2841{
2845 journal_t *journal; 2842 journal_t *journal;
2846 int j_errno; 2843 int j_errno;
@@ -2865,7 +2862,7 @@ static void ext4_clear_journal_err(struct super_block * sb,
2865 2862
2866 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 2863 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2867 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 2864 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2868 ext4_commit_super (sb, es, 1); 2865 ext4_commit_super(sb, es, 1);
2869 2866
2870 jbd2_journal_clear_err(journal); 2867 jbd2_journal_clear_err(journal);
2871 } 2868 }
@@ -2898,7 +2895,7 @@ int ext4_force_commit(struct super_block *sb)
2898 * This implicitly triggers the writebehind on sync(). 2895 * This implicitly triggers the writebehind on sync().
2899 */ 2896 */
2900 2897
2901static void ext4_write_super (struct super_block * sb) 2898static void ext4_write_super(struct super_block *sb)
2902{ 2899{
2903 if (mutex_trylock(&sb->s_lock) != 0) 2900 if (mutex_trylock(&sb->s_lock) != 0)
2904 BUG(); 2901 BUG();
@@ -2954,13 +2951,14 @@ static void ext4_unlockfs(struct super_block *sb)
2954 } 2951 }
2955} 2952}
2956 2953
2957static int ext4_remount (struct super_block * sb, int * flags, char * data) 2954static int ext4_remount(struct super_block *sb, int *flags, char *data)
2958{ 2955{
2959 struct ext4_super_block * es; 2956 struct ext4_super_block *es;
2960 struct ext4_sb_info *sbi = EXT4_SB(sb); 2957 struct ext4_sb_info *sbi = EXT4_SB(sb);
2961 ext4_fsblk_t n_blocks_count = 0; 2958 ext4_fsblk_t n_blocks_count = 0;
2962 unsigned long old_sb_flags; 2959 unsigned long old_sb_flags;
2963 struct ext4_mount_options old_opts; 2960 struct ext4_mount_options old_opts;
2961 ext4_group_t g;
2964 int err; 2962 int err;
2965#ifdef CONFIG_QUOTA 2963#ifdef CONFIG_QUOTA
2966 int i; 2964 int i;
@@ -3039,6 +3037,26 @@ static int ext4_remount (struct super_block * sb, int * flags, char * data)
3039 } 3037 }
3040 3038
3041 /* 3039 /*
3040 * Make sure the group descriptor checksums
3041 * are sane. If they aren't, refuse to
3042 * remount r/w.
3043 */
3044 for (g = 0; g < sbi->s_groups_count; g++) {
3045 struct ext4_group_desc *gdp =
3046 ext4_get_group_desc(sb, g, NULL);
3047
3048 if (!ext4_group_desc_csum_verify(sbi, g, gdp)) {
3049 printk(KERN_ERR
3050 "EXT4-fs: ext4_remount: "
3051 "Checksum for group %lu failed (%u!=%u)\n",
3052 g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)),
3053 le16_to_cpu(gdp->bg_checksum));
3054 err = -EINVAL;
3055 goto restore_opts;
3056 }
3057 }
3058
3059 /*
3042 * If we have an unprocessed orphan list hanging 3060 * If we have an unprocessed orphan list hanging
3043 * around from a previously readonly bdev mount, 3061 * around from a previously readonly bdev mount,
3044 * require a full umount/remount for now. 3062 * require a full umount/remount for now.
@@ -3063,7 +3081,7 @@ static int ext4_remount (struct super_block * sb, int * flags, char * data)
3063 sbi->s_mount_state = le16_to_cpu(es->s_state); 3081 sbi->s_mount_state = le16_to_cpu(es->s_state);
3064 if ((err = ext4_group_extend(sb, es, n_blocks_count))) 3082 if ((err = ext4_group_extend(sb, es, n_blocks_count)))
3065 goto restore_opts; 3083 goto restore_opts;
3066 if (!ext4_setup_super (sb, es, 0)) 3084 if (!ext4_setup_super(sb, es, 0))
3067 sb->s_flags &= ~MS_RDONLY; 3085 sb->s_flags &= ~MS_RDONLY;
3068 } 3086 }
3069 } 3087 }
@@ -3093,7 +3111,7 @@ restore_opts:
3093 return err; 3111 return err;
3094} 3112}
3095 3113
3096static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf) 3114static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
3097{ 3115{
3098 struct super_block *sb = dentry->d_sb; 3116 struct super_block *sb = dentry->d_sb;
3099 struct ext4_sb_info *sbi = EXT4_SB(sb); 3117 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -3331,12 +3349,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
3331 } 3349 }
3332 /* Journaling quota? */ 3350 /* Journaling quota? */
3333 if (EXT4_SB(sb)->s_qf_names[type]) { 3351 if (EXT4_SB(sb)->s_qf_names[type]) {
3334 /* Quotafile not of fs root? */ 3352 /* Quotafile not in fs root? */
3335 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) 3353 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
3336 printk(KERN_WARNING 3354 printk(KERN_WARNING
3337 "EXT4-fs: Quota file not on filesystem root. " 3355 "EXT4-fs: Quota file not on filesystem root. "
3338 "Journaled quota will not work.\n"); 3356 "Journaled quota will not work.\n");
3339 } 3357 }
3340 3358
3341 /* 3359 /*
3342 * When we journal data on quota file, we have to flush journal to see 3360 * When we journal data on quota file, we have to flush journal to see