diff options
Diffstat (limited to 'fs/ext3/super.c')
-rw-r--r-- | fs/ext3/super.c | 707 |
1 files changed, 368 insertions, 339 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 427496c4767c..1bee604cc6cd 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -135,12 +135,24 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn, | |||
135 | if (is_handle_aborted(handle)) | 135 | if (is_handle_aborted(handle)) |
136 | return; | 136 | return; |
137 | 137 | ||
138 | printk(KERN_ERR "%s: aborting transaction: %s in %s\n", | 138 | printk(KERN_ERR "EXT3-fs: %s: aborting transaction: %s in %s\n", |
139 | caller, errstr, err_fn); | 139 | caller, errstr, err_fn); |
140 | 140 | ||
141 | journal_abort_handle(handle); | 141 | journal_abort_handle(handle); |
142 | } | 142 | } |
143 | 143 | ||
144 | void ext3_msg(struct super_block *sb, const char *prefix, | ||
145 | const char *fmt, ...) | ||
146 | { | ||
147 | va_list args; | ||
148 | |||
149 | va_start(args, fmt); | ||
150 | printk("%sEXT3-fs (%s): ", prefix, sb->s_id); | ||
151 | vprintk(fmt, args); | ||
152 | printk("\n"); | ||
153 | va_end(args); | ||
154 | } | ||
155 | |||
144 | /* Deal with the reporting of failure conditions on a filesystem such as | 156 | /* Deal with the reporting of failure conditions on a filesystem such as |
145 | * inconsistencies detected or read IO failures. | 157 | * inconsistencies detected or read IO failures. |
146 | * | 158 | * |
@@ -152,7 +164,7 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn, | |||
152 | * write out the superblock safely. | 164 | * write out the superblock safely. |
153 | * | 165 | * |
154 | * We'll just use the journal_abort() error code to record an error in | 166 | * We'll just use the journal_abort() error code to record an error in |
155 | * the journal instead. On recovery, the journal will compain about | 167 | * the journal instead. On recovery, the journal will complain about |
156 | * that error until we've noted it down and cleared it. | 168 | * that error until we've noted it down and cleared it. |
157 | */ | 169 | */ |
158 | 170 | ||
@@ -169,17 +181,18 @@ static void ext3_handle_error(struct super_block *sb) | |||
169 | if (!test_opt (sb, ERRORS_CONT)) { | 181 | if (!test_opt (sb, ERRORS_CONT)) { |
170 | journal_t *journal = EXT3_SB(sb)->s_journal; | 182 | journal_t *journal = EXT3_SB(sb)->s_journal; |
171 | 183 | ||
172 | EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; | 184 | set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); |
173 | if (journal) | 185 | if (journal) |
174 | journal_abort(journal, -EIO); | 186 | journal_abort(journal, -EIO); |
175 | } | 187 | } |
176 | if (test_opt (sb, ERRORS_RO)) { | 188 | if (test_opt (sb, ERRORS_RO)) { |
177 | printk (KERN_CRIT "Remounting filesystem read-only\n"); | 189 | ext3_msg(sb, KERN_CRIT, |
190 | "error: remounting filesystem read-only"); | ||
178 | sb->s_flags |= MS_RDONLY; | 191 | sb->s_flags |= MS_RDONLY; |
179 | } | 192 | } |
180 | ext3_commit_super(sb, es, 1); | 193 | ext3_commit_super(sb, es, 1); |
181 | if (test_opt(sb, ERRORS_PANIC)) | 194 | if (test_opt(sb, ERRORS_PANIC)) |
182 | panic("EXT3-fs (device %s): panic forced after error\n", | 195 | panic("EXT3-fs (%s): panic forced after error\n", |
183 | sb->s_id); | 196 | sb->s_id); |
184 | } | 197 | } |
185 | 198 | ||
@@ -247,8 +260,7 @@ void __ext3_std_error (struct super_block * sb, const char * function, | |||
247 | return; | 260 | return; |
248 | 261 | ||
249 | errstr = ext3_decode_error(sb, errno, nbuf); | 262 | errstr = ext3_decode_error(sb, errno, nbuf); |
250 | printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", | 263 | ext3_msg(sb, KERN_CRIT, "error in %s: %s", function, errstr); |
251 | sb->s_id, function, errstr); | ||
252 | 264 | ||
253 | ext3_handle_error(sb); | 265 | ext3_handle_error(sb); |
254 | } | 266 | } |
@@ -268,24 +280,23 @@ void ext3_abort (struct super_block * sb, const char * function, | |||
268 | { | 280 | { |
269 | va_list args; | 281 | va_list args; |
270 | 282 | ||
271 | printk (KERN_CRIT "ext3_abort called.\n"); | ||
272 | |||
273 | va_start(args, fmt); | 283 | va_start(args, fmt); |
274 | printk(KERN_CRIT "EXT3-fs error (device %s): %s: ",sb->s_id, function); | 284 | printk(KERN_CRIT "EXT3-fs (%s): error: %s: ", sb->s_id, function); |
275 | vprintk(fmt, args); | 285 | vprintk(fmt, args); |
276 | printk("\n"); | 286 | printk("\n"); |
277 | va_end(args); | 287 | va_end(args); |
278 | 288 | ||
279 | if (test_opt(sb, ERRORS_PANIC)) | 289 | if (test_opt(sb, ERRORS_PANIC)) |
280 | panic("EXT3-fs panic from previous error\n"); | 290 | panic("EXT3-fs: panic from previous error\n"); |
281 | 291 | ||
282 | if (sb->s_flags & MS_RDONLY) | 292 | if (sb->s_flags & MS_RDONLY) |
283 | return; | 293 | return; |
284 | 294 | ||
285 | printk(KERN_CRIT "Remounting filesystem read-only\n"); | 295 | ext3_msg(sb, KERN_CRIT, |
296 | "error: remounting filesystem read-only"); | ||
286 | EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; | 297 | EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; |
287 | sb->s_flags |= MS_RDONLY; | 298 | sb->s_flags |= MS_RDONLY; |
288 | EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; | 299 | set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); |
289 | if (EXT3_SB(sb)->s_journal) | 300 | if (EXT3_SB(sb)->s_journal) |
290 | journal_abort(EXT3_SB(sb)->s_journal, -EIO); | 301 | journal_abort(EXT3_SB(sb)->s_journal, -EIO); |
291 | } | 302 | } |
@@ -296,7 +307,7 @@ void ext3_warning (struct super_block * sb, const char * function, | |||
296 | va_list args; | 307 | va_list args; |
297 | 308 | ||
298 | va_start(args, fmt); | 309 | va_start(args, fmt); |
299 | printk(KERN_WARNING "EXT3-fs warning (device %s): %s: ", | 310 | printk(KERN_WARNING "EXT3-fs (%s): warning: %s: ", |
300 | sb->s_id, function); | 311 | sb->s_id, function); |
301 | vprintk(fmt, args); | 312 | vprintk(fmt, args); |
302 | printk("\n"); | 313 | printk("\n"); |
@@ -310,10 +321,10 @@ void ext3_update_dynamic_rev(struct super_block *sb) | |||
310 | if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV) | 321 | if (le32_to_cpu(es->s_rev_level) > EXT3_GOOD_OLD_REV) |
311 | return; | 322 | return; |
312 | 323 | ||
313 | ext3_warning(sb, __func__, | 324 | ext3_msg(sb, KERN_WARNING, |
314 | "updating to rev %d because of new feature flag, " | 325 | "warning: updating to rev %d because of " |
315 | "running e2fsck is recommended", | 326 | "new feature flag, running e2fsck is recommended", |
316 | EXT3_DYNAMIC_REV); | 327 | EXT3_DYNAMIC_REV); |
317 | 328 | ||
318 | es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO); | 329 | es->s_first_ino = cpu_to_le32(EXT3_GOOD_OLD_FIRST_INO); |
319 | es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE); | 330 | es->s_inode_size = cpu_to_le16(EXT3_GOOD_OLD_INODE_SIZE); |
@@ -331,7 +342,7 @@ void ext3_update_dynamic_rev(struct super_block *sb) | |||
331 | /* | 342 | /* |
332 | * Open the external journal device | 343 | * Open the external journal device |
333 | */ | 344 | */ |
334 | static struct block_device *ext3_blkdev_get(dev_t dev) | 345 | static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb) |
335 | { | 346 | { |
336 | struct block_device *bdev; | 347 | struct block_device *bdev; |
337 | char b[BDEVNAME_SIZE]; | 348 | char b[BDEVNAME_SIZE]; |
@@ -342,8 +353,9 @@ static struct block_device *ext3_blkdev_get(dev_t dev) | |||
342 | return bdev; | 353 | return bdev; |
343 | 354 | ||
344 | fail: | 355 | fail: |
345 | printk(KERN_ERR "EXT3: failed to open journal device %s: %ld\n", | 356 | ext3_msg(sb, "error: failed to open journal device %s: %ld", |
346 | __bdevname(dev, b), PTR_ERR(bdev)); | 357 | __bdevname(dev, b), PTR_ERR(bdev)); |
358 | |||
347 | return NULL; | 359 | return NULL; |
348 | } | 360 | } |
349 | 361 | ||
@@ -378,13 +390,13 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) | |||
378 | { | 390 | { |
379 | struct list_head *l; | 391 | struct list_head *l; |
380 | 392 | ||
381 | printk(KERN_ERR "sb orphan head is %d\n", | 393 | ext3_msg(sb, KERN_ERR, "error: sb orphan head is %d", |
382 | le32_to_cpu(sbi->s_es->s_last_orphan)); | 394 | le32_to_cpu(sbi->s_es->s_last_orphan)); |
383 | 395 | ||
384 | printk(KERN_ERR "sb_info orphan list:\n"); | 396 | ext3_msg(sb, KERN_ERR, "sb_info orphan list:"); |
385 | list_for_each(l, &sbi->s_orphan) { | 397 | list_for_each(l, &sbi->s_orphan) { |
386 | struct inode *inode = orphan_list_entry(l); | 398 | struct inode *inode = orphan_list_entry(l); |
387 | printk(KERN_ERR " " | 399 | ext3_msg(sb, KERN_ERR, " " |
388 | "inode %s:%lu at %p: mode %o, nlink %d, next %d\n", | 400 | "inode %s:%lu at %p: mode %o, nlink %d, next %d\n", |
389 | inode->i_sb->s_id, inode->i_ino, inode, | 401 | inode->i_sb->s_id, inode->i_ino, inode, |
390 | inode->i_mode, inode->i_nlink, | 402 | inode->i_mode, inode->i_nlink, |
@@ -516,6 +528,8 @@ static void destroy_inodecache(void) | |||
516 | static void ext3_clear_inode(struct inode *inode) | 528 | static void ext3_clear_inode(struct inode *inode) |
517 | { | 529 | { |
518 | struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; | 530 | struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; |
531 | |||
532 | dquot_drop(inode); | ||
519 | ext3_discard_reservation(inode); | 533 | ext3_discard_reservation(inode); |
520 | EXT3_I(inode)->i_block_alloc_info = NULL; | 534 | EXT3_I(inode)->i_block_alloc_info = NULL; |
521 | if (unlikely(rsv)) | 535 | if (unlikely(rsv)) |
@@ -527,9 +541,22 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl | |||
527 | #if defined(CONFIG_QUOTA) | 541 | #if defined(CONFIG_QUOTA) |
528 | struct ext3_sb_info *sbi = EXT3_SB(sb); | 542 | struct ext3_sb_info *sbi = EXT3_SB(sb); |
529 | 543 | ||
530 | if (sbi->s_jquota_fmt) | 544 | if (sbi->s_jquota_fmt) { |
531 | seq_printf(seq, ",jqfmt=%s", | 545 | char *fmtname = ""; |
532 | (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); | 546 | |
547 | switch (sbi->s_jquota_fmt) { | ||
548 | case QFMT_VFS_OLD: | ||
549 | fmtname = "vfsold"; | ||
550 | break; | ||
551 | case QFMT_VFS_V0: | ||
552 | fmtname = "vfsv0"; | ||
553 | break; | ||
554 | case QFMT_VFS_V1: | ||
555 | fmtname = "vfsv1"; | ||
556 | break; | ||
557 | } | ||
558 | seq_printf(seq, ",jqfmt=%s", fmtname); | ||
559 | } | ||
533 | 560 | ||
534 | if (sbi->s_qf_names[USRQUOTA]) | 561 | if (sbi->s_qf_names[USRQUOTA]) |
535 | seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]); | 562 | seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]); |
@@ -537,10 +564,10 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl | |||
537 | if (sbi->s_qf_names[GRPQUOTA]) | 564 | if (sbi->s_qf_names[GRPQUOTA]) |
538 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); | 565 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); |
539 | 566 | ||
540 | if (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) | 567 | if (test_opt(sb, USRQUOTA)) |
541 | seq_puts(seq, ",usrquota"); | 568 | seq_puts(seq, ",usrquota"); |
542 | 569 | ||
543 | if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) | 570 | if (test_opt(sb, GRPQUOTA)) |
544 | seq_puts(seq, ",grpquota"); | 571 | seq_puts(seq, ",grpquota"); |
545 | #endif | 572 | #endif |
546 | } | 573 | } |
@@ -631,11 +658,13 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
631 | if (test_opt(sb, NOBH)) | 658 | if (test_opt(sb, NOBH)) |
632 | seq_puts(seq, ",nobh"); | 659 | seq_puts(seq, ",nobh"); |
633 | 660 | ||
634 | seq_printf(seq, ",data=%s", data_mode_string(sbi->s_mount_opt & | 661 | seq_printf(seq, ",data=%s", data_mode_string(test_opt(sb, DATA_FLAGS))); |
635 | EXT3_MOUNT_DATA_FLAGS)); | ||
636 | if (test_opt(sb, DATA_ERR_ABORT)) | 662 | if (test_opt(sb, DATA_ERR_ABORT)) |
637 | seq_puts(seq, ",data_err=abort"); | 663 | seq_puts(seq, ",data_err=abort"); |
638 | 664 | ||
665 | if (test_opt(sb, NOLOAD)) | ||
666 | seq_puts(seq, ",norecovery"); | ||
667 | |||
639 | ext3_show_quota_options(seq, sb); | 668 | ext3_show_quota_options(seq, sb); |
640 | 669 | ||
641 | return 0; | 670 | return 0; |
@@ -723,13 +752,6 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
723 | const char *data, size_t len, loff_t off); | 752 | const char *data, size_t len, loff_t off); |
724 | 753 | ||
725 | static const struct dquot_operations ext3_quota_operations = { | 754 | static const struct dquot_operations ext3_quota_operations = { |
726 | .initialize = dquot_initialize, | ||
727 | .drop = dquot_drop, | ||
728 | .alloc_space = dquot_alloc_space, | ||
729 | .alloc_inode = dquot_alloc_inode, | ||
730 | .free_space = dquot_free_space, | ||
731 | .free_inode = dquot_free_inode, | ||
732 | .transfer = dquot_transfer, | ||
733 | .write_dquot = ext3_write_dquot, | 755 | .write_dquot = ext3_write_dquot, |
734 | .acquire_dquot = ext3_acquire_dquot, | 756 | .acquire_dquot = ext3_acquire_dquot, |
735 | .release_dquot = ext3_release_dquot, | 757 | .release_dquot = ext3_release_dquot, |
@@ -787,9 +809,9 @@ enum { | |||
787 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, | 809 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, |
788 | Opt_data_err_abort, Opt_data_err_ignore, | 810 | Opt_data_err_abort, Opt_data_err_ignore, |
789 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 811 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
790 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 812 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, |
791 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, | 813 | Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize, |
792 | Opt_grpquota | 814 | Opt_usrquota, Opt_grpquota |
793 | }; | 815 | }; |
794 | 816 | ||
795 | static const match_table_t tokens = { | 817 | static const match_table_t tokens = { |
@@ -818,6 +840,7 @@ static const match_table_t tokens = { | |||
818 | {Opt_reservation, "reservation"}, | 840 | {Opt_reservation, "reservation"}, |
819 | {Opt_noreservation, "noreservation"}, | 841 | {Opt_noreservation, "noreservation"}, |
820 | {Opt_noload, "noload"}, | 842 | {Opt_noload, "noload"}, |
843 | {Opt_noload, "norecovery"}, | ||
821 | {Opt_nobh, "nobh"}, | 844 | {Opt_nobh, "nobh"}, |
822 | {Opt_bh, "bh"}, | 845 | {Opt_bh, "bh"}, |
823 | {Opt_commit, "commit=%u"}, | 846 | {Opt_commit, "commit=%u"}, |
@@ -836,6 +859,7 @@ static const match_table_t tokens = { | |||
836 | {Opt_grpjquota, "grpjquota=%s"}, | 859 | {Opt_grpjquota, "grpjquota=%s"}, |
837 | {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, | 860 | {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, |
838 | {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, | 861 | {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, |
862 | {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"}, | ||
839 | {Opt_grpquota, "grpquota"}, | 863 | {Opt_grpquota, "grpquota"}, |
840 | {Opt_noquota, "noquota"}, | 864 | {Opt_noquota, "noquota"}, |
841 | {Opt_quota, "quota"}, | 865 | {Opt_quota, "quota"}, |
@@ -845,7 +869,7 @@ static const match_table_t tokens = { | |||
845 | {Opt_err, NULL}, | 869 | {Opt_err, NULL}, |
846 | }; | 870 | }; |
847 | 871 | ||
848 | static ext3_fsblk_t get_sb_block(void **data) | 872 | static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb) |
849 | { | 873 | { |
850 | ext3_fsblk_t sb_block; | 874 | ext3_fsblk_t sb_block; |
851 | char *options = (char *) *data; | 875 | char *options = (char *) *data; |
@@ -856,7 +880,7 @@ static ext3_fsblk_t get_sb_block(void **data) | |||
856 | /*todo: use simple_strtoll with >32bit ext3 */ | 880 | /*todo: use simple_strtoll with >32bit ext3 */ |
857 | sb_block = simple_strtoul(options, &options, 0); | 881 | sb_block = simple_strtoul(options, &options, 0); |
858 | if (*options && *options != ',') { | 882 | if (*options && *options != ',') { |
859 | printk("EXT3-fs: Invalid sb specification: %s\n", | 883 | ext3_msg(sb, "error: invalid sb specification: %s", |
860 | (char *) *data); | 884 | (char *) *data); |
861 | return 1; | 885 | return 1; |
862 | } | 886 | } |
@@ -866,6 +890,63 @@ static ext3_fsblk_t get_sb_block(void **data) | |||
866 | return sb_block; | 890 | return sb_block; |
867 | } | 891 | } |
868 | 892 | ||
893 | #ifdef CONFIG_QUOTA | ||
894 | static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) | ||
895 | { | ||
896 | struct ext3_sb_info *sbi = EXT3_SB(sb); | ||
897 | char *qname; | ||
898 | |||
899 | if (sb_any_quota_loaded(sb) && | ||
900 | !sbi->s_qf_names[qtype]) { | ||
901 | ext3_msg(sb, KERN_ERR, | ||
902 | "Cannot change journaled " | ||
903 | "quota options when quota turned on"); | ||
904 | return 0; | ||
905 | } | ||
906 | qname = match_strdup(args); | ||
907 | if (!qname) { | ||
908 | ext3_msg(sb, KERN_ERR, | ||
909 | "Not enough memory for storing quotafile name"); | ||
910 | return 0; | ||
911 | } | ||
912 | if (sbi->s_qf_names[qtype] && | ||
913 | strcmp(sbi->s_qf_names[qtype], qname)) { | ||
914 | ext3_msg(sb, KERN_ERR, | ||
915 | "%s quota file already specified", QTYPE2NAME(qtype)); | ||
916 | kfree(qname); | ||
917 | return 0; | ||
918 | } | ||
919 | sbi->s_qf_names[qtype] = qname; | ||
920 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
921 | ext3_msg(sb, KERN_ERR, | ||
922 | "quotafile must be on filesystem root"); | ||
923 | kfree(sbi->s_qf_names[qtype]); | ||
924 | sbi->s_qf_names[qtype] = NULL; | ||
925 | return 0; | ||
926 | } | ||
927 | set_opt(sbi->s_mount_opt, QUOTA); | ||
928 | return 1; | ||
929 | } | ||
930 | |||
931 | static int clear_qf_name(struct super_block *sb, int qtype) { | ||
932 | |||
933 | struct ext3_sb_info *sbi = EXT3_SB(sb); | ||
934 | |||
935 | if (sb_any_quota_loaded(sb) && | ||
936 | sbi->s_qf_names[qtype]) { | ||
937 | ext3_msg(sb, KERN_ERR, "Cannot change journaled quota options" | ||
938 | " when quota turned on"); | ||
939 | return 0; | ||
940 | } | ||
941 | /* | ||
942 | * The space will be released later when all options are confirmed | ||
943 | * to be correct | ||
944 | */ | ||
945 | sbi->s_qf_names[qtype] = NULL; | ||
946 | return 1; | ||
947 | } | ||
948 | #endif | ||
949 | |||
869 | static int parse_options (char *options, struct super_block *sb, | 950 | static int parse_options (char *options, struct super_block *sb, |
870 | unsigned int *inum, unsigned long *journal_devnum, | 951 | unsigned int *inum, unsigned long *journal_devnum, |
871 | ext3_fsblk_t *n_blocks_count, int is_remount) | 952 | ext3_fsblk_t *n_blocks_count, int is_remount) |
@@ -876,8 +957,7 @@ static int parse_options (char *options, struct super_block *sb, | |||
876 | int data_opt = 0; | 957 | int data_opt = 0; |
877 | int option; | 958 | int option; |
878 | #ifdef CONFIG_QUOTA | 959 | #ifdef CONFIG_QUOTA |
879 | int qtype, qfmt; | 960 | int qfmt; |
880 | char *qname; | ||
881 | #endif | 961 | #endif |
882 | 962 | ||
883 | if (!options) | 963 | if (!options) |
@@ -956,7 +1036,8 @@ static int parse_options (char *options, struct super_block *sb, | |||
956 | #else | 1036 | #else |
957 | case Opt_user_xattr: | 1037 | case Opt_user_xattr: |
958 | case Opt_nouser_xattr: | 1038 | case Opt_nouser_xattr: |
959 | printk("EXT3 (no)user_xattr options not supported\n"); | 1039 | ext3_msg(sb, KERN_INFO, |
1040 | "(no)user_xattr options not supported"); | ||
960 | break; | 1041 | break; |
961 | #endif | 1042 | #endif |
962 | #ifdef CONFIG_EXT3_FS_POSIX_ACL | 1043 | #ifdef CONFIG_EXT3_FS_POSIX_ACL |
@@ -969,7 +1050,8 @@ static int parse_options (char *options, struct super_block *sb, | |||
969 | #else | 1050 | #else |
970 | case Opt_acl: | 1051 | case Opt_acl: |
971 | case Opt_noacl: | 1052 | case Opt_noacl: |
972 | printk("EXT3 (no)acl options not supported\n"); | 1053 | ext3_msg(sb, KERN_INFO, |
1054 | "(no)acl options not supported"); | ||
973 | break; | 1055 | break; |
974 | #endif | 1056 | #endif |
975 | case Opt_reservation: | 1057 | case Opt_reservation: |
@@ -985,16 +1067,16 @@ static int parse_options (char *options, struct super_block *sb, | |||
985 | user to specify an existing inode to be the | 1067 | user to specify an existing inode to be the |
986 | journal file. */ | 1068 | journal file. */ |
987 | if (is_remount) { | 1069 | if (is_remount) { |
988 | printk(KERN_ERR "EXT3-fs: cannot specify " | 1070 | ext3_msg(sb, KERN_ERR, "error: cannot specify " |
989 | "journal on remount\n"); | 1071 | "journal on remount"); |
990 | return 0; | 1072 | return 0; |
991 | } | 1073 | } |
992 | set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); | 1074 | set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); |
993 | break; | 1075 | break; |
994 | case Opt_journal_inum: | 1076 | case Opt_journal_inum: |
995 | if (is_remount) { | 1077 | if (is_remount) { |
996 | printk(KERN_ERR "EXT3-fs: cannot specify " | 1078 | ext3_msg(sb, KERN_ERR, "error: cannot specify " |
997 | "journal on remount\n"); | 1079 | "journal on remount"); |
998 | return 0; | 1080 | return 0; |
999 | } | 1081 | } |
1000 | if (match_int(&args[0], &option)) | 1082 | if (match_int(&args[0], &option)) |
@@ -1003,8 +1085,8 @@ static int parse_options (char *options, struct super_block *sb, | |||
1003 | break; | 1085 | break; |
1004 | case Opt_journal_dev: | 1086 | case Opt_journal_dev: |
1005 | if (is_remount) { | 1087 | if (is_remount) { |
1006 | printk(KERN_ERR "EXT3-fs: cannot specify " | 1088 | ext3_msg(sb, KERN_ERR, "error: cannot specify " |
1007 | "journal on remount\n"); | 1089 | "journal on remount"); |
1008 | return 0; | 1090 | return 0; |
1009 | } | 1091 | } |
1010 | if (match_int(&args[0], &option)) | 1092 | if (match_int(&args[0], &option)) |
@@ -1033,21 +1115,19 @@ static int parse_options (char *options, struct super_block *sb, | |||
1033 | data_opt = EXT3_MOUNT_WRITEBACK_DATA; | 1115 | data_opt = EXT3_MOUNT_WRITEBACK_DATA; |
1034 | datacheck: | 1116 | datacheck: |
1035 | if (is_remount) { | 1117 | if (is_remount) { |
1036 | if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) | 1118 | if (test_opt(sb, DATA_FLAGS) == data_opt) |
1037 | == data_opt) | ||
1038 | break; | 1119 | break; |
1039 | printk(KERN_ERR | 1120 | ext3_msg(sb, KERN_ERR, |
1040 | "EXT3-fs (device %s): Cannot change " | 1121 | "error: cannot change " |
1041 | "data mode on remount. The filesystem " | 1122 | "data mode on remount. The filesystem " |
1042 | "is mounted in data=%s mode and you " | 1123 | "is mounted in data=%s mode and you " |
1043 | "try to remount it in data=%s mode.\n", | 1124 | "try to remount it in data=%s mode.", |
1044 | sb->s_id, | 1125 | data_mode_string(test_opt(sb, |
1045 | data_mode_string(sbi->s_mount_opt & | 1126 | DATA_FLAGS)), |
1046 | EXT3_MOUNT_DATA_FLAGS), | ||
1047 | data_mode_string(data_opt)); | 1127 | data_mode_string(data_opt)); |
1048 | return 0; | 1128 | return 0; |
1049 | } else { | 1129 | } else { |
1050 | sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; | 1130 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
1051 | sbi->s_mount_opt |= data_opt; | 1131 | sbi->s_mount_opt |= data_opt; |
1052 | } | 1132 | } |
1053 | break; | 1133 | break; |
@@ -1059,74 +1139,35 @@ static int parse_options (char *options, struct super_block *sb, | |||
1059 | break; | 1139 | break; |
1060 | #ifdef CONFIG_QUOTA | 1140 | #ifdef CONFIG_QUOTA |
1061 | case Opt_usrjquota: | 1141 | case Opt_usrjquota: |
1062 | qtype = USRQUOTA; | 1142 | if (!set_qf_name(sb, USRQUOTA, &args[0])) |
1063 | goto set_qf_name; | ||
1064 | case Opt_grpjquota: | ||
1065 | qtype = GRPQUOTA; | ||
1066 | set_qf_name: | ||
1067 | if (sb_any_quota_loaded(sb) && | ||
1068 | !sbi->s_qf_names[qtype]) { | ||
1069 | printk(KERN_ERR | ||
1070 | "EXT3-fs: Cannot change journaled " | ||
1071 | "quota options when quota turned on.\n"); | ||
1072 | return 0; | 1143 | return 0; |
1073 | } | 1144 | break; |
1074 | qname = match_strdup(&args[0]); | 1145 | case Opt_grpjquota: |
1075 | if (!qname) { | 1146 | if (!set_qf_name(sb, GRPQUOTA, &args[0])) |
1076 | printk(KERN_ERR | ||
1077 | "EXT3-fs: not enough memory for " | ||
1078 | "storing quotafile name.\n"); | ||
1079 | return 0; | ||
1080 | } | ||
1081 | if (sbi->s_qf_names[qtype] && | ||
1082 | strcmp(sbi->s_qf_names[qtype], qname)) { | ||
1083 | printk(KERN_ERR | ||
1084 | "EXT3-fs: %s quota file already " | ||
1085 | "specified.\n", QTYPE2NAME(qtype)); | ||
1086 | kfree(qname); | ||
1087 | return 0; | ||
1088 | } | ||
1089 | sbi->s_qf_names[qtype] = qname; | ||
1090 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
1091 | printk(KERN_ERR | ||
1092 | "EXT3-fs: quotafile must be on " | ||
1093 | "filesystem root.\n"); | ||
1094 | kfree(sbi->s_qf_names[qtype]); | ||
1095 | sbi->s_qf_names[qtype] = NULL; | ||
1096 | return 0; | 1147 | return 0; |
1097 | } | ||
1098 | set_opt(sbi->s_mount_opt, QUOTA); | ||
1099 | break; | 1148 | break; |
1100 | case Opt_offusrjquota: | 1149 | case Opt_offusrjquota: |
1101 | qtype = USRQUOTA; | 1150 | if (!clear_qf_name(sb, USRQUOTA)) |
1102 | goto clear_qf_name; | 1151 | return 0; |
1152 | break; | ||
1103 | case Opt_offgrpjquota: | 1153 | case Opt_offgrpjquota: |
1104 | qtype = GRPQUOTA; | 1154 | if (!clear_qf_name(sb, GRPQUOTA)) |
1105 | clear_qf_name: | ||
1106 | if (sb_any_quota_loaded(sb) && | ||
1107 | sbi->s_qf_names[qtype]) { | ||
1108 | printk(KERN_ERR "EXT3-fs: Cannot change " | ||
1109 | "journaled quota options when " | ||
1110 | "quota turned on.\n"); | ||
1111 | return 0; | 1155 | return 0; |
1112 | } | ||
1113 | /* | ||
1114 | * The space will be released later when all options | ||
1115 | * are confirmed to be correct | ||
1116 | */ | ||
1117 | sbi->s_qf_names[qtype] = NULL; | ||
1118 | break; | 1156 | break; |
1119 | case Opt_jqfmt_vfsold: | 1157 | case Opt_jqfmt_vfsold: |
1120 | qfmt = QFMT_VFS_OLD; | 1158 | qfmt = QFMT_VFS_OLD; |
1121 | goto set_qf_format; | 1159 | goto set_qf_format; |
1122 | case Opt_jqfmt_vfsv0: | 1160 | case Opt_jqfmt_vfsv0: |
1123 | qfmt = QFMT_VFS_V0; | 1161 | qfmt = QFMT_VFS_V0; |
1162 | goto set_qf_format; | ||
1163 | case Opt_jqfmt_vfsv1: | ||
1164 | qfmt = QFMT_VFS_V1; | ||
1124 | set_qf_format: | 1165 | set_qf_format: |
1125 | if (sb_any_quota_loaded(sb) && | 1166 | if (sb_any_quota_loaded(sb) && |
1126 | sbi->s_jquota_fmt != qfmt) { | 1167 | sbi->s_jquota_fmt != qfmt) { |
1127 | printk(KERN_ERR "EXT3-fs: Cannot change " | 1168 | ext3_msg(sb, KERN_ERR, "error: cannot change " |
1128 | "journaled quota options when " | 1169 | "journaled quota options when " |
1129 | "quota turned on.\n"); | 1170 | "quota turned on."); |
1130 | return 0; | 1171 | return 0; |
1131 | } | 1172 | } |
1132 | sbi->s_jquota_fmt = qfmt; | 1173 | sbi->s_jquota_fmt = qfmt; |
@@ -1142,8 +1183,8 @@ set_qf_format: | |||
1142 | break; | 1183 | break; |
1143 | case Opt_noquota: | 1184 | case Opt_noquota: |
1144 | if (sb_any_quota_loaded(sb)) { | 1185 | if (sb_any_quota_loaded(sb)) { |
1145 | printk(KERN_ERR "EXT3-fs: Cannot change quota " | 1186 | ext3_msg(sb, KERN_ERR, "error: cannot change " |
1146 | "options when quota turned on.\n"); | 1187 | "quota options when quota turned on."); |
1147 | return 0; | 1188 | return 0; |
1148 | } | 1189 | } |
1149 | clear_opt(sbi->s_mount_opt, QUOTA); | 1190 | clear_opt(sbi->s_mount_opt, QUOTA); |
@@ -1154,8 +1195,8 @@ set_qf_format: | |||
1154 | case Opt_quota: | 1195 | case Opt_quota: |
1155 | case Opt_usrquota: | 1196 | case Opt_usrquota: |
1156 | case Opt_grpquota: | 1197 | case Opt_grpquota: |
1157 | printk(KERN_ERR | 1198 | ext3_msg(sb, KERN_ERR, |
1158 | "EXT3-fs: quota options not supported.\n"); | 1199 | "error: quota options not supported."); |
1159 | break; | 1200 | break; |
1160 | case Opt_usrjquota: | 1201 | case Opt_usrjquota: |
1161 | case Opt_grpjquota: | 1202 | case Opt_grpjquota: |
@@ -1163,9 +1204,10 @@ set_qf_format: | |||
1163 | case Opt_offgrpjquota: | 1204 | case Opt_offgrpjquota: |
1164 | case Opt_jqfmt_vfsold: | 1205 | case Opt_jqfmt_vfsold: |
1165 | case Opt_jqfmt_vfsv0: | 1206 | case Opt_jqfmt_vfsv0: |
1166 | printk(KERN_ERR | 1207 | case Opt_jqfmt_vfsv1: |
1167 | "EXT3-fs: journaled quota options not " | 1208 | ext3_msg(sb, KERN_ERR, |
1168 | "supported.\n"); | 1209 | "error: journaled quota options not " |
1210 | "supported."); | ||
1169 | break; | 1211 | break; |
1170 | case Opt_noquota: | 1212 | case Opt_noquota: |
1171 | break; | 1213 | break; |
@@ -1185,8 +1227,9 @@ set_qf_format: | |||
1185 | break; | 1227 | break; |
1186 | case Opt_resize: | 1228 | case Opt_resize: |
1187 | if (!is_remount) { | 1229 | if (!is_remount) { |
1188 | printk("EXT3-fs: resize option only available " | 1230 | ext3_msg(sb, KERN_ERR, |
1189 | "for remount\n"); | 1231 | "error: resize option only available " |
1232 | "for remount"); | ||
1190 | return 0; | 1233 | return 0; |
1191 | } | 1234 | } |
1192 | if (match_int(&args[0], &option) != 0) | 1235 | if (match_int(&args[0], &option) != 0) |
@@ -1200,41 +1243,35 @@ set_qf_format: | |||
1200 | clear_opt(sbi->s_mount_opt, NOBH); | 1243 | clear_opt(sbi->s_mount_opt, NOBH); |
1201 | break; | 1244 | break; |
1202 | default: | 1245 | default: |
1203 | printk (KERN_ERR | 1246 | ext3_msg(sb, KERN_ERR, |
1204 | "EXT3-fs: Unrecognized mount option \"%s\" " | 1247 | "error: unrecognized mount option \"%s\" " |
1205 | "or missing value\n", p); | 1248 | "or missing value", p); |
1206 | return 0; | 1249 | return 0; |
1207 | } | 1250 | } |
1208 | } | 1251 | } |
1209 | #ifdef CONFIG_QUOTA | 1252 | #ifdef CONFIG_QUOTA |
1210 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { | 1253 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { |
1211 | if ((sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) && | 1254 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) |
1212 | sbi->s_qf_names[USRQUOTA]) | ||
1213 | clear_opt(sbi->s_mount_opt, USRQUOTA); | 1255 | clear_opt(sbi->s_mount_opt, USRQUOTA); |
1214 | 1256 | if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) | |
1215 | if ((sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) && | ||
1216 | sbi->s_qf_names[GRPQUOTA]) | ||
1217 | clear_opt(sbi->s_mount_opt, GRPQUOTA); | 1257 | clear_opt(sbi->s_mount_opt, GRPQUOTA); |
1218 | 1258 | ||
1219 | if ((sbi->s_qf_names[USRQUOTA] && | 1259 | if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { |
1220 | (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || | 1260 | ext3_msg(sb, KERN_ERR, "error: old and new quota " |
1221 | (sbi->s_qf_names[GRPQUOTA] && | 1261 | "format mixing."); |
1222 | (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) { | ||
1223 | printk(KERN_ERR "EXT3-fs: old and new quota " | ||
1224 | "format mixing.\n"); | ||
1225 | return 0; | 1262 | return 0; |
1226 | } | 1263 | } |
1227 | 1264 | ||
1228 | if (!sbi->s_jquota_fmt) { | 1265 | if (!sbi->s_jquota_fmt) { |
1229 | printk(KERN_ERR "EXT3-fs: journaled quota format " | 1266 | ext3_msg(sb, KERN_ERR, "error: journaled quota format " |
1230 | "not specified.\n"); | 1267 | "not specified."); |
1231 | return 0; | 1268 | return 0; |
1232 | } | 1269 | } |
1233 | } else { | 1270 | } else { |
1234 | if (sbi->s_jquota_fmt) { | 1271 | if (sbi->s_jquota_fmt) { |
1235 | printk(KERN_ERR "EXT3-fs: journaled quota format " | 1272 | ext3_msg(sb, KERN_ERR, "error: journaled quota format " |
1236 | "specified with no journaling " | 1273 | "specified with no journaling " |
1237 | "enabled.\n"); | 1274 | "enabled."); |
1238 | return 0; | 1275 | return 0; |
1239 | } | 1276 | } |
1240 | } | 1277 | } |
@@ -1249,31 +1286,33 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1249 | int res = 0; | 1286 | int res = 0; |
1250 | 1287 | ||
1251 | if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { | 1288 | if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { |
1252 | printk (KERN_ERR "EXT3-fs warning: revision level too high, " | 1289 | ext3_msg(sb, KERN_ERR, |
1253 | "forcing read-only mode\n"); | 1290 | "error: revision level too high, " |
1291 | "forcing read-only mode"); | ||
1254 | res = MS_RDONLY; | 1292 | res = MS_RDONLY; |
1255 | } | 1293 | } |
1256 | if (read_only) | 1294 | if (read_only) |
1257 | return res; | 1295 | return res; |
1258 | if (!(sbi->s_mount_state & EXT3_VALID_FS)) | 1296 | if (!(sbi->s_mount_state & EXT3_VALID_FS)) |
1259 | printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, " | 1297 | ext3_msg(sb, KERN_WARNING, |
1260 | "running e2fsck is recommended\n"); | 1298 | "warning: mounting unchecked fs, " |
1299 | "running e2fsck is recommended"); | ||
1261 | else if ((sbi->s_mount_state & EXT3_ERROR_FS)) | 1300 | else if ((sbi->s_mount_state & EXT3_ERROR_FS)) |
1262 | printk (KERN_WARNING | 1301 | ext3_msg(sb, KERN_WARNING, |
1263 | "EXT3-fs warning: mounting fs with errors, " | 1302 | "warning: mounting fs with errors, " |
1264 | "running e2fsck is recommended\n"); | 1303 | "running e2fsck is recommended"); |
1265 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && | 1304 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && |
1266 | le16_to_cpu(es->s_mnt_count) >= | 1305 | le16_to_cpu(es->s_mnt_count) >= |
1267 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) | 1306 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) |
1268 | printk (KERN_WARNING | 1307 | ext3_msg(sb, KERN_WARNING, |
1269 | "EXT3-fs warning: maximal mount count reached, " | 1308 | "warning: maximal mount count reached, " |
1270 | "running e2fsck is recommended\n"); | 1309 | "running e2fsck is recommended"); |
1271 | else if (le32_to_cpu(es->s_checkinterval) && | 1310 | else if (le32_to_cpu(es->s_checkinterval) && |
1272 | (le32_to_cpu(es->s_lastcheck) + | 1311 | (le32_to_cpu(es->s_lastcheck) + |
1273 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) | 1312 | le32_to_cpu(es->s_checkinterval) <= get_seconds())) |
1274 | printk (KERN_WARNING | 1313 | ext3_msg(sb, KERN_WARNING, |
1275 | "EXT3-fs warning: checktime reached, " | 1314 | "warning: checktime reached, " |
1276 | "running e2fsck is recommended\n"); | 1315 | "running e2fsck is recommended"); |
1277 | #if 0 | 1316 | #if 0 |
1278 | /* @@@ We _will_ want to clear the valid bit if we find | 1317 | /* @@@ We _will_ want to clear the valid bit if we find |
1279 | inconsistencies, to force a fsck at reboot. But for | 1318 | inconsistencies, to force a fsck at reboot. But for |
@@ -1290,22 +1329,20 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1290 | 1329 | ||
1291 | ext3_commit_super(sb, es, 1); | 1330 | ext3_commit_super(sb, es, 1); |
1292 | if (test_opt(sb, DEBUG)) | 1331 | if (test_opt(sb, DEBUG)) |
1293 | printk(KERN_INFO "[EXT3 FS bs=%lu, gc=%lu, " | 1332 | ext3_msg(sb, KERN_INFO, "[bs=%lu, gc=%lu, " |
1294 | "bpg=%lu, ipg=%lu, mo=%04lx]\n", | 1333 | "bpg=%lu, ipg=%lu, mo=%04lx]", |
1295 | sb->s_blocksize, | 1334 | sb->s_blocksize, |
1296 | sbi->s_groups_count, | 1335 | sbi->s_groups_count, |
1297 | EXT3_BLOCKS_PER_GROUP(sb), | 1336 | EXT3_BLOCKS_PER_GROUP(sb), |
1298 | EXT3_INODES_PER_GROUP(sb), | 1337 | EXT3_INODES_PER_GROUP(sb), |
1299 | sbi->s_mount_opt); | 1338 | sbi->s_mount_opt); |
1300 | 1339 | ||
1301 | printk(KERN_INFO "EXT3 FS on %s, ", sb->s_id); | ||
1302 | if (EXT3_SB(sb)->s_journal->j_inode == NULL) { | 1340 | if (EXT3_SB(sb)->s_journal->j_inode == NULL) { |
1303 | char b[BDEVNAME_SIZE]; | 1341 | char b[BDEVNAME_SIZE]; |
1304 | 1342 | ext3_msg(sb, KERN_INFO, "using external journal on %s", | |
1305 | printk("external journal on %s\n", | ||
1306 | bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); | 1343 | bdevname(EXT3_SB(sb)->s_journal->j_dev, b)); |
1307 | } else { | 1344 | } else { |
1308 | printk("internal journal\n"); | 1345 | ext3_msg(sb, KERN_INFO, "using internal journal"); |
1309 | } | 1346 | } |
1310 | return res; | 1347 | return res; |
1311 | } | 1348 | } |
@@ -1399,8 +1436,8 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1399 | } | 1436 | } |
1400 | 1437 | ||
1401 | if (bdev_read_only(sb->s_bdev)) { | 1438 | if (bdev_read_only(sb->s_bdev)) { |
1402 | printk(KERN_ERR "EXT3-fs: write access " | 1439 | ext3_msg(sb, KERN_ERR, "error: write access " |
1403 | "unavailable, skipping orphan cleanup.\n"); | 1440 | "unavailable, skipping orphan cleanup."); |
1404 | return; | 1441 | return; |
1405 | } | 1442 | } |
1406 | 1443 | ||
@@ -1414,8 +1451,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1414 | } | 1451 | } |
1415 | 1452 | ||
1416 | if (s_flags & MS_RDONLY) { | 1453 | if (s_flags & MS_RDONLY) { |
1417 | printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n", | 1454 | ext3_msg(sb, KERN_INFO, "orphan cleanup on readonly fs"); |
1418 | sb->s_id); | ||
1419 | sb->s_flags &= ~MS_RDONLY; | 1455 | sb->s_flags &= ~MS_RDONLY; |
1420 | } | 1456 | } |
1421 | #ifdef CONFIG_QUOTA | 1457 | #ifdef CONFIG_QUOTA |
@@ -1426,9 +1462,9 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1426 | if (EXT3_SB(sb)->s_qf_names[i]) { | 1462 | if (EXT3_SB(sb)->s_qf_names[i]) { |
1427 | int ret = ext3_quota_on_mount(sb, i); | 1463 | int ret = ext3_quota_on_mount(sb, i); |
1428 | if (ret < 0) | 1464 | if (ret < 0) |
1429 | printk(KERN_ERR | 1465 | ext3_msg(sb, KERN_ERR, |
1430 | "EXT3-fs: Cannot turn on journaled " | 1466 | "error: cannot turn on journaled " |
1431 | "quota: error %d\n", ret); | 1467 | "quota: %d", ret); |
1432 | } | 1468 | } |
1433 | } | 1469 | } |
1434 | #endif | 1470 | #endif |
@@ -1443,7 +1479,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1443 | } | 1479 | } |
1444 | 1480 | ||
1445 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); | 1481 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); |
1446 | vfs_dq_init(inode); | 1482 | dquot_initialize(inode); |
1447 | if (inode->i_nlink) { | 1483 | if (inode->i_nlink) { |
1448 | printk(KERN_DEBUG | 1484 | printk(KERN_DEBUG |
1449 | "%s: truncating inode %lu to %Ld bytes\n", | 1485 | "%s: truncating inode %lu to %Ld bytes\n", |
@@ -1466,11 +1502,11 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1466 | #define PLURAL(x) (x), ((x)==1) ? "" : "s" | 1502 | #define PLURAL(x) (x), ((x)==1) ? "" : "s" |
1467 | 1503 | ||
1468 | if (nr_orphans) | 1504 | if (nr_orphans) |
1469 | printk(KERN_INFO "EXT3-fs: %s: %d orphan inode%s deleted\n", | 1505 | ext3_msg(sb, KERN_INFO, "%d orphan inode%s deleted", |
1470 | sb->s_id, PLURAL(nr_orphans)); | 1506 | PLURAL(nr_orphans)); |
1471 | if (nr_truncates) | 1507 | if (nr_truncates) |
1472 | printk(KERN_INFO "EXT3-fs: %s: %d truncate%s cleaned up\n", | 1508 | ext3_msg(sb, KERN_INFO, "%d truncate%s cleaned up", |
1473 | sb->s_id, PLURAL(nr_truncates)); | 1509 | PLURAL(nr_truncates)); |
1474 | #ifdef CONFIG_QUOTA | 1510 | #ifdef CONFIG_QUOTA |
1475 | /* Turn quotas off */ | 1511 | /* Turn quotas off */ |
1476 | for (i = 0; i < MAXQUOTAS; i++) { | 1512 | for (i = 0; i < MAXQUOTAS; i++) { |
@@ -1554,7 +1590,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1554 | struct ext3_super_block *es = NULL; | 1590 | struct ext3_super_block *es = NULL; |
1555 | struct ext3_sb_info *sbi; | 1591 | struct ext3_sb_info *sbi; |
1556 | ext3_fsblk_t block; | 1592 | ext3_fsblk_t block; |
1557 | ext3_fsblk_t sb_block = get_sb_block(&data); | 1593 | ext3_fsblk_t sb_block = get_sb_block(&data, sb); |
1558 | ext3_fsblk_t logic_sb_block; | 1594 | ext3_fsblk_t logic_sb_block; |
1559 | unsigned long offset = 0; | 1595 | unsigned long offset = 0; |
1560 | unsigned int journal_inum = 0; | 1596 | unsigned int journal_inum = 0; |
@@ -1590,7 +1626,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1590 | 1626 | ||
1591 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); | 1627 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); |
1592 | if (!blocksize) { | 1628 | if (!blocksize) { |
1593 | printk(KERN_ERR "EXT3-fs: unable to set blocksize\n"); | 1629 | ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); |
1594 | goto out_fail; | 1630 | goto out_fail; |
1595 | } | 1631 | } |
1596 | 1632 | ||
@@ -1606,7 +1642,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1606 | } | 1642 | } |
1607 | 1643 | ||
1608 | if (!(bh = sb_bread(sb, logic_sb_block))) { | 1644 | if (!(bh = sb_bread(sb, logic_sb_block))) { |
1609 | printk (KERN_ERR "EXT3-fs: unable to read superblock\n"); | 1645 | ext3_msg(sb, KERN_ERR, "error: unable to read superblock"); |
1610 | goto out_fail; | 1646 | goto out_fail; |
1611 | } | 1647 | } |
1612 | /* | 1648 | /* |
@@ -1636,11 +1672,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1636 | set_opt(sbi->s_mount_opt, POSIX_ACL); | 1672 | set_opt(sbi->s_mount_opt, POSIX_ACL); |
1637 | #endif | 1673 | #endif |
1638 | if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) | 1674 | if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) |
1639 | sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA; | 1675 | set_opt(sbi->s_mount_opt, JOURNAL_DATA); |
1640 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) | 1676 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) |
1641 | sbi->s_mount_opt |= EXT3_MOUNT_ORDERED_DATA; | 1677 | set_opt(sbi->s_mount_opt, ORDERED_DATA); |
1642 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) | 1678 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) |
1643 | sbi->s_mount_opt |= EXT3_MOUNT_WRITEBACK_DATA; | 1679 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); |
1644 | 1680 | ||
1645 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) | 1681 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) |
1646 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); | 1682 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); |
@@ -1659,15 +1695,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1659 | goto failed_mount; | 1695 | goto failed_mount; |
1660 | 1696 | ||
1661 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 1697 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
1662 | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 1698 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
1663 | 1699 | ||
1664 | if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && | 1700 | if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && |
1665 | (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || | 1701 | (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || |
1666 | EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || | 1702 | EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || |
1667 | EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) | 1703 | EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) |
1668 | printk(KERN_WARNING | 1704 | ext3_msg(sb, KERN_WARNING, |
1669 | "EXT3-fs warning: feature flags set on rev 0 fs, " | 1705 | "warning: feature flags set on rev 0 fs, " |
1670 | "running e2fsck is recommended\n"); | 1706 | "running e2fsck is recommended"); |
1671 | /* | 1707 | /* |
1672 | * Check feature flags regardless of the revision level, since we | 1708 | * Check feature flags regardless of the revision level, since we |
1673 | * previously didn't change the revision level when setting the flags, | 1709 | * previously didn't change the revision level when setting the flags, |
@@ -1675,25 +1711,25 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1675 | */ | 1711 | */ |
1676 | features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); | 1712 | features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); |
1677 | if (features) { | 1713 | if (features) { |
1678 | printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " | 1714 | ext3_msg(sb, KERN_ERR, |
1679 | "unsupported optional features (%x).\n", | 1715 | "error: couldn't mount because of unsupported " |
1680 | sb->s_id, le32_to_cpu(features)); | 1716 | "optional features (%x)", le32_to_cpu(features)); |
1681 | goto failed_mount; | 1717 | goto failed_mount; |
1682 | } | 1718 | } |
1683 | features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); | 1719 | features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); |
1684 | if (!(sb->s_flags & MS_RDONLY) && features) { | 1720 | if (!(sb->s_flags & MS_RDONLY) && features) { |
1685 | printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " | 1721 | ext3_msg(sb, KERN_ERR, |
1686 | "unsupported optional features (%x).\n", | 1722 | "error: couldn't mount RDWR because of unsupported " |
1687 | sb->s_id, le32_to_cpu(features)); | 1723 | "optional features (%x)", le32_to_cpu(features)); |
1688 | goto failed_mount; | 1724 | goto failed_mount; |
1689 | } | 1725 | } |
1690 | blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); | 1726 | blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); |
1691 | 1727 | ||
1692 | if (blocksize < EXT3_MIN_BLOCK_SIZE || | 1728 | if (blocksize < EXT3_MIN_BLOCK_SIZE || |
1693 | blocksize > EXT3_MAX_BLOCK_SIZE) { | 1729 | blocksize > EXT3_MAX_BLOCK_SIZE) { |
1694 | printk(KERN_ERR | 1730 | ext3_msg(sb, KERN_ERR, |
1695 | "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", | 1731 | "error: couldn't mount because of unsupported " |
1696 | blocksize, sb->s_id); | 1732 | "filesystem blocksize %d", blocksize); |
1697 | goto failed_mount; | 1733 | goto failed_mount; |
1698 | } | 1734 | } |
1699 | 1735 | ||
@@ -1704,30 +1740,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1704 | * than the hardware sectorsize for the machine. | 1740 | * than the hardware sectorsize for the machine. |
1705 | */ | 1741 | */ |
1706 | if (blocksize < hblock) { | 1742 | if (blocksize < hblock) { |
1707 | printk(KERN_ERR "EXT3-fs: blocksize %d too small for " | 1743 | ext3_msg(sb, KERN_ERR, |
1708 | "device blocksize %d.\n", blocksize, hblock); | 1744 | "error: fsblocksize %d too small for " |
1745 | "hardware sectorsize %d", blocksize, hblock); | ||
1709 | goto failed_mount; | 1746 | goto failed_mount; |
1710 | } | 1747 | } |
1711 | 1748 | ||
1712 | brelse (bh); | 1749 | brelse (bh); |
1713 | if (!sb_set_blocksize(sb, blocksize)) { | 1750 | if (!sb_set_blocksize(sb, blocksize)) { |
1714 | printk(KERN_ERR "EXT3-fs: bad blocksize %d.\n", | 1751 | ext3_msg(sb, KERN_ERR, |
1715 | blocksize); | 1752 | "error: bad blocksize %d", blocksize); |
1716 | goto out_fail; | 1753 | goto out_fail; |
1717 | } | 1754 | } |
1718 | logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; | 1755 | logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; |
1719 | offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; | 1756 | offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; |
1720 | bh = sb_bread(sb, logic_sb_block); | 1757 | bh = sb_bread(sb, logic_sb_block); |
1721 | if (!bh) { | 1758 | if (!bh) { |
1722 | printk(KERN_ERR | 1759 | ext3_msg(sb, KERN_ERR, |
1723 | "EXT3-fs: Can't read superblock on 2nd try.\n"); | 1760 | "error: can't read superblock on 2nd try"); |
1724 | goto failed_mount; | 1761 | goto failed_mount; |
1725 | } | 1762 | } |
1726 | es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); | 1763 | es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); |
1727 | sbi->s_es = es; | 1764 | sbi->s_es = es; |
1728 | if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { | 1765 | if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { |
1729 | printk (KERN_ERR | 1766 | ext3_msg(sb, KERN_ERR, |
1730 | "EXT3-fs: Magic mismatch, very weird !\n"); | 1767 | "error: magic mismatch"); |
1731 | goto failed_mount; | 1768 | goto failed_mount; |
1732 | } | 1769 | } |
1733 | } | 1770 | } |
@@ -1743,8 +1780,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1743 | if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) || | 1780 | if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) || |
1744 | (!is_power_of_2(sbi->s_inode_size)) || | 1781 | (!is_power_of_2(sbi->s_inode_size)) || |
1745 | (sbi->s_inode_size > blocksize)) { | 1782 | (sbi->s_inode_size > blocksize)) { |
1746 | printk (KERN_ERR | 1783 | ext3_msg(sb, KERN_ERR, |
1747 | "EXT3-fs: unsupported inode size: %d\n", | 1784 | "error: unsupported inode size: %d", |
1748 | sbi->s_inode_size); | 1785 | sbi->s_inode_size); |
1749 | goto failed_mount; | 1786 | goto failed_mount; |
1750 | } | 1787 | } |
@@ -1752,8 +1789,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1752 | sbi->s_frag_size = EXT3_MIN_FRAG_SIZE << | 1789 | sbi->s_frag_size = EXT3_MIN_FRAG_SIZE << |
1753 | le32_to_cpu(es->s_log_frag_size); | 1790 | le32_to_cpu(es->s_log_frag_size); |
1754 | if (blocksize != sbi->s_frag_size) { | 1791 | if (blocksize != sbi->s_frag_size) { |
1755 | printk(KERN_ERR | 1792 | ext3_msg(sb, KERN_ERR, |
1756 | "EXT3-fs: fragsize %lu != blocksize %u (unsupported)\n", | 1793 | "error: fragsize %lu != blocksize %u (unsupported)", |
1757 | sbi->s_frag_size, blocksize); | 1794 | sbi->s_frag_size, blocksize); |
1758 | goto failed_mount; | 1795 | goto failed_mount; |
1759 | } | 1796 | } |
@@ -1789,31 +1826,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1789 | } | 1826 | } |
1790 | 1827 | ||
1791 | if (sbi->s_blocks_per_group > blocksize * 8) { | 1828 | if (sbi->s_blocks_per_group > blocksize * 8) { |
1792 | printk (KERN_ERR | 1829 | ext3_msg(sb, KERN_ERR, |
1793 | "EXT3-fs: #blocks per group too big: %lu\n", | 1830 | "#blocks per group too big: %lu", |
1794 | sbi->s_blocks_per_group); | 1831 | sbi->s_blocks_per_group); |
1795 | goto failed_mount; | 1832 | goto failed_mount; |
1796 | } | 1833 | } |
1797 | if (sbi->s_frags_per_group > blocksize * 8) { | 1834 | if (sbi->s_frags_per_group > blocksize * 8) { |
1798 | printk (KERN_ERR | 1835 | ext3_msg(sb, KERN_ERR, |
1799 | "EXT3-fs: #fragments per group too big: %lu\n", | 1836 | "error: #fragments per group too big: %lu", |
1800 | sbi->s_frags_per_group); | 1837 | sbi->s_frags_per_group); |
1801 | goto failed_mount; | 1838 | goto failed_mount; |
1802 | } | 1839 | } |
1803 | if (sbi->s_inodes_per_group > blocksize * 8) { | 1840 | if (sbi->s_inodes_per_group > blocksize * 8) { |
1804 | printk (KERN_ERR | 1841 | ext3_msg(sb, KERN_ERR, |
1805 | "EXT3-fs: #inodes per group too big: %lu\n", | 1842 | "error: #inodes per group too big: %lu", |
1806 | sbi->s_inodes_per_group); | 1843 | sbi->s_inodes_per_group); |
1807 | goto failed_mount; | 1844 | goto failed_mount; |
1808 | } | 1845 | } |
1809 | 1846 | ||
1810 | if (le32_to_cpu(es->s_blocks_count) > | 1847 | if (le32_to_cpu(es->s_blocks_count) > |
1811 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { | 1848 | (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { |
1812 | printk(KERN_ERR "EXT3-fs: filesystem on %s:" | 1849 | ext3_msg(sb, KERN_ERR, |
1813 | " too large to mount safely\n", sb->s_id); | 1850 | "error: filesystem is too large to mount safely"); |
1814 | if (sizeof(sector_t) < 8) | 1851 | if (sizeof(sector_t) < 8) |
1815 | printk(KERN_WARNING "EXT3-fs: CONFIG_LBDAF not " | 1852 | ext3_msg(sb, KERN_ERR, |
1816 | "enabled\n"); | 1853 | "error: CONFIG_LBDAF not enabled"); |
1817 | goto failed_mount; | 1854 | goto failed_mount; |
1818 | } | 1855 | } |
1819 | 1856 | ||
@@ -1827,7 +1864,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1827 | sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), | 1864 | sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), |
1828 | GFP_KERNEL); | 1865 | GFP_KERNEL); |
1829 | if (sbi->s_group_desc == NULL) { | 1866 | if (sbi->s_group_desc == NULL) { |
1830 | printk (KERN_ERR "EXT3-fs: not enough memory\n"); | 1867 | ext3_msg(sb, KERN_ERR, |
1868 | "error: not enough memory"); | ||
1831 | goto failed_mount; | 1869 | goto failed_mount; |
1832 | } | 1870 | } |
1833 | 1871 | ||
@@ -1837,14 +1875,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1837 | block = descriptor_loc(sb, logic_sb_block, i); | 1875 | block = descriptor_loc(sb, logic_sb_block, i); |
1838 | sbi->s_group_desc[i] = sb_bread(sb, block); | 1876 | sbi->s_group_desc[i] = sb_bread(sb, block); |
1839 | if (!sbi->s_group_desc[i]) { | 1877 | if (!sbi->s_group_desc[i]) { |
1840 | printk (KERN_ERR "EXT3-fs: " | 1878 | ext3_msg(sb, KERN_ERR, |
1841 | "can't read group descriptor %d\n", i); | 1879 | "error: can't read group descriptor %d", i); |
1842 | db_count = i; | 1880 | db_count = i; |
1843 | goto failed_mount2; | 1881 | goto failed_mount2; |
1844 | } | 1882 | } |
1845 | } | 1883 | } |
1846 | if (!ext3_check_descriptors (sb)) { | 1884 | if (!ext3_check_descriptors (sb)) { |
1847 | printk(KERN_ERR "EXT3-fs: group descriptors corrupted!\n"); | 1885 | ext3_msg(sb, KERN_ERR, |
1886 | "error: group descriptors corrupted"); | ||
1848 | goto failed_mount2; | 1887 | goto failed_mount2; |
1849 | } | 1888 | } |
1850 | sbi->s_gdb_count = db_count; | 1889 | sbi->s_gdb_count = db_count; |
@@ -1862,7 +1901,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1862 | ext3_count_dirs(sb)); | 1901 | ext3_count_dirs(sb)); |
1863 | } | 1902 | } |
1864 | if (err) { | 1903 | if (err) { |
1865 | printk(KERN_ERR "EXT3-fs: insufficient memory\n"); | 1904 | ext3_msg(sb, KERN_ERR, "error: insufficient memory"); |
1866 | goto failed_mount3; | 1905 | goto failed_mount3; |
1867 | } | 1906 | } |
1868 | 1907 | ||
@@ -1890,6 +1929,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1890 | sb->dq_op = &ext3_quota_operations; | 1929 | sb->dq_op = &ext3_quota_operations; |
1891 | #endif | 1930 | #endif |
1892 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ | 1931 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ |
1932 | mutex_init(&sbi->s_orphan_lock); | ||
1933 | mutex_init(&sbi->s_resize_lock); | ||
1893 | 1934 | ||
1894 | sb->s_root = NULL; | 1935 | sb->s_root = NULL; |
1895 | 1936 | ||
@@ -1910,9 +1951,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1910 | goto failed_mount3; | 1951 | goto failed_mount3; |
1911 | } else { | 1952 | } else { |
1912 | if (!silent) | 1953 | if (!silent) |
1913 | printk (KERN_ERR | 1954 | ext3_msg(sb, KERN_ERR, |
1914 | "ext3: No journal on filesystem on %s\n", | 1955 | "error: no journal found. " |
1915 | sb->s_id); | 1956 | "mounting ext3 over ext2?"); |
1916 | goto failed_mount3; | 1957 | goto failed_mount3; |
1917 | } | 1958 | } |
1918 | 1959 | ||
@@ -1934,8 +1975,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1934 | case EXT3_MOUNT_WRITEBACK_DATA: | 1975 | case EXT3_MOUNT_WRITEBACK_DATA: |
1935 | if (!journal_check_available_features | 1976 | if (!journal_check_available_features |
1936 | (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { | 1977 | (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { |
1937 | printk(KERN_ERR "EXT3-fs: Journal does not support " | 1978 | ext3_msg(sb, KERN_ERR, |
1938 | "requested data journaling mode\n"); | 1979 | "error: journal does not support " |
1980 | "requested data journaling mode"); | ||
1939 | goto failed_mount4; | 1981 | goto failed_mount4; |
1940 | } | 1982 | } |
1941 | default: | 1983 | default: |
@@ -1944,8 +1986,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1944 | 1986 | ||
1945 | if (test_opt(sb, NOBH)) { | 1987 | if (test_opt(sb, NOBH)) { |
1946 | if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) { | 1988 | if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) { |
1947 | printk(KERN_WARNING "EXT3-fs: Ignoring nobh option - " | 1989 | ext3_msg(sb, KERN_WARNING, |
1948 | "its supported only with writeback mode\n"); | 1990 | "warning: ignoring nobh option - " |
1991 | "it is supported only with writeback mode"); | ||
1949 | clear_opt(sbi->s_mount_opt, NOBH); | 1992 | clear_opt(sbi->s_mount_opt, NOBH); |
1950 | } | 1993 | } |
1951 | } | 1994 | } |
@@ -1956,39 +1999,32 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1956 | 1999 | ||
1957 | root = ext3_iget(sb, EXT3_ROOT_INO); | 2000 | root = ext3_iget(sb, EXT3_ROOT_INO); |
1958 | if (IS_ERR(root)) { | 2001 | if (IS_ERR(root)) { |
1959 | printk(KERN_ERR "EXT3-fs: get root inode failed\n"); | 2002 | ext3_msg(sb, KERN_ERR, "error: get root inode failed"); |
1960 | ret = PTR_ERR(root); | 2003 | ret = PTR_ERR(root); |
1961 | goto failed_mount4; | 2004 | goto failed_mount4; |
1962 | } | 2005 | } |
1963 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 2006 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
1964 | iput(root); | 2007 | iput(root); |
1965 | printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); | 2008 | ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); |
1966 | goto failed_mount4; | 2009 | goto failed_mount4; |
1967 | } | 2010 | } |
1968 | sb->s_root = d_alloc_root(root); | 2011 | sb->s_root = d_alloc_root(root); |
1969 | if (!sb->s_root) { | 2012 | if (!sb->s_root) { |
1970 | printk(KERN_ERR "EXT3-fs: get root dentry failed\n"); | 2013 | ext3_msg(sb, KERN_ERR, "error: get root dentry failed"); |
1971 | iput(root); | 2014 | iput(root); |
1972 | ret = -ENOMEM; | 2015 | ret = -ENOMEM; |
1973 | goto failed_mount4; | 2016 | goto failed_mount4; |
1974 | } | 2017 | } |
1975 | 2018 | ||
1976 | ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 2019 | ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
1977 | /* | 2020 | |
1978 | * akpm: core read_super() calls in here with the superblock locked. | ||
1979 | * That deadlocks, because orphan cleanup needs to lock the superblock | ||
1980 | * in numerous places. Here we just pop the lock - it's relatively | ||
1981 | * harmless, because we are now ready to accept write_super() requests, | ||
1982 | * and aviro says that's the only reason for hanging onto the | ||
1983 | * superblock lock. | ||
1984 | */ | ||
1985 | EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; | 2021 | EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; |
1986 | ext3_orphan_cleanup(sb, es); | 2022 | ext3_orphan_cleanup(sb, es); |
1987 | EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; | 2023 | EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; |
1988 | if (needs_recovery) | 2024 | if (needs_recovery) |
1989 | printk (KERN_INFO "EXT3-fs: recovery complete.\n"); | 2025 | ext3_msg(sb, KERN_INFO, "recovery complete"); |
1990 | ext3_mark_recovery_complete(sb, es); | 2026 | ext3_mark_recovery_complete(sb, es); |
1991 | printk (KERN_INFO "EXT3-fs: mounted filesystem with %s data mode.\n", | 2027 | ext3_msg(sb, KERN_INFO, "mounted filesystem with %s data mode", |
1992 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": | 2028 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": |
1993 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": | 2029 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": |
1994 | "writeback"); | 2030 | "writeback"); |
@@ -1998,7 +2034,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1998 | 2034 | ||
1999 | cantfind_ext3: | 2035 | cantfind_ext3: |
2000 | if (!silent) | 2036 | if (!silent) |
2001 | printk(KERN_ERR "VFS: Can't find ext3 filesystem on dev %s.\n", | 2037 | ext3_msg(sb, KERN_INFO, |
2038 | "error: can't find ext3 filesystem on dev %s.", | ||
2002 | sb->s_id); | 2039 | sb->s_id); |
2003 | goto failed_mount; | 2040 | goto failed_mount; |
2004 | 2041 | ||
@@ -2066,27 +2103,27 @@ static journal_t *ext3_get_journal(struct super_block *sb, | |||
2066 | 2103 | ||
2067 | journal_inode = ext3_iget(sb, journal_inum); | 2104 | journal_inode = ext3_iget(sb, journal_inum); |
2068 | if (IS_ERR(journal_inode)) { | 2105 | if (IS_ERR(journal_inode)) { |
2069 | printk(KERN_ERR "EXT3-fs: no journal found.\n"); | 2106 | ext3_msg(sb, KERN_ERR, "error: no journal found"); |
2070 | return NULL; | 2107 | return NULL; |
2071 | } | 2108 | } |
2072 | if (!journal_inode->i_nlink) { | 2109 | if (!journal_inode->i_nlink) { |
2073 | make_bad_inode(journal_inode); | 2110 | make_bad_inode(journal_inode); |
2074 | iput(journal_inode); | 2111 | iput(journal_inode); |
2075 | printk(KERN_ERR "EXT3-fs: journal inode is deleted.\n"); | 2112 | ext3_msg(sb, KERN_ERR, "error: journal inode is deleted"); |
2076 | return NULL; | 2113 | return NULL; |
2077 | } | 2114 | } |
2078 | 2115 | ||
2079 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", | 2116 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", |
2080 | journal_inode, journal_inode->i_size); | 2117 | journal_inode, journal_inode->i_size); |
2081 | if (!S_ISREG(journal_inode->i_mode)) { | 2118 | if (!S_ISREG(journal_inode->i_mode)) { |
2082 | printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); | 2119 | ext3_msg(sb, KERN_ERR, "error: invalid journal inode"); |
2083 | iput(journal_inode); | 2120 | iput(journal_inode); |
2084 | return NULL; | 2121 | return NULL; |
2085 | } | 2122 | } |
2086 | 2123 | ||
2087 | journal = journal_init_inode(journal_inode); | 2124 | journal = journal_init_inode(journal_inode); |
2088 | if (!journal) { | 2125 | if (!journal) { |
2089 | printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); | 2126 | ext3_msg(sb, KERN_ERR, "error: could not load journal inode"); |
2090 | iput(journal_inode); | 2127 | iput(journal_inode); |
2091 | return NULL; | 2128 | return NULL; |
2092 | } | 2129 | } |
@@ -2108,13 +2145,13 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2108 | struct ext3_super_block * es; | 2145 | struct ext3_super_block * es; |
2109 | struct block_device *bdev; | 2146 | struct block_device *bdev; |
2110 | 2147 | ||
2111 | bdev = ext3_blkdev_get(j_dev); | 2148 | bdev = ext3_blkdev_get(j_dev, sb); |
2112 | if (bdev == NULL) | 2149 | if (bdev == NULL) |
2113 | return NULL; | 2150 | return NULL; |
2114 | 2151 | ||
2115 | if (bd_claim(bdev, sb)) { | 2152 | if (bd_claim(bdev, sb)) { |
2116 | printk(KERN_ERR | 2153 | ext3_msg(sb, KERN_ERR, |
2117 | "EXT3: failed to claim external journal device.\n"); | 2154 | "error: failed to claim external journal device"); |
2118 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); | 2155 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); |
2119 | return NULL; | 2156 | return NULL; |
2120 | } | 2157 | } |
@@ -2122,8 +2159,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2122 | blocksize = sb->s_blocksize; | 2159 | blocksize = sb->s_blocksize; |
2123 | hblock = bdev_logical_block_size(bdev); | 2160 | hblock = bdev_logical_block_size(bdev); |
2124 | if (blocksize < hblock) { | 2161 | if (blocksize < hblock) { |
2125 | printk(KERN_ERR | 2162 | ext3_msg(sb, KERN_ERR, |
2126 | "EXT3-fs: blocksize too small for journal device.\n"); | 2163 | "error: blocksize too small for journal device"); |
2127 | goto out_bdev; | 2164 | goto out_bdev; |
2128 | } | 2165 | } |
2129 | 2166 | ||
@@ -2131,8 +2168,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2131 | offset = EXT3_MIN_BLOCK_SIZE % blocksize; | 2168 | offset = EXT3_MIN_BLOCK_SIZE % blocksize; |
2132 | set_blocksize(bdev, blocksize); | 2169 | set_blocksize(bdev, blocksize); |
2133 | if (!(bh = __bread(bdev, sb_block, blocksize))) { | 2170 | if (!(bh = __bread(bdev, sb_block, blocksize))) { |
2134 | printk(KERN_ERR "EXT3-fs: couldn't read superblock of " | 2171 | ext3_msg(sb, KERN_ERR, "error: couldn't read superblock of " |
2135 | "external journal\n"); | 2172 | "external journal"); |
2136 | goto out_bdev; | 2173 | goto out_bdev; |
2137 | } | 2174 | } |
2138 | 2175 | ||
@@ -2140,14 +2177,14 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2140 | if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || | 2177 | if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || |
2141 | !(le32_to_cpu(es->s_feature_incompat) & | 2178 | !(le32_to_cpu(es->s_feature_incompat) & |
2142 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { | 2179 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { |
2143 | printk(KERN_ERR "EXT3-fs: external journal has " | 2180 | ext3_msg(sb, KERN_ERR, "error: external journal has " |
2144 | "bad superblock\n"); | 2181 | "bad superblock"); |
2145 | brelse(bh); | 2182 | brelse(bh); |
2146 | goto out_bdev; | 2183 | goto out_bdev; |
2147 | } | 2184 | } |
2148 | 2185 | ||
2149 | if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { | 2186 | if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { |
2150 | printk(KERN_ERR "EXT3-fs: journal UUID does not match\n"); | 2187 | ext3_msg(sb, KERN_ERR, "error: journal UUID does not match"); |
2151 | brelse(bh); | 2188 | brelse(bh); |
2152 | goto out_bdev; | 2189 | goto out_bdev; |
2153 | } | 2190 | } |
@@ -2159,19 +2196,21 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2159 | journal = journal_init_dev(bdev, sb->s_bdev, | 2196 | journal = journal_init_dev(bdev, sb->s_bdev, |
2160 | start, len, blocksize); | 2197 | start, len, blocksize); |
2161 | if (!journal) { | 2198 | if (!journal) { |
2162 | printk(KERN_ERR "EXT3-fs: failed to create device journal\n"); | 2199 | ext3_msg(sb, KERN_ERR, |
2200 | "error: failed to create device journal"); | ||
2163 | goto out_bdev; | 2201 | goto out_bdev; |
2164 | } | 2202 | } |
2165 | journal->j_private = sb; | 2203 | journal->j_private = sb; |
2166 | ll_rw_block(READ, 1, &journal->j_sb_buffer); | 2204 | ll_rw_block(READ, 1, &journal->j_sb_buffer); |
2167 | wait_on_buffer(journal->j_sb_buffer); | 2205 | wait_on_buffer(journal->j_sb_buffer); |
2168 | if (!buffer_uptodate(journal->j_sb_buffer)) { | 2206 | if (!buffer_uptodate(journal->j_sb_buffer)) { |
2169 | printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); | 2207 | ext3_msg(sb, KERN_ERR, "I/O error on journal device"); |
2170 | goto out_journal; | 2208 | goto out_journal; |
2171 | } | 2209 | } |
2172 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { | 2210 | if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { |
2173 | printk(KERN_ERR "EXT3-fs: External journal has more than one " | 2211 | ext3_msg(sb, KERN_ERR, |
2174 | "user (unsupported) - %d\n", | 2212 | "error: external journal has more than one " |
2213 | "user (unsupported) - %d", | ||
2175 | be32_to_cpu(journal->j_superblock->s_nr_users)); | 2214 | be32_to_cpu(journal->j_superblock->s_nr_users)); |
2176 | goto out_journal; | 2215 | goto out_journal; |
2177 | } | 2216 | } |
@@ -2197,8 +2236,8 @@ static int ext3_load_journal(struct super_block *sb, | |||
2197 | 2236 | ||
2198 | if (journal_devnum && | 2237 | if (journal_devnum && |
2199 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { | 2238 | journal_devnum != le32_to_cpu(es->s_journal_dev)) { |
2200 | printk(KERN_INFO "EXT3-fs: external journal device major/minor " | 2239 | ext3_msg(sb, KERN_INFO, "external journal device major/minor " |
2201 | "numbers have changed\n"); | 2240 | "numbers have changed"); |
2202 | journal_dev = new_decode_dev(journal_devnum); | 2241 | journal_dev = new_decode_dev(journal_devnum); |
2203 | } else | 2242 | } else |
2204 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); | 2243 | journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); |
@@ -2213,21 +2252,21 @@ static int ext3_load_journal(struct super_block *sb, | |||
2213 | 2252 | ||
2214 | if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { | 2253 | if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { |
2215 | if (sb->s_flags & MS_RDONLY) { | 2254 | if (sb->s_flags & MS_RDONLY) { |
2216 | printk(KERN_INFO "EXT3-fs: INFO: recovery " | 2255 | ext3_msg(sb, KERN_INFO, |
2217 | "required on readonly filesystem.\n"); | 2256 | "recovery required on readonly filesystem"); |
2218 | if (really_read_only) { | 2257 | if (really_read_only) { |
2219 | printk(KERN_ERR "EXT3-fs: write access " | 2258 | ext3_msg(sb, KERN_ERR, "error: write access " |
2220 | "unavailable, cannot proceed.\n"); | 2259 | "unavailable, cannot proceed"); |
2221 | return -EROFS; | 2260 | return -EROFS; |
2222 | } | 2261 | } |
2223 | printk (KERN_INFO "EXT3-fs: write access will " | 2262 | ext3_msg(sb, KERN_INFO, |
2224 | "be enabled during recovery.\n"); | 2263 | "write access will be enabled during recovery"); |
2225 | } | 2264 | } |
2226 | } | 2265 | } |
2227 | 2266 | ||
2228 | if (journal_inum && journal_dev) { | 2267 | if (journal_inum && journal_dev) { |
2229 | printk(KERN_ERR "EXT3-fs: filesystem has both journal " | 2268 | ext3_msg(sb, KERN_ERR, "error: filesystem has both journal " |
2230 | "and inode journals!\n"); | 2269 | "and inode journals"); |
2231 | return -EINVAL; | 2270 | return -EINVAL; |
2232 | } | 2271 | } |
2233 | 2272 | ||
@@ -2242,7 +2281,7 @@ static int ext3_load_journal(struct super_block *sb, | |||
2242 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { | 2281 | if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { |
2243 | err = journal_update_format(journal); | 2282 | err = journal_update_format(journal); |
2244 | if (err) { | 2283 | if (err) { |
2245 | printk(KERN_ERR "EXT3-fs: error updating journal.\n"); | 2284 | ext3_msg(sb, KERN_ERR, "error updating journal"); |
2246 | journal_destroy(journal); | 2285 | journal_destroy(journal); |
2247 | return err; | 2286 | return err; |
2248 | } | 2287 | } |
@@ -2254,7 +2293,7 @@ static int ext3_load_journal(struct super_block *sb, | |||
2254 | err = journal_load(journal); | 2293 | err = journal_load(journal); |
2255 | 2294 | ||
2256 | if (err) { | 2295 | if (err) { |
2257 | printk(KERN_ERR "EXT3-fs: error loading journal.\n"); | 2296 | ext3_msg(sb, KERN_ERR, "error loading journal"); |
2258 | journal_destroy(journal); | 2297 | journal_destroy(journal); |
2259 | return err; | 2298 | return err; |
2260 | } | 2299 | } |
@@ -2273,16 +2312,17 @@ static int ext3_load_journal(struct super_block *sb, | |||
2273 | return 0; | 2312 | return 0; |
2274 | } | 2313 | } |
2275 | 2314 | ||
2276 | static int ext3_create_journal(struct super_block * sb, | 2315 | static int ext3_create_journal(struct super_block *sb, |
2277 | struct ext3_super_block * es, | 2316 | struct ext3_super_block *es, |
2278 | unsigned int journal_inum) | 2317 | unsigned int journal_inum) |
2279 | { | 2318 | { |
2280 | journal_t *journal; | 2319 | journal_t *journal; |
2281 | int err; | 2320 | int err; |
2282 | 2321 | ||
2283 | if (sb->s_flags & MS_RDONLY) { | 2322 | if (sb->s_flags & MS_RDONLY) { |
2284 | printk(KERN_ERR "EXT3-fs: readonly filesystem when trying to " | 2323 | ext3_msg(sb, KERN_ERR, |
2285 | "create journal.\n"); | 2324 | "error: readonly filesystem when trying to " |
2325 | "create journal"); | ||
2286 | return -EROFS; | 2326 | return -EROFS; |
2287 | } | 2327 | } |
2288 | 2328 | ||
@@ -2290,12 +2330,12 @@ static int ext3_create_journal(struct super_block * sb, | |||
2290 | if (!journal) | 2330 | if (!journal) |
2291 | return -EINVAL; | 2331 | return -EINVAL; |
2292 | 2332 | ||
2293 | printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n", | 2333 | ext3_msg(sb, KERN_INFO, "creating new journal on inode %u", |
2294 | journal_inum); | 2334 | journal_inum); |
2295 | 2335 | ||
2296 | err = journal_create(journal); | 2336 | err = journal_create(journal); |
2297 | if (err) { | 2337 | if (err) { |
2298 | printk(KERN_ERR "EXT3-fs: error creating journal.\n"); | 2338 | ext3_msg(sb, KERN_ERR, "error creating journal"); |
2299 | journal_destroy(journal); | 2339 | journal_destroy(journal); |
2300 | return -EIO; | 2340 | return -EIO; |
2301 | } | 2341 | } |
@@ -2359,13 +2399,11 @@ static void ext3_mark_recovery_complete(struct super_block * sb, | |||
2359 | if (journal_flush(journal) < 0) | 2399 | if (journal_flush(journal) < 0) |
2360 | goto out; | 2400 | goto out; |
2361 | 2401 | ||
2362 | lock_super(sb); | ||
2363 | if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && | 2402 | if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) && |
2364 | sb->s_flags & MS_RDONLY) { | 2403 | sb->s_flags & MS_RDONLY) { |
2365 | EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); | 2404 | EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); |
2366 | ext3_commit_super(sb, es, 1); | 2405 | ext3_commit_super(sb, es, 1); |
2367 | } | 2406 | } |
2368 | unlock_super(sb); | ||
2369 | 2407 | ||
2370 | out: | 2408 | out: |
2371 | journal_unlock_updates(journal); | 2409 | journal_unlock_updates(journal); |
@@ -2376,8 +2414,8 @@ out: | |||
2376 | * has recorded an error from a previous lifetime, move that error to the | 2414 | * has recorded an error from a previous lifetime, move that error to the |
2377 | * main filesystem now. | 2415 | * main filesystem now. |
2378 | */ | 2416 | */ |
2379 | static void ext3_clear_journal_err(struct super_block * sb, | 2417 | static void ext3_clear_journal_err(struct super_block *sb, |
2380 | struct ext3_super_block * es) | 2418 | struct ext3_super_block *es) |
2381 | { | 2419 | { |
2382 | journal_t *journal; | 2420 | journal_t *journal; |
2383 | int j_errno; | 2421 | int j_errno; |
@@ -2524,11 +2562,11 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2524 | goto restore_opts; | 2562 | goto restore_opts; |
2525 | } | 2563 | } |
2526 | 2564 | ||
2527 | if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) | 2565 | if (test_opt(sb, ABORT)) |
2528 | ext3_abort(sb, __func__, "Abort forced by user"); | 2566 | ext3_abort(sb, __func__, "Abort forced by user"); |
2529 | 2567 | ||
2530 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 2568 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
2531 | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 2569 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
2532 | 2570 | ||
2533 | es = sbi->s_es; | 2571 | es = sbi->s_es; |
2534 | 2572 | ||
@@ -2536,7 +2574,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2536 | 2574 | ||
2537 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || | 2575 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || |
2538 | n_blocks_count > le32_to_cpu(es->s_blocks_count)) { | 2576 | n_blocks_count > le32_to_cpu(es->s_blocks_count)) { |
2539 | if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) { | 2577 | if (test_opt(sb, ABORT)) { |
2540 | err = -EROFS; | 2578 | err = -EROFS; |
2541 | goto restore_opts; | 2579 | goto restore_opts; |
2542 | } | 2580 | } |
@@ -2557,21 +2595,15 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2557 | (sbi->s_mount_state & EXT3_VALID_FS)) | 2595 | (sbi->s_mount_state & EXT3_VALID_FS)) |
2558 | es->s_state = cpu_to_le16(sbi->s_mount_state); | 2596 | es->s_state = cpu_to_le16(sbi->s_mount_state); |
2559 | 2597 | ||
2560 | /* | ||
2561 | * We have to unlock super so that we can wait for | ||
2562 | * transactions. | ||
2563 | */ | ||
2564 | unlock_super(sb); | ||
2565 | ext3_mark_recovery_complete(sb, es); | 2598 | ext3_mark_recovery_complete(sb, es); |
2566 | lock_super(sb); | ||
2567 | } else { | 2599 | } else { |
2568 | __le32 ret; | 2600 | __le32 ret; |
2569 | if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, | 2601 | if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, |
2570 | ~EXT3_FEATURE_RO_COMPAT_SUPP))) { | 2602 | ~EXT3_FEATURE_RO_COMPAT_SUPP))) { |
2571 | printk(KERN_WARNING "EXT3-fs: %s: couldn't " | 2603 | ext3_msg(sb, KERN_WARNING, |
2572 | "remount RDWR because of unsupported " | 2604 | "warning: couldn't remount RDWR " |
2573 | "optional features (%x).\n", | 2605 | "because of unsupported optional " |
2574 | sb->s_id, le32_to_cpu(ret)); | 2606 | "features (%x)", le32_to_cpu(ret)); |
2575 | err = -EROFS; | 2607 | err = -EROFS; |
2576 | goto restore_opts; | 2608 | goto restore_opts; |
2577 | } | 2609 | } |
@@ -2582,11 +2614,10 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2582 | * require a full umount/remount for now. | 2614 | * require a full umount/remount for now. |
2583 | */ | 2615 | */ |
2584 | if (es->s_last_orphan) { | 2616 | if (es->s_last_orphan) { |
2585 | printk(KERN_WARNING "EXT3-fs: %s: couldn't " | 2617 | ext3_msg(sb, KERN_WARNING, "warning: couldn't " |
2586 | "remount RDWR because of unprocessed " | 2618 | "remount RDWR because of unprocessed " |
2587 | "orphan inode list. Please " | 2619 | "orphan inode list. Please " |
2588 | "umount/remount instead.\n", | 2620 | "umount/remount instead."); |
2589 | sb->s_id); | ||
2590 | err = -EINVAL; | 2621 | err = -EINVAL; |
2591 | goto restore_opts; | 2622 | goto restore_opts; |
2592 | } | 2623 | } |
@@ -2686,13 +2717,11 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf) | |||
2686 | buf->f_bsize = sb->s_blocksize; | 2717 | buf->f_bsize = sb->s_blocksize; |
2687 | buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last; | 2718 | buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last; |
2688 | buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter); | 2719 | buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter); |
2689 | es->s_free_blocks_count = cpu_to_le32(buf->f_bfree); | ||
2690 | buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count); | 2720 | buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count); |
2691 | if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count)) | 2721 | if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count)) |
2692 | buf->f_bavail = 0; | 2722 | buf->f_bavail = 0; |
2693 | buf->f_files = le32_to_cpu(es->s_inodes_count); | 2723 | buf->f_files = le32_to_cpu(es->s_inodes_count); |
2694 | buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter); | 2724 | buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter); |
2695 | es->s_free_inodes_count = cpu_to_le32(buf->f_ffree); | ||
2696 | buf->f_namelen = EXT3_NAME_LEN; | 2725 | buf->f_namelen = EXT3_NAME_LEN; |
2697 | fsid = le64_to_cpup((void *)es->s_uuid) ^ | 2726 | fsid = le64_to_cpup((void *)es->s_uuid) ^ |
2698 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); | 2727 | le64_to_cpup((void *)es->s_uuid + sizeof(u64)); |
@@ -2706,7 +2735,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf) | |||
2706 | * Process 1 Process 2 | 2735 | * Process 1 Process 2 |
2707 | * ext3_create() quota_sync() | 2736 | * ext3_create() quota_sync() |
2708 | * journal_start() write_dquot() | 2737 | * journal_start() write_dquot() |
2709 | * vfs_dq_init() down(dqio_mutex) | 2738 | * dquot_initialize() down(dqio_mutex) |
2710 | * down(dqio_mutex) journal_start() | 2739 | * down(dqio_mutex) journal_start() |
2711 | * | 2740 | * |
2712 | */ | 2741 | */ |
@@ -2837,9 +2866,9 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id, | |||
2837 | if (EXT3_SB(sb)->s_qf_names[type]) { | 2866 | if (EXT3_SB(sb)->s_qf_names[type]) { |
2838 | /* Quotafile not of fs root? */ | 2867 | /* Quotafile not of fs root? */ |
2839 | if (path.dentry->d_parent != sb->s_root) | 2868 | if (path.dentry->d_parent != sb->s_root) |
2840 | printk(KERN_WARNING | 2869 | ext3_msg(sb, KERN_WARNING, |
2841 | "EXT3-fs: Quota file not on filesystem root. " | 2870 | "warning: Quota file not on filesystem root. " |
2842 | "Journaled quota will not work.\n"); | 2871 | "Journaled quota will not work."); |
2843 | } | 2872 | } |
2844 | 2873 | ||
2845 | /* | 2874 | /* |
@@ -2914,65 +2943,65 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
2914 | sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); | 2943 | sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); |
2915 | int err = 0; | 2944 | int err = 0; |
2916 | int offset = off & (sb->s_blocksize - 1); | 2945 | int offset = off & (sb->s_blocksize - 1); |
2917 | int tocopy; | ||
2918 | int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; | 2946 | int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; |
2919 | size_t towrite = len; | ||
2920 | struct buffer_head *bh; | 2947 | struct buffer_head *bh; |
2921 | handle_t *handle = journal_current_handle(); | 2948 | handle_t *handle = journal_current_handle(); |
2922 | 2949 | ||
2923 | if (!handle) { | 2950 | if (!handle) { |
2924 | printk(KERN_WARNING "EXT3-fs: Quota write (off=%Lu, len=%Lu)" | 2951 | ext3_msg(sb, KERN_WARNING, |
2925 | " cancelled because transaction is not started.\n", | 2952 | "warning: quota write (off=%llu, len=%llu)" |
2953 | " cancelled because transaction is not started.", | ||
2954 | (unsigned long long)off, (unsigned long long)len); | ||
2955 | return -EIO; | ||
2956 | } | ||
2957 | |||
2958 | /* | ||
2959 | * Since we account only one data block in transaction credits, | ||
2960 | * then it is impossible to cross a block boundary. | ||
2961 | */ | ||
2962 | if (sb->s_blocksize - offset < len) { | ||
2963 | ext3_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" | ||
2964 | " cancelled because not block aligned", | ||
2926 | (unsigned long long)off, (unsigned long long)len); | 2965 | (unsigned long long)off, (unsigned long long)len); |
2927 | return -EIO; | 2966 | return -EIO; |
2928 | } | 2967 | } |
2929 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); | 2968 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); |
2930 | while (towrite > 0) { | 2969 | bh = ext3_bread(handle, inode, blk, 1, &err); |
2931 | tocopy = sb->s_blocksize - offset < towrite ? | 2970 | if (!bh) |
2932 | sb->s_blocksize - offset : towrite; | 2971 | goto out; |
2933 | bh = ext3_bread(handle, inode, blk, 1, &err); | 2972 | if (journal_quota) { |
2934 | if (!bh) | 2973 | err = ext3_journal_get_write_access(handle, bh); |
2974 | if (err) { | ||
2975 | brelse(bh); | ||
2935 | goto out; | 2976 | goto out; |
2936 | if (journal_quota) { | ||
2937 | err = ext3_journal_get_write_access(handle, bh); | ||
2938 | if (err) { | ||
2939 | brelse(bh); | ||
2940 | goto out; | ||
2941 | } | ||
2942 | } | ||
2943 | lock_buffer(bh); | ||
2944 | memcpy(bh->b_data+offset, data, tocopy); | ||
2945 | flush_dcache_page(bh->b_page); | ||
2946 | unlock_buffer(bh); | ||
2947 | if (journal_quota) | ||
2948 | err = ext3_journal_dirty_metadata(handle, bh); | ||
2949 | else { | ||
2950 | /* Always do at least ordered writes for quotas */ | ||
2951 | err = ext3_journal_dirty_data(handle, bh); | ||
2952 | mark_buffer_dirty(bh); | ||
2953 | } | 2977 | } |
2954 | brelse(bh); | ||
2955 | if (err) | ||
2956 | goto out; | ||
2957 | offset = 0; | ||
2958 | towrite -= tocopy; | ||
2959 | data += tocopy; | ||
2960 | blk++; | ||
2961 | } | 2978 | } |
2979 | lock_buffer(bh); | ||
2980 | memcpy(bh->b_data+offset, data, len); | ||
2981 | flush_dcache_page(bh->b_page); | ||
2982 | unlock_buffer(bh); | ||
2983 | if (journal_quota) | ||
2984 | err = ext3_journal_dirty_metadata(handle, bh); | ||
2985 | else { | ||
2986 | /* Always do at least ordered writes for quotas */ | ||
2987 | err = ext3_journal_dirty_data(handle, bh); | ||
2988 | mark_buffer_dirty(bh); | ||
2989 | } | ||
2990 | brelse(bh); | ||
2962 | out: | 2991 | out: |
2963 | if (len == towrite) { | 2992 | if (err) { |
2964 | mutex_unlock(&inode->i_mutex); | 2993 | mutex_unlock(&inode->i_mutex); |
2965 | return err; | 2994 | return err; |
2966 | } | 2995 | } |
2967 | if (inode->i_size < off+len-towrite) { | 2996 | if (inode->i_size < off + len) { |
2968 | i_size_write(inode, off+len-towrite); | 2997 | i_size_write(inode, off + len); |
2969 | EXT3_I(inode)->i_disksize = inode->i_size; | 2998 | EXT3_I(inode)->i_disksize = inode->i_size; |
2970 | } | 2999 | } |
2971 | inode->i_version++; | 3000 | inode->i_version++; |
2972 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 3001 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
2973 | ext3_mark_inode_dirty(handle, inode); | 3002 | ext3_mark_inode_dirty(handle, inode); |
2974 | mutex_unlock(&inode->i_mutex); | 3003 | mutex_unlock(&inode->i_mutex); |
2975 | return len - towrite; | 3004 | return len; |
2976 | } | 3005 | } |
2977 | 3006 | ||
2978 | #endif | 3007 | #endif |