aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-08-01 23:14:20 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-08-01 23:14:20 -0400
commit8b67f04ab9de5d8f3a71aef72bf02c995a506db5 (patch)
treedd05968730762f5b18de4c6b0720843669e4e9db
parentca0e05e4b15193aeba72b995e90de990db7f8304 (diff)
ext4: Add mount options in superblock
Allow mount options to be stored in the superblock. Also add default mount option bits for nobarrier, block_validity, discard, and nodelalloc. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/ext4.h9
-rw-r--r--fs/ext4/super.c29
2 files changed, 30 insertions, 8 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9ca3637eca5f..ed14e1db0832 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1025,8 +1025,9 @@ struct ext4_super_block {
1025 __le32 s_last_error_line; /* line number where error happened */ 1025 __le32 s_last_error_line; /* line number where error happened */
1026 __le64 s_last_error_block; /* block involved of last error */ 1026 __le64 s_last_error_block; /* block involved of last error */
1027 __u8 s_last_error_func[32]; /* function where the error happened */ 1027 __u8 s_last_error_func[32]; /* function where the error happened */
1028#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_reserved) 1028#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
1029 __le32 s_reserved[128]; /* Padding to the end of the block */ 1029 __u8 s_mount_opts[64];
1030 __le32 s_reserved[112]; /* Padding to the end of the block */
1030}; 1031};
1031 1032
1032#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START) 1033#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
@@ -1341,6 +1342,10 @@ EXT4_INODE_BIT_FNS(state, state_flags)
1341#define EXT4_DEFM_JMODE_DATA 0x0020 1342#define EXT4_DEFM_JMODE_DATA 0x0020
1342#define EXT4_DEFM_JMODE_ORDERED 0x0040 1343#define EXT4_DEFM_JMODE_ORDERED 0x0040
1343#define EXT4_DEFM_JMODE_WBACK 0x0060 1344#define EXT4_DEFM_JMODE_WBACK 0x0060
1345#define EXT4_DEFM_NOBARRIER 0x0100
1346#define EXT4_DEFM_BLOCK_VALIDITY 0x0200
1347#define EXT4_DEFM_DISCARD 0x0400
1348#define EXT4_DEFM_NODELALLOC 0x0800
1344 1349
1345/* 1350/*
1346 * Default journal batch times 1351 * Default journal batch times
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3e3f6484c223..3fd65eb66ccd 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1003,10 +1003,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
1003 seq_puts(seq, ",journal_checksum"); 1003 seq_puts(seq, ",journal_checksum");
1004 if (test_opt(sb, I_VERSION)) 1004 if (test_opt(sb, I_VERSION))
1005 seq_puts(seq, ",i_version"); 1005 seq_puts(seq, ",i_version");
1006 if (!test_opt(sb, DELALLOC)) 1006 if (!test_opt(sb, DELALLOC) &&
1007 !(def_mount_opts & EXT4_DEFM_NODELALLOC))
1007 seq_puts(seq, ",nodelalloc"); 1008 seq_puts(seq, ",nodelalloc");
1008 1009
1009
1010 if (sbi->s_stripe) 1010 if (sbi->s_stripe)
1011 seq_printf(seq, ",stripe=%lu", sbi->s_stripe); 1011 seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
1012 /* 1012 /*
@@ -1030,7 +1030,7 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
1030 if (test_opt(sb, NO_AUTO_DA_ALLOC)) 1030 if (test_opt(sb, NO_AUTO_DA_ALLOC))
1031 seq_puts(seq, ",noauto_da_alloc"); 1031 seq_puts(seq, ",noauto_da_alloc");
1032 1032
1033 if (test_opt(sb, DISCARD)) 1033 if (test_opt(sb, DISCARD) && !(def_mount_opts & EXT4_DEFM_DISCARD))
1034 seq_puts(seq, ",discard"); 1034 seq_puts(seq, ",discard");
1035 1035
1036 if (test_opt(sb, NOLOAD)) 1036 if (test_opt(sb, NOLOAD))
@@ -1039,6 +1039,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
1039 if (test_opt(sb, DIOREAD_NOLOCK)) 1039 if (test_opt(sb, DIOREAD_NOLOCK))
1040 seq_puts(seq, ",dioread_nolock"); 1040 seq_puts(seq, ",dioread_nolock");
1041 1041
1042 if (test_opt(sb, BLOCK_VALIDITY) &&
1043 !(def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY))
1044 seq_puts(seq, ",block_validity");
1045
1042 ext4_show_quota_options(seq, sb); 1046 ext4_show_quota_options(seq, sb);
1043 1047
1044 return 0; 1048 return 0;
@@ -2655,6 +2659,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2655 set_opt(sbi->s_mount_opt, ERRORS_CONT); 2659 set_opt(sbi->s_mount_opt, ERRORS_CONT);
2656 else 2660 else
2657 set_opt(sbi->s_mount_opt, ERRORS_RO); 2661 set_opt(sbi->s_mount_opt, ERRORS_RO);
2662 if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY)
2663 set_opt(sbi->s_mount_opt, BLOCK_VALIDITY);
2664 if (def_mount_opts & EXT4_DEFM_DISCARD)
2665 set_opt(sbi->s_mount_opt, DISCARD);
2658 2666
2659 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 2667 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
2660 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 2668 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
@@ -2662,15 +2670,23 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2662 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; 2670 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
2663 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; 2671 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
2664 2672
2665 set_opt(sbi->s_mount_opt, BARRIER); 2673 if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)
2674 set_opt(sbi->s_mount_opt, BARRIER);
2666 2675
2667 /* 2676 /*
2668 * enable delayed allocation by default 2677 * enable delayed allocation by default
2669 * Use -o nodelalloc to turn it off 2678 * Use -o nodelalloc to turn it off
2670 */ 2679 */
2671 if (!IS_EXT3_SB(sb)) 2680 if (!IS_EXT3_SB(sb) &&
2681 ((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0))
2672 set_opt(sbi->s_mount_opt, DELALLOC); 2682 set_opt(sbi->s_mount_opt, DELALLOC);
2673 2683
2684 if (!parse_options((char *) sbi->s_es->s_mount_opts, sb,
2685 &journal_devnum, &journal_ioprio, NULL, 0)) {
2686 ext4_msg(sb, KERN_WARNING,
2687 "failed to parse options in superblock: %s",
2688 sbi->s_es->s_mount_opts);
2689 }
2674 if (!parse_options((char *) data, sb, &journal_devnum, 2690 if (!parse_options((char *) data, sb, &journal_devnum,
2675 &journal_ioprio, NULL, 0)) 2691 &journal_ioprio, NULL, 0))
2676 goto failed_mount; 2692 goto failed_mount;
@@ -3141,7 +3157,8 @@ no_journal:
3141 descr = "out journal"; 3157 descr = "out journal";
3142 3158
3143 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " 3159 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
3144 "Opts: %s", descr, orig_data); 3160 "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts,
3161 *sbi->s_es->s_mount_opts ? "; " : "", orig_data);
3145 3162
3146 init_timer(&sbi->s_err_report); 3163 init_timer(&sbi->s_err_report);
3147 sbi->s_err_report.function = print_daily_error_info; 3164 sbi->s_err_report.function = print_daily_error_info;