aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/write.c8
-rw-r--r--fs/btrfs/file.c4
-rw-r--r--fs/cifs/dir.c3
-rw-r--r--fs/cifs/file.c6
-rw-r--r--fs/ext2/dir.c4
-rw-r--r--fs/ext2/ext2.h2
-rw-r--r--fs/ext2/inode.c6
-rw-r--r--fs/ext2/super.c184
-rw-r--r--fs/ext2/xip.c5
-rw-r--r--fs/ext3/inode.c18
-rw-r--r--fs/ext3/resize.c2
-rw-r--r--fs/ext3/super.c468
-rw-r--r--fs/ext3/xattr.c7
-rw-r--r--fs/ext4/super.c30
-rw-r--r--fs/isofs/compress.c533
-rw-r--r--fs/isofs/rock.c3
-rw-r--r--fs/jbd2/commit.c2
-rw-r--r--fs/namei.c9
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/ocfs2/quota.h4
-rw-r--r--fs/ocfs2/quota_local.c2
-rw-r--r--fs/quota/Kconfig8
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--fs/quota/quota_v1.c2
-rw-r--r--fs/quota/quota_v2.c167
-rw-r--r--fs/quota/quotaio_v2.h19
-rw-r--r--fs/sync.c13
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c2
30 files changed, 889 insertions, 632 deletions
diff --git a/fs/afs/write.c b/fs/afs/write.c
index c63a3c8beb73..5e15a21dbf9f 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -671,7 +671,6 @@ ssize_t afs_file_write(struct kiocb *iocb, const struct iovec *iov,
671 struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode); 671 struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode);
672 ssize_t result; 672 ssize_t result;
673 size_t count = iov_length(iov, nr_segs); 673 size_t count = iov_length(iov, nr_segs);
674 int ret;
675 674
676 _enter("{%x.%u},{%zu},%lu,", 675 _enter("{%x.%u},{%zu},%lu,",
677 vnode->fid.vid, vnode->fid.vnode, count, nr_segs); 676 vnode->fid.vid, vnode->fid.vnode, count, nr_segs);
@@ -691,13 +690,6 @@ ssize_t afs_file_write(struct kiocb *iocb, const struct iovec *iov,
691 return result; 690 return result;
692 } 691 }
693 692
694 /* return error values for O_SYNC and IS_SYNC() */
695 if (IS_SYNC(&vnode->vfs_inode) || iocb->ki_filp->f_flags & O_SYNC) {
696 ret = afs_fsync(iocb->ki_filp, dentry, 1);
697 if (ret < 0)
698 result = ret;
699 }
700
701 _leave(" = %zd", result); 693 _leave(" = %zd", result);
702 return result; 694 return result;
703} 695}
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 06550affbd27..77f759302e12 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -909,7 +909,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
909 unsigned long last_index; 909 unsigned long last_index;
910 int will_write; 910 int will_write;
911 911
912 will_write = ((file->f_flags & O_SYNC) || IS_SYNC(inode) || 912 will_write = ((file->f_flags & O_DSYNC) || IS_SYNC(inode) ||
913 (file->f_flags & O_DIRECT)); 913 (file->f_flags & O_DIRECT));
914 914
915 nrptrs = min((count + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE, 915 nrptrs = min((count + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE,
@@ -1076,7 +1076,7 @@ out_nolock:
1076 if (err) 1076 if (err)
1077 num_written = err; 1077 num_written = err;
1078 1078
1079 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { 1079 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
1080 trans = btrfs_start_transaction(root, 1); 1080 trans = btrfs_start_transaction(root, 1);
1081 ret = btrfs_log_dentry_safe(trans, root, 1081 ret = btrfs_log_dentry_safe(trans, root,
1082 file->f_dentry); 1082 file->f_dentry);
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 1f42f772865a..6ccf7262d1b7 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -214,7 +214,8 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
214 posix_flags |= SMB_O_EXCL; 214 posix_flags |= SMB_O_EXCL;
215 if (oflags & O_TRUNC) 215 if (oflags & O_TRUNC)
216 posix_flags |= SMB_O_TRUNC; 216 posix_flags |= SMB_O_TRUNC;
217 if (oflags & O_SYNC) 217 /* be safe and imply O_SYNC for O_DSYNC */
218 if (oflags & O_DSYNC)
218 posix_flags |= SMB_O_SYNC; 219 posix_flags |= SMB_O_SYNC;
219 if (oflags & O_DIRECTORY) 220 if (oflags & O_DIRECTORY)
220 posix_flags |= SMB_O_DIRECTORY; 221 posix_flags |= SMB_O_DIRECTORY;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 429337eb7afe..057e1dae12ab 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -76,8 +76,10 @@ static inline fmode_t cifs_posix_convert_flags(unsigned int flags)
76 reopening a file. They had their effect on the original open */ 76 reopening a file. They had their effect on the original open */
77 if (flags & O_APPEND) 77 if (flags & O_APPEND)
78 posix_flags |= (fmode_t)O_APPEND; 78 posix_flags |= (fmode_t)O_APPEND;
79 if (flags & O_SYNC) 79 if (flags & O_DSYNC)
80 posix_flags |= (fmode_t)O_SYNC; 80 posix_flags |= (fmode_t)O_DSYNC;
81 if (flags & __O_SYNC)
82 posix_flags |= (fmode_t)__O_SYNC;
81 if (flags & O_DIRECTORY) 83 if (flags & O_DIRECTORY)
82 posix_flags |= (fmode_t)O_DIRECTORY; 84 posix_flags |= (fmode_t)O_DIRECTORY;
83 if (flags & O_NOFOLLOW) 85 if (flags & O_NOFOLLOW)
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 6cde970b0a1a..fc2bd05d3559 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -353,8 +353,8 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)
353 * ext2_find_entry() 353 * ext2_find_entry()
354 * 354 *
355 * finds an entry in the specified directory with the wanted name. It 355 * finds an entry in the specified directory with the wanted name. It
356 * returns the page in which the entry was found, and the entry itself 356 * returns the page in which the entry was found (as a parameter - res_page),
357 * (as a parameter - res_dir). Page is returned mapped and unlocked. 357 * and the entry itself. Page is returned mapped and unlocked.
358 * Entry is guaranteed to be valid. 358 * Entry is guaranteed to be valid.
359 */ 359 */
360struct ext2_dir_entry_2 *ext2_find_entry (struct inode * dir, 360struct ext2_dir_entry_2 *ext2_find_entry (struct inode * dir,
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a8a8e27a063..da318b0fa637 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
142/* super.c */ 142/* super.c */
143extern void ext2_error (struct super_block *, const char *, const char *, ...) 143extern void ext2_error (struct super_block *, const char *, const char *, ...)
144 __attribute__ ((format (printf, 3, 4))); 144 __attribute__ ((format (printf, 3, 4)));
145extern void ext2_warning (struct super_block *, const char *, const char *, ...) 145extern void ext2_msg(struct super_block *, const char *, const char *, ...)
146 __attribute__ ((format (printf, 3, 4))); 146 __attribute__ ((format (printf, 3, 4)));
147extern void ext2_update_dynamic_rev (struct super_block *sb); 147extern void ext2_update_dynamic_rev (struct super_block *sb);
148extern void ext2_write_super (struct super_block *); 148extern void ext2_write_super (struct super_block *);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ade634076d0a..71b032c65a02 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
137 int final = 0; 137 int final = 0;
138 138
139 if (i_block < 0) { 139 if (i_block < 0) {
140 ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0"); 140 ext2_msg(inode->i_sb, KERN_WARNING,
141 "warning: %s: block < 0", __func__);
141 } else if (i_block < direct_blocks) { 142 } else if (i_block < direct_blocks) {
142 offsets[n++] = i_block; 143 offsets[n++] = i_block;
143 final = direct_blocks; 144 final = direct_blocks;
@@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
157 offsets[n++] = i_block & (ptrs - 1); 158 offsets[n++] = i_block & (ptrs - 1);
158 final = ptrs; 159 final = ptrs;
159 } else { 160 } else {
160 ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big"); 161 ext2_msg(inode->i_sb, KERN_WARNING,
162 "warning: %s: block is too big", __func__);
161 } 163 }
162 if (boundary) 164 if (boundary)
163 *boundary = final - 1 - (i_block & (ptrs - 1)); 165 *boundary = final - 1 - (i_block & (ptrs - 1));
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1a9ffee47d56..1388802b7803 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
58 } 58 }
59 59
60 va_start(args, fmt); 60 va_start(args, fmt);
61 printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function); 61 printk(KERN_CRIT "EXT2-fs (%s): error: %s: ", sb->s_id, function);
62 vprintk(fmt, args); 62 vprintk(fmt, args);
63 printk("\n"); 63 printk("\n");
64 va_end(args); 64 va_end(args);
65 65
66 if (test_opt(sb, ERRORS_PANIC)) 66 if (test_opt(sb, ERRORS_PANIC))
67 panic("EXT2-fs panic from previous error\n"); 67 panic("EXT2-fs: panic from previous error\n");
68 if (test_opt(sb, ERRORS_RO)) { 68 if (test_opt(sb, ERRORS_RO)) {
69 printk("Remounting filesystem read-only\n"); 69 ext2_msg(sb, KERN_CRIT,
70 "error: remounting filesystem read-only");
70 sb->s_flags |= MS_RDONLY; 71 sb->s_flags |= MS_RDONLY;
71 } 72 }
72} 73}
73 74
74void ext2_warning (struct super_block * sb, const char * function, 75void ext2_msg(struct super_block *sb, const char *prefix,
75 const char * fmt, ...) 76 const char *fmt, ...)
76{ 77{
77 va_list args; 78 va_list args;
78 79
79 va_start(args, fmt); 80 va_start(args, fmt);
80 printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ", 81 printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
81 sb->s_id, function);
82 vprintk(fmt, args); 82 vprintk(fmt, args);
83 printk("\n"); 83 printk("\n");
84 va_end(args); 84 va_end(args);
@@ -91,9 +91,9 @@ void ext2_update_dynamic_rev(struct super_block *sb)
91 if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) 91 if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
92 return; 92 return;
93 93
94 ext2_warning(sb, __func__, 94 ext2_msg(sb, KERN_WARNING,
95 "updating to rev %d because of new feature flag, " 95 "warning: updating to rev %d because of "
96 "running e2fsck is recommended", 96 "new feature flag, running e2fsck is recommended",
97 EXT2_DYNAMIC_REV); 97 EXT2_DYNAMIC_REV);
98 98
99 es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO); 99 es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
@@ -419,10 +419,10 @@ static const match_table_t tokens = {
419 {Opt_err, NULL} 419 {Opt_err, NULL}
420}; 420};
421 421
422static int parse_options (char * options, 422static int parse_options(char *options, struct super_block *sb)
423 struct ext2_sb_info *sbi)
424{ 423{
425 char * p; 424 char *p;
425 struct ext2_sb_info *sbi = EXT2_SB(sb);
426 substring_t args[MAX_OPT_ARGS]; 426 substring_t args[MAX_OPT_ARGS];
427 int option; 427 int option;
428 428
@@ -505,7 +505,8 @@ static int parse_options (char * options,
505#else 505#else
506 case Opt_user_xattr: 506 case Opt_user_xattr:
507 case Opt_nouser_xattr: 507 case Opt_nouser_xattr:
508 printk("EXT2 (no)user_xattr options not supported\n"); 508 ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
509 "not supported");
509 break; 510 break;
510#endif 511#endif
511#ifdef CONFIG_EXT2_FS_POSIX_ACL 512#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -518,14 +519,15 @@ static int parse_options (char * options,
518#else 519#else
519 case Opt_acl: 520 case Opt_acl:
520 case Opt_noacl: 521 case Opt_noacl:
521 printk("EXT2 (no)acl options not supported\n"); 522 ext2_msg(sb, KERN_INFO,
523 "(no)acl options not supported");
522 break; 524 break;
523#endif 525#endif
524 case Opt_xip: 526 case Opt_xip:
525#ifdef CONFIG_EXT2_FS_XIP 527#ifdef CONFIG_EXT2_FS_XIP
526 set_opt (sbi->s_mount_opt, XIP); 528 set_opt (sbi->s_mount_opt, XIP);
527#else 529#else
528 printk("EXT2 xip option not supported\n"); 530 ext2_msg(sb, KERN_INFO, "xip option not supported");
529#endif 531#endif
530 break; 532 break;
531 533
@@ -542,19 +544,18 @@ static int parse_options (char * options,
542 case Opt_quota: 544 case Opt_quota:
543 case Opt_usrquota: 545 case Opt_usrquota:
544 case Opt_grpquota: 546 case Opt_grpquota:
545 printk(KERN_ERR 547 ext2_msg(sb, KERN_INFO,
546 "EXT2-fs: quota operations not supported.\n"); 548 "quota operations not supported");
547
548 break; 549 break;
549#endif 550#endif
550 551
551 case Opt_reservation: 552 case Opt_reservation:
552 set_opt(sbi->s_mount_opt, RESERVATION); 553 set_opt(sbi->s_mount_opt, RESERVATION);
553 printk("reservations ON\n"); 554 ext2_msg(sb, KERN_INFO, "reservations ON");
554 break; 555 break;
555 case Opt_noreservation: 556 case Opt_noreservation:
556 clear_opt(sbi->s_mount_opt, RESERVATION); 557 clear_opt(sbi->s_mount_opt, RESERVATION);
557 printk("reservations OFF\n"); 558 ext2_msg(sb, KERN_INFO, "reservations OFF");
558 break; 559 break;
559 case Opt_ignore: 560 case Opt_ignore:
560 break; 561 break;
@@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
573 struct ext2_sb_info *sbi = EXT2_SB(sb); 574 struct ext2_sb_info *sbi = EXT2_SB(sb);
574 575
575 if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { 576 if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
576 printk ("EXT2-fs warning: revision level too high, " 577 ext2_msg(sb, KERN_ERR,
577 "forcing read-only mode\n"); 578 "error: revision level too high, "
579 "forcing read-only mode");
578 res = MS_RDONLY; 580 res = MS_RDONLY;
579 } 581 }
580 if (read_only) 582 if (read_only)
581 return res; 583 return res;
582 if (!(sbi->s_mount_state & EXT2_VALID_FS)) 584 if (!(sbi->s_mount_state & EXT2_VALID_FS))
583 printk ("EXT2-fs warning: mounting unchecked fs, " 585 ext2_msg(sb, KERN_WARNING,
584 "running e2fsck is recommended\n"); 586 "warning: mounting unchecked fs, "
587 "running e2fsck is recommended");
585 else if ((sbi->s_mount_state & EXT2_ERROR_FS)) 588 else if ((sbi->s_mount_state & EXT2_ERROR_FS))
586 printk ("EXT2-fs warning: mounting fs with errors, " 589 ext2_msg(sb, KERN_WARNING,
587 "running e2fsck is recommended\n"); 590 "warning: mounting fs with errors, "
591 "running e2fsck is recommended");
588 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 592 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
589 le16_to_cpu(es->s_mnt_count) >= 593 le16_to_cpu(es->s_mnt_count) >=
590 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 594 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
591 printk ("EXT2-fs warning: maximal mount count reached, " 595 ext2_msg(sb, KERN_WARNING,
592 "running e2fsck is recommended\n"); 596 "warning: maximal mount count reached, "
597 "running e2fsck is recommended");
593 else if (le32_to_cpu(es->s_checkinterval) && 598 else if (le32_to_cpu(es->s_checkinterval) &&
594 (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds())) 599 (le32_to_cpu(es->s_lastcheck) +
595 printk ("EXT2-fs warning: checktime reached, " 600 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
596 "running e2fsck is recommended\n"); 601 ext2_msg(sb, KERN_WARNING,
602 "warning: checktime reached, "
603 "running e2fsck is recommended");
597 if (!le16_to_cpu(es->s_max_mnt_count)) 604 if (!le16_to_cpu(es->s_max_mnt_count))
598 es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); 605 es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
599 le16_add_cpu(&es->s_mnt_count, 1); 606 le16_add_cpu(&es->s_mnt_count, 1);
600 ext2_write_super(sb); 607 ext2_write_super(sb);
601 if (test_opt (sb, DEBUG)) 608 if (test_opt (sb, DEBUG))
602 printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " 609 ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
603 "bpg=%lu, ipg=%lu, mo=%04lx]\n", 610 "bpg=%lu, ipg=%lu, mo=%04lx]",
604 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, 611 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
605 sbi->s_frag_size, 612 sbi->s_frag_size,
606 sbi->s_groups_count, 613 sbi->s_groups_count,
@@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
767 */ 774 */
768 blocksize = sb_min_blocksize(sb, BLOCK_SIZE); 775 blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
769 if (!blocksize) { 776 if (!blocksize) {
770 printk ("EXT2-fs: unable to set blocksize\n"); 777 ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
771 goto failed_sbi; 778 goto failed_sbi;
772 } 779 }
773 780
@@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
783 } 790 }
784 791
785 if (!(bh = sb_bread(sb, logic_sb_block))) { 792 if (!(bh = sb_bread(sb, logic_sb_block))) {
786 printk ("EXT2-fs: unable to read superblock\n"); 793 ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
787 goto failed_sbi; 794 goto failed_sbi;
788 } 795 }
789 /* 796 /*
@@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
826 833
827 set_opt(sbi->s_mount_opt, RESERVATION); 834 set_opt(sbi->s_mount_opt, RESERVATION);
828 835
829 if (!parse_options ((char *) data, sbi)) 836 if (!parse_options((char *) data, sb))
830 goto failed_mount; 837 goto failed_mount;
831 838
832 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 839 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
840 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || 847 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
841 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 848 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
842 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U))) 849 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
843 printk("EXT2-fs warning: feature flags set on rev 0 fs, " 850 ext2_msg(sb, KERN_WARNING,
844 "running e2fsck is recommended\n"); 851 "warning: feature flags set on rev 0 fs, "
852 "running e2fsck is recommended");
845 /* 853 /*
846 * Check feature flags regardless of the revision level, since we 854 * Check feature flags regardless of the revision level, since we
847 * previously didn't change the revision level when setting the flags, 855 * previously didn't change the revision level when setting the flags,
@@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
849 */ 857 */
850 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP); 858 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
851 if (features) { 859 if (features) {
852 printk("EXT2-fs: %s: couldn't mount because of " 860 ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
853 "unsupported optional features (%x).\n", 861 "unsupported optional features (%x)",
854 sb->s_id, le32_to_cpu(features)); 862 le32_to_cpu(features));
855 goto failed_mount; 863 goto failed_mount;
856 } 864 }
857 if (!(sb->s_flags & MS_RDONLY) && 865 if (!(sb->s_flags & MS_RDONLY) &&
858 (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){ 866 (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
859 printk("EXT2-fs: %s: couldn't mount RDWR because of " 867 ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
860 "unsupported optional features (%x).\n", 868 "unsupported optional features (%x)",
861 sb->s_id, le32_to_cpu(features)); 869 le32_to_cpu(features));
862 goto failed_mount; 870 goto failed_mount;
863 } 871 }
864 872
@@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
866 874
867 if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) { 875 if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
868 if (!silent) 876 if (!silent)
869 printk("XIP: Unsupported blocksize\n"); 877 ext2_msg(sb, KERN_ERR,
878 "error: unsupported blocksize for xip");
870 goto failed_mount; 879 goto failed_mount;
871 } 880 }
872 881
@@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
875 brelse(bh); 884 brelse(bh);
876 885
877 if (!sb_set_blocksize(sb, blocksize)) { 886 if (!sb_set_blocksize(sb, blocksize)) {
878 printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n"); 887 ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
879 goto failed_sbi; 888 goto failed_sbi;
880 } 889 }
881 890
@@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
883 offset = (sb_block*BLOCK_SIZE) % blocksize; 892 offset = (sb_block*BLOCK_SIZE) % blocksize;
884 bh = sb_bread(sb, logic_sb_block); 893 bh = sb_bread(sb, logic_sb_block);
885 if(!bh) { 894 if(!bh) {
886 printk("EXT2-fs: Couldn't read superblock on " 895 ext2_msg(sb, KERN_ERR, "error: couldn't read"
887 "2nd try.\n"); 896 "superblock on 2nd try");
888 goto failed_sbi; 897 goto failed_sbi;
889 } 898 }
890 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); 899 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
891 sbi->s_es = es; 900 sbi->s_es = es;
892 if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { 901 if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
893 printk ("EXT2-fs: Magic mismatch, very weird !\n"); 902 ext2_msg(sb, KERN_ERR, "error: magic mismatch");
894 goto failed_mount; 903 goto failed_mount;
895 } 904 }
896 } 905 }
@@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
906 if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || 915 if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
907 !is_power_of_2(sbi->s_inode_size) || 916 !is_power_of_2(sbi->s_inode_size) ||
908 (sbi->s_inode_size > blocksize)) { 917 (sbi->s_inode_size > blocksize)) {
909 printk ("EXT2-fs: unsupported inode size: %d\n", 918 ext2_msg(sb, KERN_ERR,
919 "error: unsupported inode size: %d",
910 sbi->s_inode_size); 920 sbi->s_inode_size);
911 goto failed_mount; 921 goto failed_mount;
912 } 922 }
@@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
943 953
944 if (sb->s_blocksize != bh->b_size) { 954 if (sb->s_blocksize != bh->b_size) {
945 if (!silent) 955 if (!silent)
946 printk ("VFS: Unsupported blocksize on dev " 956 ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
947 "%s.\n", sb->s_id);
948 goto failed_mount; 957 goto failed_mount;
949 } 958 }
950 959
951 if (sb->s_blocksize != sbi->s_frag_size) { 960 if (sb->s_blocksize != sbi->s_frag_size) {
952 printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n", 961 ext2_msg(sb, KERN_ERR,
962 "error: fragsize %lu != blocksize %lu"
963 "(not supported yet)",
953 sbi->s_frag_size, sb->s_blocksize); 964 sbi->s_frag_size, sb->s_blocksize);
954 goto failed_mount; 965 goto failed_mount;
955 } 966 }
956 967
957 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { 968 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
958 printk ("EXT2-fs: #blocks per group too big: %lu\n", 969 ext2_msg(sb, KERN_ERR,
970 "error: #blocks per group too big: %lu",
959 sbi->s_blocks_per_group); 971 sbi->s_blocks_per_group);
960 goto failed_mount; 972 goto failed_mount;
961 } 973 }
962 if (sbi->s_frags_per_group > sb->s_blocksize * 8) { 974 if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
963 printk ("EXT2-fs: #fragments per group too big: %lu\n", 975 ext2_msg(sb, KERN_ERR,
976 "error: #fragments per group too big: %lu",
964 sbi->s_frags_per_group); 977 sbi->s_frags_per_group);
965 goto failed_mount; 978 goto failed_mount;
966 } 979 }
967 if (sbi->s_inodes_per_group > sb->s_blocksize * 8) { 980 if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
968 printk ("EXT2-fs: #inodes per group too big: %lu\n", 981 ext2_msg(sb, KERN_ERR,
982 "error: #inodes per group too big: %lu",
969 sbi->s_inodes_per_group); 983 sbi->s_inodes_per_group);
970 goto failed_mount; 984 goto failed_mount;
971 } 985 }
@@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
979 EXT2_DESC_PER_BLOCK(sb); 993 EXT2_DESC_PER_BLOCK(sb);
980 sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); 994 sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
981 if (sbi->s_group_desc == NULL) { 995 if (sbi->s_group_desc == NULL) {
982 printk ("EXT2-fs: not enough memory\n"); 996 ext2_msg(sb, KERN_ERR, "error: not enough memory");
983 goto failed_mount; 997 goto failed_mount;
984 } 998 }
985 bgl_lock_init(sbi->s_blockgroup_lock); 999 bgl_lock_init(sbi->s_blockgroup_lock);
986 sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); 1000 sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
987 if (!sbi->s_debts) { 1001 if (!sbi->s_debts) {
988 printk ("EXT2-fs: not enough memory\n"); 1002 ext2_msg(sb, KERN_ERR, "error: not enough memory");
989 goto failed_mount_group_desc; 1003 goto failed_mount_group_desc;
990 } 1004 }
991 for (i = 0; i < db_count; i++) { 1005 for (i = 0; i < db_count; i++) {
@@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
994 if (!sbi->s_group_desc[i]) { 1008 if (!sbi->s_group_desc[i]) {
995 for (j = 0; j < i; j++) 1009 for (j = 0; j < i; j++)
996 brelse (sbi->s_group_desc[j]); 1010 brelse (sbi->s_group_desc[j]);
997 printk ("EXT2-fs: unable to read group descriptors\n"); 1011 ext2_msg(sb, KERN_ERR,
1012 "error: unable to read group descriptors");
998 goto failed_mount_group_desc; 1013 goto failed_mount_group_desc;
999 } 1014 }
1000 } 1015 }
1001 if (!ext2_check_descriptors (sb)) { 1016 if (!ext2_check_descriptors (sb)) {
1002 printk ("EXT2-fs: group descriptors corrupted!\n"); 1017 ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
1003 goto failed_mount2; 1018 goto failed_mount2;
1004 } 1019 }
1005 sbi->s_gdb_count = db_count; 1020 sbi->s_gdb_count = db_count;
@@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
1032 ext2_count_dirs(sb)); 1047 ext2_count_dirs(sb));
1033 } 1048 }
1034 if (err) { 1049 if (err) {
1035 printk(KERN_ERR "EXT2-fs: insufficient memory\n"); 1050 ext2_msg(sb, KERN_ERR, "error: insufficient memory");
1036 goto failed_mount3; 1051 goto failed_mount3;
1037 } 1052 }
1038 /* 1053 /*
@@ -1048,27 +1063,28 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
1048 } 1063 }
1049 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 1064 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1050 iput(root); 1065 iput(root);
1051 printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); 1066 ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
1052 goto failed_mount3; 1067 goto failed_mount3;
1053 } 1068 }
1054 1069
1055 sb->s_root = d_alloc_root(root); 1070 sb->s_root = d_alloc_root(root);
1056 if (!sb->s_root) { 1071 if (!sb->s_root) {
1057 iput(root); 1072 iput(root);
1058 printk(KERN_ERR "EXT2-fs: get root inode failed\n"); 1073 ext2_msg(sb, KERN_ERR, "error: get root inode failed");
1059 ret = -ENOMEM; 1074 ret = -ENOMEM;
1060 goto failed_mount3; 1075 goto failed_mount3;
1061 } 1076 }
1062 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) 1077 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
1063 ext2_warning(sb, __func__, 1078 ext2_msg(sb, KERN_WARNING,
1064 "mounting ext3 filesystem as ext2"); 1079 "warning: mounting ext3 filesystem as ext2");
1065 ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); 1080 ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
1066 return 0; 1081 return 0;
1067 1082
1068cantfind_ext2: 1083cantfind_ext2:
1069 if (!silent) 1084 if (!silent)
1070 printk("VFS: Can't find an ext2 filesystem on dev %s.\n", 1085 ext2_msg(sb, KERN_ERR,
1071 sb->s_id); 1086 "error: can't find an ext2 filesystem on dev %s.",
1087 sb->s_id);
1072 goto failed_mount; 1088 goto failed_mount;
1073failed_mount3: 1089failed_mount3:
1074 percpu_counter_destroy(&sbi->s_freeblocks_counter); 1090 percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1121,8 +1137,24 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
1121static int ext2_sync_fs(struct super_block *sb, int wait) 1137static int ext2_sync_fs(struct super_block *sb, int wait)
1122{ 1138{
1123 struct ext2_super_block *es = EXT2_SB(sb)->s_es; 1139 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
1140 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
1124 1141
1125 lock_kernel(); 1142 lock_kernel();
1143 if (buffer_write_io_error(sbh)) {
1144 /*
1145 * Oh, dear. A previous attempt to write the
1146 * superblock failed. This could happen because the
1147 * USB device was yanked out. Or it could happen to
1148 * be a transient write error and maybe the block will
1149 * be remapped. Nothing we can do but to retry the
1150 * write and hope for the best.
1151 */
1152 ext2_msg(sb, KERN_ERR,
1153 "previous I/O error to superblock detected\n");
1154 clear_buffer_write_io_error(sbh);
1155 set_buffer_uptodate(sbh);
1156 }
1157
1126 if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { 1158 if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
1127 ext2_debug("setting valid to 0\n"); 1159 ext2_debug("setting valid to 0\n");
1128 es->s_state &= cpu_to_le16(~EXT2_VALID_FS); 1160 es->s_state &= cpu_to_le16(~EXT2_VALID_FS);
@@ -1170,7 +1202,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1170 /* 1202 /*
1171 * Allow the "check" option to be passed as a remount option. 1203 * Allow the "check" option to be passed as a remount option.
1172 */ 1204 */
1173 if (!parse_options (data, sbi)) { 1205 if (!parse_options(data, sb)) {
1174 err = -EINVAL; 1206 err = -EINVAL;
1175 goto restore_opts; 1207 goto restore_opts;
1176 } 1208 }
@@ -1182,7 +1214,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1182 EXT2_MOUNT_XIP if not */ 1214 EXT2_MOUNT_XIP if not */
1183 1215
1184 if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) { 1216 if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
1185 printk("XIP: Unsupported blocksize\n"); 1217 ext2_msg(sb, KERN_WARNING,
1218 "warning: unsupported blocksize for xip");
1186 err = -EINVAL; 1219 err = -EINVAL;
1187 goto restore_opts; 1220 goto restore_opts;
1188 } 1221 }
@@ -1191,8 +1224,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1191 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != 1224 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
1192 (old_mount_opt & EXT2_MOUNT_XIP)) && 1225 (old_mount_opt & EXT2_MOUNT_XIP)) &&
1193 invalidate_inodes(sb)) { 1226 invalidate_inodes(sb)) {
1194 ext2_warning(sb, __func__, "refusing change of xip flag " 1227 ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
1195 "with busy inodes while remounting"); 1228 "xip flag with busy inodes while remounting");
1196 sbi->s_mount_opt &= ~EXT2_MOUNT_XIP; 1229 sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
1197 sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP; 1230 sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
1198 } 1231 }
@@ -1216,9 +1249,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1216 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb, 1249 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
1217 ~EXT2_FEATURE_RO_COMPAT_SUPP); 1250 ~EXT2_FEATURE_RO_COMPAT_SUPP);
1218 if (ret) { 1251 if (ret) {
1219 printk("EXT2-fs: %s: couldn't remount RDWR because of " 1252 ext2_msg(sb, KERN_WARNING,
1220 "unsupported optional features (%x).\n", 1253 "warning: couldn't remount RDWR because of "
1221 sb->s_id, le32_to_cpu(ret)); 1254 "unsupported optional features (%x).",
1255 le32_to_cpu(ret));
1222 err = -EROFS; 1256 err = -EROFS;
1223 goto restore_opts; 1257 goto restore_opts;
1224 } 1258 }
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index c18fbf3e4068..322a56b2dfb1 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
69 if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) && 69 if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
70 !sb->s_bdev->bd_disk->fops->direct_access) { 70 !sb->s_bdev->bd_disk->fops->direct_access) {
71 sbi->s_mount_opt &= (~EXT2_MOUNT_XIP); 71 sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
72 ext2_warning(sb, __func__, 72 ext2_msg(sb, KERN_WARNING,
73 "ignoring xip option - not supported by bdev"); 73 "warning: ignoring xip option - "
74 "not supported by bdev");
74 } 75 }
75} 76}
76 77
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 2db957778903..ad14227f509e 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1151,6 +1151,16 @@ static int do_journal_get_write_access(handle_t *handle,
1151 return ext3_journal_get_write_access(handle, bh); 1151 return ext3_journal_get_write_access(handle, bh);
1152} 1152}
1153 1153
1154/*
1155 * Truncate blocks that were not used by write. We have to truncate the
1156 * pagecache as well so that corresponding buffers get properly unmapped.
1157 */
1158static void ext3_truncate_failed_write(struct inode *inode)
1159{
1160 truncate_inode_pages(inode->i_mapping, inode->i_size);
1161 ext3_truncate(inode);
1162}
1163
1154static int ext3_write_begin(struct file *file, struct address_space *mapping, 1164static int ext3_write_begin(struct file *file, struct address_space *mapping,
1155 loff_t pos, unsigned len, unsigned flags, 1165 loff_t pos, unsigned len, unsigned flags,
1156 struct page **pagep, void **fsdata) 1166 struct page **pagep, void **fsdata)
@@ -1209,7 +1219,7 @@ write_begin_failed:
1209 unlock_page(page); 1219 unlock_page(page);
1210 page_cache_release(page); 1220 page_cache_release(page);
1211 if (pos + len > inode->i_size) 1221 if (pos + len > inode->i_size)
1212 ext3_truncate(inode); 1222 ext3_truncate_failed_write(inode);
1213 } 1223 }
1214 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1224 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1215 goto retry; 1225 goto retry;
@@ -1304,7 +1314,7 @@ static int ext3_ordered_write_end(struct file *file,
1304 page_cache_release(page); 1314 page_cache_release(page);
1305 1315
1306 if (pos + len > inode->i_size) 1316 if (pos + len > inode->i_size)
1307 ext3_truncate(inode); 1317 ext3_truncate_failed_write(inode);
1308 return ret ? ret : copied; 1318 return ret ? ret : copied;
1309} 1319}
1310 1320
@@ -1330,7 +1340,7 @@ static int ext3_writeback_write_end(struct file *file,
1330 page_cache_release(page); 1340 page_cache_release(page);
1331 1341
1332 if (pos + len > inode->i_size) 1342 if (pos + len > inode->i_size)
1333 ext3_truncate(inode); 1343 ext3_truncate_failed_write(inode);
1334 return ret ? ret : copied; 1344 return ret ? ret : copied;
1335} 1345}
1336 1346
@@ -1383,7 +1393,7 @@ static int ext3_journalled_write_end(struct file *file,
1383 page_cache_release(page); 1393 page_cache_release(page);
1384 1394
1385 if (pos + len > inode->i_size) 1395 if (pos + len > inode->i_size)
1386 ext3_truncate(inode); 1396 ext3_truncate_failed_write(inode);
1387 return ret ? ret : copied; 1397 return ret ? ret : copied;
1388} 1398}
1389 1399
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 8359e7b3dc89..5f83b6179178 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -266,7 +266,7 @@ static int setup_new_group_blocks(struct super_block *sb,
266 goto exit_bh; 266 goto exit_bh;
267 267
268 if (IS_ERR(gdb = bclean(handle, sb, block))) { 268 if (IS_ERR(gdb = bclean(handle, sb, block))) {
269 err = PTR_ERR(bh); 269 err = PTR_ERR(gdb);
270 goto exit_bh; 270 goto exit_bh;
271 } 271 }
272 ext3_journal_dirty_metadata(handle, gdb); 272 ext3_journal_dirty_metadata(handle, gdb);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 427496c4767c..7ad1e8c30bd0 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
144void 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 *
@@ -174,12 +186,13 @@ static void ext3_handle_error(struct super_block *sb)
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,21 +280,20 @@ 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 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
@@ -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 */
334static struct block_device *ext3_blkdev_get(dev_t dev) 345static 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
344fail: 355fail:
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,
@@ -527,9 +539,22 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl
527#if defined(CONFIG_QUOTA) 539#if defined(CONFIG_QUOTA)
528 struct ext3_sb_info *sbi = EXT3_SB(sb); 540 struct ext3_sb_info *sbi = EXT3_SB(sb);
529 541
530 if (sbi->s_jquota_fmt) 542 if (sbi->s_jquota_fmt) {
531 seq_printf(seq, ",jqfmt=%s", 543 char *fmtname = "";
532 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); 544
545 switch (sbi->s_jquota_fmt) {
546 case QFMT_VFS_OLD:
547 fmtname = "vfsold";
548 break;
549 case QFMT_VFS_V0:
550 fmtname = "vfsv0";
551 break;
552 case QFMT_VFS_V1:
553 fmtname = "vfsv1";
554 break;
555 }
556 seq_printf(seq, ",jqfmt=%s", fmtname);
557 }
533 558
534 if (sbi->s_qf_names[USRQUOTA]) 559 if (sbi->s_qf_names[USRQUOTA])
535 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]); 560 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
@@ -636,6 +661,9 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
636 if (test_opt(sb, DATA_ERR_ABORT)) 661 if (test_opt(sb, DATA_ERR_ABORT))
637 seq_puts(seq, ",data_err=abort"); 662 seq_puts(seq, ",data_err=abort");
638 663
664 if (test_opt(sb, NOLOAD))
665 seq_puts(seq, ",norecovery");
666
639 ext3_show_quota_options(seq, sb); 667 ext3_show_quota_options(seq, sb);
640 668
641 return 0; 669 return 0;
@@ -787,9 +815,9 @@ enum {
787 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 815 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
788 Opt_data_err_abort, Opt_data_err_ignore, 816 Opt_data_err_abort, Opt_data_err_ignore,
789 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 817 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
790 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, 818 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
791 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, 819 Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
792 Opt_grpquota 820 Opt_usrquota, Opt_grpquota
793}; 821};
794 822
795static const match_table_t tokens = { 823static const match_table_t tokens = {
@@ -818,6 +846,7 @@ static const match_table_t tokens = {
818 {Opt_reservation, "reservation"}, 846 {Opt_reservation, "reservation"},
819 {Opt_noreservation, "noreservation"}, 847 {Opt_noreservation, "noreservation"},
820 {Opt_noload, "noload"}, 848 {Opt_noload, "noload"},
849 {Opt_noload, "norecovery"},
821 {Opt_nobh, "nobh"}, 850 {Opt_nobh, "nobh"},
822 {Opt_bh, "bh"}, 851 {Opt_bh, "bh"},
823 {Opt_commit, "commit=%u"}, 852 {Opt_commit, "commit=%u"},
@@ -836,6 +865,7 @@ static const match_table_t tokens = {
836 {Opt_grpjquota, "grpjquota=%s"}, 865 {Opt_grpjquota, "grpjquota=%s"},
837 {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, 866 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
838 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, 867 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
868 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
839 {Opt_grpquota, "grpquota"}, 869 {Opt_grpquota, "grpquota"},
840 {Opt_noquota, "noquota"}, 870 {Opt_noquota, "noquota"},
841 {Opt_quota, "quota"}, 871 {Opt_quota, "quota"},
@@ -845,7 +875,7 @@ static const match_table_t tokens = {
845 {Opt_err, NULL}, 875 {Opt_err, NULL},
846}; 876};
847 877
848static ext3_fsblk_t get_sb_block(void **data) 878static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)
849{ 879{
850 ext3_fsblk_t sb_block; 880 ext3_fsblk_t sb_block;
851 char *options = (char *) *data; 881 char *options = (char *) *data;
@@ -856,7 +886,7 @@ static ext3_fsblk_t get_sb_block(void **data)
856 /*todo: use simple_strtoll with >32bit ext3 */ 886 /*todo: use simple_strtoll with >32bit ext3 */
857 sb_block = simple_strtoul(options, &options, 0); 887 sb_block = simple_strtoul(options, &options, 0);
858 if (*options && *options != ',') { 888 if (*options && *options != ',') {
859 printk("EXT3-fs: Invalid sb specification: %s\n", 889 ext3_msg(sb, "error: invalid sb specification: %s",
860 (char *) *data); 890 (char *) *data);
861 return 1; 891 return 1;
862 } 892 }
@@ -956,7 +986,8 @@ static int parse_options (char *options, struct super_block *sb,
956#else 986#else
957 case Opt_user_xattr: 987 case Opt_user_xattr:
958 case Opt_nouser_xattr: 988 case Opt_nouser_xattr:
959 printk("EXT3 (no)user_xattr options not supported\n"); 989 ext3_msg(sb, KERN_INFO,
990 "(no)user_xattr options not supported");
960 break; 991 break;
961#endif 992#endif
962#ifdef CONFIG_EXT3_FS_POSIX_ACL 993#ifdef CONFIG_EXT3_FS_POSIX_ACL
@@ -969,7 +1000,8 @@ static int parse_options (char *options, struct super_block *sb,
969#else 1000#else
970 case Opt_acl: 1001 case Opt_acl:
971 case Opt_noacl: 1002 case Opt_noacl:
972 printk("EXT3 (no)acl options not supported\n"); 1003 ext3_msg(sb, KERN_INFO,
1004 "(no)acl options not supported");
973 break; 1005 break;
974#endif 1006#endif
975 case Opt_reservation: 1007 case Opt_reservation:
@@ -985,16 +1017,16 @@ static int parse_options (char *options, struct super_block *sb,
985 user to specify an existing inode to be the 1017 user to specify an existing inode to be the
986 journal file. */ 1018 journal file. */
987 if (is_remount) { 1019 if (is_remount) {
988 printk(KERN_ERR "EXT3-fs: cannot specify " 1020 ext3_msg(sb, KERN_ERR, "error: cannot specify "
989 "journal on remount\n"); 1021 "journal on remount");
990 return 0; 1022 return 0;
991 } 1023 }
992 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL); 1024 set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
993 break; 1025 break;
994 case Opt_journal_inum: 1026 case Opt_journal_inum:
995 if (is_remount) { 1027 if (is_remount) {
996 printk(KERN_ERR "EXT3-fs: cannot specify " 1028 ext3_msg(sb, KERN_ERR, "error: cannot specify "
997 "journal on remount\n"); 1029 "journal on remount");
998 return 0; 1030 return 0;
999 } 1031 }
1000 if (match_int(&args[0], &option)) 1032 if (match_int(&args[0], &option))
@@ -1003,8 +1035,8 @@ static int parse_options (char *options, struct super_block *sb,
1003 break; 1035 break;
1004 case Opt_journal_dev: 1036 case Opt_journal_dev:
1005 if (is_remount) { 1037 if (is_remount) {
1006 printk(KERN_ERR "EXT3-fs: cannot specify " 1038 ext3_msg(sb, KERN_ERR, "error: cannot specify "
1007 "journal on remount\n"); 1039 "journal on remount");
1008 return 0; 1040 return 0;
1009 } 1041 }
1010 if (match_int(&args[0], &option)) 1042 if (match_int(&args[0], &option))
@@ -1036,12 +1068,11 @@ static int parse_options (char *options, struct super_block *sb,
1036 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) 1068 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS)
1037 == data_opt) 1069 == data_opt)
1038 break; 1070 break;
1039 printk(KERN_ERR 1071 ext3_msg(sb, KERN_ERR,
1040 "EXT3-fs (device %s): Cannot change " 1072 "error: cannot change "
1041 "data mode on remount. The filesystem " 1073 "data mode on remount. The filesystem "
1042 "is mounted in data=%s mode and you " 1074 "is mounted in data=%s mode and you "
1043 "try to remount it in data=%s mode.\n", 1075 "try to remount it in data=%s mode.",
1044 sb->s_id,
1045 data_mode_string(sbi->s_mount_opt & 1076 data_mode_string(sbi->s_mount_opt &
1046 EXT3_MOUNT_DATA_FLAGS), 1077 EXT3_MOUNT_DATA_FLAGS),
1047 data_mode_string(data_opt)); 1078 data_mode_string(data_opt));
@@ -1066,31 +1097,31 @@ static int parse_options (char *options, struct super_block *sb,
1066set_qf_name: 1097set_qf_name:
1067 if (sb_any_quota_loaded(sb) && 1098 if (sb_any_quota_loaded(sb) &&
1068 !sbi->s_qf_names[qtype]) { 1099 !sbi->s_qf_names[qtype]) {
1069 printk(KERN_ERR 1100 ext3_msg(sb, KERN_ERR,
1070 "EXT3-fs: Cannot change journaled " 1101 "error: cannot change journaled "
1071 "quota options when quota turned on.\n"); 1102 "quota options when quota turned on.");
1072 return 0; 1103 return 0;
1073 } 1104 }
1074 qname = match_strdup(&args[0]); 1105 qname = match_strdup(&args[0]);
1075 if (!qname) { 1106 if (!qname) {
1076 printk(KERN_ERR 1107 ext3_msg(sb, KERN_ERR,
1077 "EXT3-fs: not enough memory for " 1108 "error: not enough memory for "
1078 "storing quotafile name.\n"); 1109 "storing quotafile name.");
1079 return 0; 1110 return 0;
1080 } 1111 }
1081 if (sbi->s_qf_names[qtype] && 1112 if (sbi->s_qf_names[qtype] &&
1082 strcmp(sbi->s_qf_names[qtype], qname)) { 1113 strcmp(sbi->s_qf_names[qtype], qname)) {
1083 printk(KERN_ERR 1114 ext3_msg(sb, KERN_ERR,
1084 "EXT3-fs: %s quota file already " 1115 "error: %s quota file already "
1085 "specified.\n", QTYPE2NAME(qtype)); 1116 "specified.", QTYPE2NAME(qtype));
1086 kfree(qname); 1117 kfree(qname);
1087 return 0; 1118 return 0;
1088 } 1119 }
1089 sbi->s_qf_names[qtype] = qname; 1120 sbi->s_qf_names[qtype] = qname;
1090 if (strchr(sbi->s_qf_names[qtype], '/')) { 1121 if (strchr(sbi->s_qf_names[qtype], '/')) {
1091 printk(KERN_ERR 1122 ext3_msg(sb, KERN_ERR,
1092 "EXT3-fs: quotafile must be on " 1123 "error: quotafile must be on "
1093 "filesystem root.\n"); 1124 "filesystem root.");
1094 kfree(sbi->s_qf_names[qtype]); 1125 kfree(sbi->s_qf_names[qtype]);
1095 sbi->s_qf_names[qtype] = NULL; 1126 sbi->s_qf_names[qtype] = NULL;
1096 return 0; 1127 return 0;
@@ -1105,9 +1136,9 @@ set_qf_name:
1105clear_qf_name: 1136clear_qf_name:
1106 if (sb_any_quota_loaded(sb) && 1137 if (sb_any_quota_loaded(sb) &&
1107 sbi->s_qf_names[qtype]) { 1138 sbi->s_qf_names[qtype]) {
1108 printk(KERN_ERR "EXT3-fs: Cannot change " 1139 ext3_msg(sb, KERN_ERR, "error: cannot change "
1109 "journaled quota options when " 1140 "journaled quota options when "
1110 "quota turned on.\n"); 1141 "quota turned on.");
1111 return 0; 1142 return 0;
1112 } 1143 }
1113 /* 1144 /*
@@ -1121,12 +1152,15 @@ clear_qf_name:
1121 goto set_qf_format; 1152 goto set_qf_format;
1122 case Opt_jqfmt_vfsv0: 1153 case Opt_jqfmt_vfsv0:
1123 qfmt = QFMT_VFS_V0; 1154 qfmt = QFMT_VFS_V0;
1155 goto set_qf_format;
1156 case Opt_jqfmt_vfsv1:
1157 qfmt = QFMT_VFS_V1;
1124set_qf_format: 1158set_qf_format:
1125 if (sb_any_quota_loaded(sb) && 1159 if (sb_any_quota_loaded(sb) &&
1126 sbi->s_jquota_fmt != qfmt) { 1160 sbi->s_jquota_fmt != qfmt) {
1127 printk(KERN_ERR "EXT3-fs: Cannot change " 1161 ext3_msg(sb, KERN_ERR, "error: cannot change "
1128 "journaled quota options when " 1162 "journaled quota options when "
1129 "quota turned on.\n"); 1163 "quota turned on.");
1130 return 0; 1164 return 0;
1131 } 1165 }
1132 sbi->s_jquota_fmt = qfmt; 1166 sbi->s_jquota_fmt = qfmt;
@@ -1142,8 +1176,8 @@ set_qf_format:
1142 break; 1176 break;
1143 case Opt_noquota: 1177 case Opt_noquota:
1144 if (sb_any_quota_loaded(sb)) { 1178 if (sb_any_quota_loaded(sb)) {
1145 printk(KERN_ERR "EXT3-fs: Cannot change quota " 1179 ext3_msg(sb, KERN_ERR, "error: cannot change "
1146 "options when quota turned on.\n"); 1180 "quota options when quota turned on.");
1147 return 0; 1181 return 0;
1148 } 1182 }
1149 clear_opt(sbi->s_mount_opt, QUOTA); 1183 clear_opt(sbi->s_mount_opt, QUOTA);
@@ -1154,8 +1188,8 @@ set_qf_format:
1154 case Opt_quota: 1188 case Opt_quota:
1155 case Opt_usrquota: 1189 case Opt_usrquota:
1156 case Opt_grpquota: 1190 case Opt_grpquota:
1157 printk(KERN_ERR 1191 ext3_msg(sb, KERN_ERR,
1158 "EXT3-fs: quota options not supported.\n"); 1192 "error: quota options not supported.");
1159 break; 1193 break;
1160 case Opt_usrjquota: 1194 case Opt_usrjquota:
1161 case Opt_grpjquota: 1195 case Opt_grpjquota:
@@ -1163,9 +1197,10 @@ set_qf_format:
1163 case Opt_offgrpjquota: 1197 case Opt_offgrpjquota:
1164 case Opt_jqfmt_vfsold: 1198 case Opt_jqfmt_vfsold:
1165 case Opt_jqfmt_vfsv0: 1199 case Opt_jqfmt_vfsv0:
1166 printk(KERN_ERR 1200 case Opt_jqfmt_vfsv1:
1167 "EXT3-fs: journaled quota options not " 1201 ext3_msg(sb, KERN_ERR,
1168 "supported.\n"); 1202 "error: journaled quota options not "
1203 "supported.");
1169 break; 1204 break;
1170 case Opt_noquota: 1205 case Opt_noquota:
1171 break; 1206 break;
@@ -1185,8 +1220,9 @@ set_qf_format:
1185 break; 1220 break;
1186 case Opt_resize: 1221 case Opt_resize:
1187 if (!is_remount) { 1222 if (!is_remount) {
1188 printk("EXT3-fs: resize option only available " 1223 ext3_msg(sb, KERN_ERR,
1189 "for remount\n"); 1224 "error: resize option only available "
1225 "for remount");
1190 return 0; 1226 return 0;
1191 } 1227 }
1192 if (match_int(&args[0], &option) != 0) 1228 if (match_int(&args[0], &option) != 0)
@@ -1200,9 +1236,9 @@ set_qf_format:
1200 clear_opt(sbi->s_mount_opt, NOBH); 1236 clear_opt(sbi->s_mount_opt, NOBH);
1201 break; 1237 break;
1202 default: 1238 default:
1203 printk (KERN_ERR 1239 ext3_msg(sb, KERN_ERR,
1204 "EXT3-fs: Unrecognized mount option \"%s\" " 1240 "error: unrecognized mount option \"%s\" "
1205 "or missing value\n", p); 1241 "or missing value", p);
1206 return 0; 1242 return 0;
1207 } 1243 }
1208 } 1244 }
@@ -1220,21 +1256,21 @@ set_qf_format:
1220 (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || 1256 (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) ||
1221 (sbi->s_qf_names[GRPQUOTA] && 1257 (sbi->s_qf_names[GRPQUOTA] &&
1222 (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) { 1258 (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) {
1223 printk(KERN_ERR "EXT3-fs: old and new quota " 1259 ext3_msg(sb, KERN_ERR, "error: old and new quota "
1224 "format mixing.\n"); 1260 "format mixing.");
1225 return 0; 1261 return 0;
1226 } 1262 }
1227 1263
1228 if (!sbi->s_jquota_fmt) { 1264 if (!sbi->s_jquota_fmt) {
1229 printk(KERN_ERR "EXT3-fs: journaled quota format " 1265 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1230 "not specified.\n"); 1266 "not specified.");
1231 return 0; 1267 return 0;
1232 } 1268 }
1233 } else { 1269 } else {
1234 if (sbi->s_jquota_fmt) { 1270 if (sbi->s_jquota_fmt) {
1235 printk(KERN_ERR "EXT3-fs: journaled quota format " 1271 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1236 "specified with no journaling " 1272 "specified with no journaling "
1237 "enabled.\n"); 1273 "enabled.");
1238 return 0; 1274 return 0;
1239 } 1275 }
1240 } 1276 }
@@ -1249,31 +1285,33 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1249 int res = 0; 1285 int res = 0;
1250 1286
1251 if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) { 1287 if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) {
1252 printk (KERN_ERR "EXT3-fs warning: revision level too high, " 1288 ext3_msg(sb, KERN_ERR,
1253 "forcing read-only mode\n"); 1289 "error: revision level too high, "
1290 "forcing read-only mode");
1254 res = MS_RDONLY; 1291 res = MS_RDONLY;
1255 } 1292 }
1256 if (read_only) 1293 if (read_only)
1257 return res; 1294 return res;
1258 if (!(sbi->s_mount_state & EXT3_VALID_FS)) 1295 if (!(sbi->s_mount_state & EXT3_VALID_FS))
1259 printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, " 1296 ext3_msg(sb, KERN_WARNING,
1260 "running e2fsck is recommended\n"); 1297 "warning: mounting unchecked fs, "
1298 "running e2fsck is recommended");
1261 else if ((sbi->s_mount_state & EXT3_ERROR_FS)) 1299 else if ((sbi->s_mount_state & EXT3_ERROR_FS))
1262 printk (KERN_WARNING 1300 ext3_msg(sb, KERN_WARNING,
1263 "EXT3-fs warning: mounting fs with errors, " 1301 "warning: mounting fs with errors, "
1264 "running e2fsck is recommended\n"); 1302 "running e2fsck is recommended");
1265 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && 1303 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
1266 le16_to_cpu(es->s_mnt_count) >= 1304 le16_to_cpu(es->s_mnt_count) >=
1267 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) 1305 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
1268 printk (KERN_WARNING 1306 ext3_msg(sb, KERN_WARNING,
1269 "EXT3-fs warning: maximal mount count reached, " 1307 "warning: maximal mount count reached, "
1270 "running e2fsck is recommended\n"); 1308 "running e2fsck is recommended");
1271 else if (le32_to_cpu(es->s_checkinterval) && 1309 else if (le32_to_cpu(es->s_checkinterval) &&
1272 (le32_to_cpu(es->s_lastcheck) + 1310 (le32_to_cpu(es->s_lastcheck) +
1273 le32_to_cpu(es->s_checkinterval) <= get_seconds())) 1311 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
1274 printk (KERN_WARNING 1312 ext3_msg(sb, KERN_WARNING,
1275 "EXT3-fs warning: checktime reached, " 1313 "warning: checktime reached, "
1276 "running e2fsck is recommended\n"); 1314 "running e2fsck is recommended");
1277#if 0 1315#if 0
1278 /* @@@ We _will_ want to clear the valid bit if we find 1316 /* @@@ We _will_ want to clear the valid bit if we find
1279 inconsistencies, to force a fsck at reboot. But for 1317 inconsistencies, to force a fsck at reboot. But for
@@ -1290,22 +1328,20 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1290 1328
1291 ext3_commit_super(sb, es, 1); 1329 ext3_commit_super(sb, es, 1);
1292 if (test_opt(sb, DEBUG)) 1330 if (test_opt(sb, DEBUG))
1293 printk(KERN_INFO "[EXT3 FS bs=%lu, gc=%lu, " 1331 ext3_msg(sb, KERN_INFO, "[bs=%lu, gc=%lu, "
1294 "bpg=%lu, ipg=%lu, mo=%04lx]\n", 1332 "bpg=%lu, ipg=%lu, mo=%04lx]",
1295 sb->s_blocksize, 1333 sb->s_blocksize,
1296 sbi->s_groups_count, 1334 sbi->s_groups_count,
1297 EXT3_BLOCKS_PER_GROUP(sb), 1335 EXT3_BLOCKS_PER_GROUP(sb),
1298 EXT3_INODES_PER_GROUP(sb), 1336 EXT3_INODES_PER_GROUP(sb),
1299 sbi->s_mount_opt); 1337 sbi->s_mount_opt);
1300 1338
1301 printk(KERN_INFO "EXT3 FS on %s, ", sb->s_id);
1302 if (EXT3_SB(sb)->s_journal->j_inode == NULL) { 1339 if (EXT3_SB(sb)->s_journal->j_inode == NULL) {
1303 char b[BDEVNAME_SIZE]; 1340 char b[BDEVNAME_SIZE];
1304 1341 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)); 1342 bdevname(EXT3_SB(sb)->s_journal->j_dev, b));
1307 } else { 1343 } else {
1308 printk("internal journal\n"); 1344 ext3_msg(sb, KERN_INFO, "using internal journal");
1309 } 1345 }
1310 return res; 1346 return res;
1311} 1347}
@@ -1399,8 +1435,8 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1399 } 1435 }
1400 1436
1401 if (bdev_read_only(sb->s_bdev)) { 1437 if (bdev_read_only(sb->s_bdev)) {
1402 printk(KERN_ERR "EXT3-fs: write access " 1438 ext3_msg(sb, KERN_ERR, "error: write access "
1403 "unavailable, skipping orphan cleanup.\n"); 1439 "unavailable, skipping orphan cleanup.");
1404 return; 1440 return;
1405 } 1441 }
1406 1442
@@ -1414,8 +1450,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1414 } 1450 }
1415 1451
1416 if (s_flags & MS_RDONLY) { 1452 if (s_flags & MS_RDONLY) {
1417 printk(KERN_INFO "EXT3-fs: %s: orphan cleanup on readonly fs\n", 1453 ext3_msg(sb, KERN_INFO, "orphan cleanup on readonly fs");
1418 sb->s_id);
1419 sb->s_flags &= ~MS_RDONLY; 1454 sb->s_flags &= ~MS_RDONLY;
1420 } 1455 }
1421#ifdef CONFIG_QUOTA 1456#ifdef CONFIG_QUOTA
@@ -1426,9 +1461,9 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1426 if (EXT3_SB(sb)->s_qf_names[i]) { 1461 if (EXT3_SB(sb)->s_qf_names[i]) {
1427 int ret = ext3_quota_on_mount(sb, i); 1462 int ret = ext3_quota_on_mount(sb, i);
1428 if (ret < 0) 1463 if (ret < 0)
1429 printk(KERN_ERR 1464 ext3_msg(sb, KERN_ERR,
1430 "EXT3-fs: Cannot turn on journaled " 1465 "error: cannot turn on journaled "
1431 "quota: error %d\n", ret); 1466 "quota: %d", ret);
1432 } 1467 }
1433 } 1468 }
1434#endif 1469#endif
@@ -1466,11 +1501,11 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1466#define PLURAL(x) (x), ((x)==1) ? "" : "s" 1501#define PLURAL(x) (x), ((x)==1) ? "" : "s"
1467 1502
1468 if (nr_orphans) 1503 if (nr_orphans)
1469 printk(KERN_INFO "EXT3-fs: %s: %d orphan inode%s deleted\n", 1504 ext3_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
1470 sb->s_id, PLURAL(nr_orphans)); 1505 PLURAL(nr_orphans));
1471 if (nr_truncates) 1506 if (nr_truncates)
1472 printk(KERN_INFO "EXT3-fs: %s: %d truncate%s cleaned up\n", 1507 ext3_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
1473 sb->s_id, PLURAL(nr_truncates)); 1508 PLURAL(nr_truncates));
1474#ifdef CONFIG_QUOTA 1509#ifdef CONFIG_QUOTA
1475 /* Turn quotas off */ 1510 /* Turn quotas off */
1476 for (i = 0; i < MAXQUOTAS; i++) { 1511 for (i = 0; i < MAXQUOTAS; i++) {
@@ -1554,7 +1589,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1554 struct ext3_super_block *es = NULL; 1589 struct ext3_super_block *es = NULL;
1555 struct ext3_sb_info *sbi; 1590 struct ext3_sb_info *sbi;
1556 ext3_fsblk_t block; 1591 ext3_fsblk_t block;
1557 ext3_fsblk_t sb_block = get_sb_block(&data); 1592 ext3_fsblk_t sb_block = get_sb_block(&data, sb);
1558 ext3_fsblk_t logic_sb_block; 1593 ext3_fsblk_t logic_sb_block;
1559 unsigned long offset = 0; 1594 unsigned long offset = 0;
1560 unsigned int journal_inum = 0; 1595 unsigned int journal_inum = 0;
@@ -1590,7 +1625,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1590 1625
1591 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1626 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
1592 if (!blocksize) { 1627 if (!blocksize) {
1593 printk(KERN_ERR "EXT3-fs: unable to set blocksize\n"); 1628 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize");
1594 goto out_fail; 1629 goto out_fail;
1595 } 1630 }
1596 1631
@@ -1606,7 +1641,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1606 } 1641 }
1607 1642
1608 if (!(bh = sb_bread(sb, logic_sb_block))) { 1643 if (!(bh = sb_bread(sb, logic_sb_block))) {
1609 printk (KERN_ERR "EXT3-fs: unable to read superblock\n"); 1644 ext3_msg(sb, KERN_ERR, "error: unable to read superblock");
1610 goto out_fail; 1645 goto out_fail;
1611 } 1646 }
1612 /* 1647 /*
@@ -1665,9 +1700,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1665 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || 1700 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) ||
1666 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 1701 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
1667 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) 1702 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U)))
1668 printk(KERN_WARNING 1703 ext3_msg(sb, KERN_WARNING,
1669 "EXT3-fs warning: feature flags set on rev 0 fs, " 1704 "warning: feature flags set on rev 0 fs, "
1670 "running e2fsck is recommended\n"); 1705 "running e2fsck is recommended");
1671 /* 1706 /*
1672 * Check feature flags regardless of the revision level, since we 1707 * Check feature flags regardless of the revision level, since we
1673 * previously didn't change the revision level when setting the flags, 1708 * previously didn't change the revision level when setting the flags,
@@ -1675,25 +1710,25 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1675 */ 1710 */
1676 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP); 1711 features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP);
1677 if (features) { 1712 if (features) {
1678 printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " 1713 ext3_msg(sb, KERN_ERR,
1679 "unsupported optional features (%x).\n", 1714 "error: couldn't mount because of unsupported "
1680 sb->s_id, le32_to_cpu(features)); 1715 "optional features (%x)", le32_to_cpu(features));
1681 goto failed_mount; 1716 goto failed_mount;
1682 } 1717 }
1683 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP); 1718 features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP);
1684 if (!(sb->s_flags & MS_RDONLY) && features) { 1719 if (!(sb->s_flags & MS_RDONLY) && features) {
1685 printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " 1720 ext3_msg(sb, KERN_ERR,
1686 "unsupported optional features (%x).\n", 1721 "error: couldn't mount RDWR because of unsupported "
1687 sb->s_id, le32_to_cpu(features)); 1722 "optional features (%x)", le32_to_cpu(features));
1688 goto failed_mount; 1723 goto failed_mount;
1689 } 1724 }
1690 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 1725 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
1691 1726
1692 if (blocksize < EXT3_MIN_BLOCK_SIZE || 1727 if (blocksize < EXT3_MIN_BLOCK_SIZE ||
1693 blocksize > EXT3_MAX_BLOCK_SIZE) { 1728 blocksize > EXT3_MAX_BLOCK_SIZE) {
1694 printk(KERN_ERR 1729 ext3_msg(sb, KERN_ERR,
1695 "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", 1730 "error: couldn't mount because of unsupported "
1696 blocksize, sb->s_id); 1731 "filesystem blocksize %d", blocksize);
1697 goto failed_mount; 1732 goto failed_mount;
1698 } 1733 }
1699 1734
@@ -1704,30 +1739,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1704 * than the hardware sectorsize for the machine. 1739 * than the hardware sectorsize for the machine.
1705 */ 1740 */
1706 if (blocksize < hblock) { 1741 if (blocksize < hblock) {
1707 printk(KERN_ERR "EXT3-fs: blocksize %d too small for " 1742 ext3_msg(sb, KERN_ERR,
1708 "device blocksize %d.\n", blocksize, hblock); 1743 "error: fsblocksize %d too small for "
1744 "hardware sectorsize %d", blocksize, hblock);
1709 goto failed_mount; 1745 goto failed_mount;
1710 } 1746 }
1711 1747
1712 brelse (bh); 1748 brelse (bh);
1713 if (!sb_set_blocksize(sb, blocksize)) { 1749 if (!sb_set_blocksize(sb, blocksize)) {
1714 printk(KERN_ERR "EXT3-fs: bad blocksize %d.\n", 1750 ext3_msg(sb, KERN_ERR,
1715 blocksize); 1751 "error: bad blocksize %d", blocksize);
1716 goto out_fail; 1752 goto out_fail;
1717 } 1753 }
1718 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize; 1754 logic_sb_block = (sb_block * EXT3_MIN_BLOCK_SIZE) / blocksize;
1719 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; 1755 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize;
1720 bh = sb_bread(sb, logic_sb_block); 1756 bh = sb_bread(sb, logic_sb_block);
1721 if (!bh) { 1757 if (!bh) {
1722 printk(KERN_ERR 1758 ext3_msg(sb, KERN_ERR,
1723 "EXT3-fs: Can't read superblock on 2nd try.\n"); 1759 "error: can't read superblock on 2nd try");
1724 goto failed_mount; 1760 goto failed_mount;
1725 } 1761 }
1726 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); 1762 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset);
1727 sbi->s_es = es; 1763 sbi->s_es = es;
1728 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { 1764 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
1729 printk (KERN_ERR 1765 ext3_msg(sb, KERN_ERR,
1730 "EXT3-fs: Magic mismatch, very weird !\n"); 1766 "error: magic mismatch");
1731 goto failed_mount; 1767 goto failed_mount;
1732 } 1768 }
1733 } 1769 }
@@ -1743,8 +1779,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) || 1779 if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) ||
1744 (!is_power_of_2(sbi->s_inode_size)) || 1780 (!is_power_of_2(sbi->s_inode_size)) ||
1745 (sbi->s_inode_size > blocksize)) { 1781 (sbi->s_inode_size > blocksize)) {
1746 printk (KERN_ERR 1782 ext3_msg(sb, KERN_ERR,
1747 "EXT3-fs: unsupported inode size: %d\n", 1783 "error: unsupported inode size: %d",
1748 sbi->s_inode_size); 1784 sbi->s_inode_size);
1749 goto failed_mount; 1785 goto failed_mount;
1750 } 1786 }
@@ -1752,8 +1788,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1752 sbi->s_frag_size = EXT3_MIN_FRAG_SIZE << 1788 sbi->s_frag_size = EXT3_MIN_FRAG_SIZE <<
1753 le32_to_cpu(es->s_log_frag_size); 1789 le32_to_cpu(es->s_log_frag_size);
1754 if (blocksize != sbi->s_frag_size) { 1790 if (blocksize != sbi->s_frag_size) {
1755 printk(KERN_ERR 1791 ext3_msg(sb, KERN_ERR,
1756 "EXT3-fs: fragsize %lu != blocksize %u (unsupported)\n", 1792 "error: fragsize %lu != blocksize %u (unsupported)",
1757 sbi->s_frag_size, blocksize); 1793 sbi->s_frag_size, blocksize);
1758 goto failed_mount; 1794 goto failed_mount;
1759 } 1795 }
@@ -1789,31 +1825,31 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1789 } 1825 }
1790 1826
1791 if (sbi->s_blocks_per_group > blocksize * 8) { 1827 if (sbi->s_blocks_per_group > blocksize * 8) {
1792 printk (KERN_ERR 1828 ext3_msg(sb, KERN_ERR,
1793 "EXT3-fs: #blocks per group too big: %lu\n", 1829 "#blocks per group too big: %lu",
1794 sbi->s_blocks_per_group); 1830 sbi->s_blocks_per_group);
1795 goto failed_mount; 1831 goto failed_mount;
1796 } 1832 }
1797 if (sbi->s_frags_per_group > blocksize * 8) { 1833 if (sbi->s_frags_per_group > blocksize * 8) {
1798 printk (KERN_ERR 1834 ext3_msg(sb, KERN_ERR,
1799 "EXT3-fs: #fragments per group too big: %lu\n", 1835 "error: #fragments per group too big: %lu",
1800 sbi->s_frags_per_group); 1836 sbi->s_frags_per_group);
1801 goto failed_mount; 1837 goto failed_mount;
1802 } 1838 }
1803 if (sbi->s_inodes_per_group > blocksize * 8) { 1839 if (sbi->s_inodes_per_group > blocksize * 8) {
1804 printk (KERN_ERR 1840 ext3_msg(sb, KERN_ERR,
1805 "EXT3-fs: #inodes per group too big: %lu\n", 1841 "error: #inodes per group too big: %lu",
1806 sbi->s_inodes_per_group); 1842 sbi->s_inodes_per_group);
1807 goto failed_mount; 1843 goto failed_mount;
1808 } 1844 }
1809 1845
1810 if (le32_to_cpu(es->s_blocks_count) > 1846 if (le32_to_cpu(es->s_blocks_count) >
1811 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 1847 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
1812 printk(KERN_ERR "EXT3-fs: filesystem on %s:" 1848 ext3_msg(sb, KERN_ERR,
1813 " too large to mount safely\n", sb->s_id); 1849 "error: filesystem is too large to mount safely");
1814 if (sizeof(sector_t) < 8) 1850 if (sizeof(sector_t) < 8)
1815 printk(KERN_WARNING "EXT3-fs: CONFIG_LBDAF not " 1851 ext3_msg(sb, KERN_ERR,
1816 "enabled\n"); 1852 "error: CONFIG_LBDAF not enabled");
1817 goto failed_mount; 1853 goto failed_mount;
1818 } 1854 }
1819 1855
@@ -1827,7 +1863,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 *), 1863 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
1828 GFP_KERNEL); 1864 GFP_KERNEL);
1829 if (sbi->s_group_desc == NULL) { 1865 if (sbi->s_group_desc == NULL) {
1830 printk (KERN_ERR "EXT3-fs: not enough memory\n"); 1866 ext3_msg(sb, KERN_ERR,
1867 "error: not enough memory");
1831 goto failed_mount; 1868 goto failed_mount;
1832 } 1869 }
1833 1870
@@ -1837,14 +1874,15 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1837 block = descriptor_loc(sb, logic_sb_block, i); 1874 block = descriptor_loc(sb, logic_sb_block, i);
1838 sbi->s_group_desc[i] = sb_bread(sb, block); 1875 sbi->s_group_desc[i] = sb_bread(sb, block);
1839 if (!sbi->s_group_desc[i]) { 1876 if (!sbi->s_group_desc[i]) {
1840 printk (KERN_ERR "EXT3-fs: " 1877 ext3_msg(sb, KERN_ERR,
1841 "can't read group descriptor %d\n", i); 1878 "error: can't read group descriptor %d", i);
1842 db_count = i; 1879 db_count = i;
1843 goto failed_mount2; 1880 goto failed_mount2;
1844 } 1881 }
1845 } 1882 }
1846 if (!ext3_check_descriptors (sb)) { 1883 if (!ext3_check_descriptors (sb)) {
1847 printk(KERN_ERR "EXT3-fs: group descriptors corrupted!\n"); 1884 ext3_msg(sb, KERN_ERR,
1885 "error: group descriptors corrupted");
1848 goto failed_mount2; 1886 goto failed_mount2;
1849 } 1887 }
1850 sbi->s_gdb_count = db_count; 1888 sbi->s_gdb_count = db_count;
@@ -1862,7 +1900,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1862 ext3_count_dirs(sb)); 1900 ext3_count_dirs(sb));
1863 } 1901 }
1864 if (err) { 1902 if (err) {
1865 printk(KERN_ERR "EXT3-fs: insufficient memory\n"); 1903 ext3_msg(sb, KERN_ERR, "error: insufficient memory");
1866 goto failed_mount3; 1904 goto failed_mount3;
1867 } 1905 }
1868 1906
@@ -1910,9 +1948,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1910 goto failed_mount3; 1948 goto failed_mount3;
1911 } else { 1949 } else {
1912 if (!silent) 1950 if (!silent)
1913 printk (KERN_ERR 1951 ext3_msg(sb, KERN_ERR,
1914 "ext3: No journal on filesystem on %s\n", 1952 "error: no journal found. "
1915 sb->s_id); 1953 "mounting ext3 over ext2?");
1916 goto failed_mount3; 1954 goto failed_mount3;
1917 } 1955 }
1918 1956
@@ -1934,8 +1972,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1934 case EXT3_MOUNT_WRITEBACK_DATA: 1972 case EXT3_MOUNT_WRITEBACK_DATA:
1935 if (!journal_check_available_features 1973 if (!journal_check_available_features
1936 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { 1974 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) {
1937 printk(KERN_ERR "EXT3-fs: Journal does not support " 1975 ext3_msg(sb, KERN_ERR,
1938 "requested data journaling mode\n"); 1976 "error: journal does not support "
1977 "requested data journaling mode");
1939 goto failed_mount4; 1978 goto failed_mount4;
1940 } 1979 }
1941 default: 1980 default:
@@ -1944,8 +1983,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1944 1983
1945 if (test_opt(sb, NOBH)) { 1984 if (test_opt(sb, NOBH)) {
1946 if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) { 1985 if (!(test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)) {
1947 printk(KERN_WARNING "EXT3-fs: Ignoring nobh option - " 1986 ext3_msg(sb, KERN_WARNING,
1948 "its supported only with writeback mode\n"); 1987 "warning: ignoring nobh option - "
1988 "it is supported only with writeback mode");
1949 clear_opt(sbi->s_mount_opt, NOBH); 1989 clear_opt(sbi->s_mount_opt, NOBH);
1950 } 1990 }
1951 } 1991 }
@@ -1956,18 +1996,18 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1956 1996
1957 root = ext3_iget(sb, EXT3_ROOT_INO); 1997 root = ext3_iget(sb, EXT3_ROOT_INO);
1958 if (IS_ERR(root)) { 1998 if (IS_ERR(root)) {
1959 printk(KERN_ERR "EXT3-fs: get root inode failed\n"); 1999 ext3_msg(sb, KERN_ERR, "error: get root inode failed");
1960 ret = PTR_ERR(root); 2000 ret = PTR_ERR(root);
1961 goto failed_mount4; 2001 goto failed_mount4;
1962 } 2002 }
1963 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 2003 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1964 iput(root); 2004 iput(root);
1965 printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); 2005 ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
1966 goto failed_mount4; 2006 goto failed_mount4;
1967 } 2007 }
1968 sb->s_root = d_alloc_root(root); 2008 sb->s_root = d_alloc_root(root);
1969 if (!sb->s_root) { 2009 if (!sb->s_root) {
1970 printk(KERN_ERR "EXT3-fs: get root dentry failed\n"); 2010 ext3_msg(sb, KERN_ERR, "error: get root dentry failed");
1971 iput(root); 2011 iput(root);
1972 ret = -ENOMEM; 2012 ret = -ENOMEM;
1973 goto failed_mount4; 2013 goto failed_mount4;
@@ -1986,9 +2026,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1986 ext3_orphan_cleanup(sb, es); 2026 ext3_orphan_cleanup(sb, es);
1987 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; 2027 EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS;
1988 if (needs_recovery) 2028 if (needs_recovery)
1989 printk (KERN_INFO "EXT3-fs: recovery complete.\n"); 2029 ext3_msg(sb, KERN_INFO, "recovery complete");
1990 ext3_mark_recovery_complete(sb, es); 2030 ext3_mark_recovery_complete(sb, es);
1991 printk (KERN_INFO "EXT3-fs: mounted filesystem with %s data mode.\n", 2031 ext3_msg(sb, KERN_INFO, "mounted filesystem with %s data mode",
1992 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": 2032 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal":
1993 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2033 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
1994 "writeback"); 2034 "writeback");
@@ -1998,7 +2038,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1998 2038
1999cantfind_ext3: 2039cantfind_ext3:
2000 if (!silent) 2040 if (!silent)
2001 printk(KERN_ERR "VFS: Can't find ext3 filesystem on dev %s.\n", 2041 ext3_msg(sb, KERN_INFO,
2042 "error: can't find ext3 filesystem on dev %s.",
2002 sb->s_id); 2043 sb->s_id);
2003 goto failed_mount; 2044 goto failed_mount;
2004 2045
@@ -2066,27 +2107,27 @@ static journal_t *ext3_get_journal(struct super_block *sb,
2066 2107
2067 journal_inode = ext3_iget(sb, journal_inum); 2108 journal_inode = ext3_iget(sb, journal_inum);
2068 if (IS_ERR(journal_inode)) { 2109 if (IS_ERR(journal_inode)) {
2069 printk(KERN_ERR "EXT3-fs: no journal found.\n"); 2110 ext3_msg(sb, KERN_ERR, "error: no journal found");
2070 return NULL; 2111 return NULL;
2071 } 2112 }
2072 if (!journal_inode->i_nlink) { 2113 if (!journal_inode->i_nlink) {
2073 make_bad_inode(journal_inode); 2114 make_bad_inode(journal_inode);
2074 iput(journal_inode); 2115 iput(journal_inode);
2075 printk(KERN_ERR "EXT3-fs: journal inode is deleted.\n"); 2116 ext3_msg(sb, KERN_ERR, "error: journal inode is deleted");
2076 return NULL; 2117 return NULL;
2077 } 2118 }
2078 2119
2079 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 2120 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
2080 journal_inode, journal_inode->i_size); 2121 journal_inode, journal_inode->i_size);
2081 if (!S_ISREG(journal_inode->i_mode)) { 2122 if (!S_ISREG(journal_inode->i_mode)) {
2082 printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); 2123 ext3_msg(sb, KERN_ERR, "error: invalid journal inode");
2083 iput(journal_inode); 2124 iput(journal_inode);
2084 return NULL; 2125 return NULL;
2085 } 2126 }
2086 2127
2087 journal = journal_init_inode(journal_inode); 2128 journal = journal_init_inode(journal_inode);
2088 if (!journal) { 2129 if (!journal) {
2089 printk(KERN_ERR "EXT3-fs: Could not load journal inode\n"); 2130 ext3_msg(sb, KERN_ERR, "error: could not load journal inode");
2090 iput(journal_inode); 2131 iput(journal_inode);
2091 return NULL; 2132 return NULL;
2092 } 2133 }
@@ -2108,13 +2149,13 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2108 struct ext3_super_block * es; 2149 struct ext3_super_block * es;
2109 struct block_device *bdev; 2150 struct block_device *bdev;
2110 2151
2111 bdev = ext3_blkdev_get(j_dev); 2152 bdev = ext3_blkdev_get(j_dev, sb);
2112 if (bdev == NULL) 2153 if (bdev == NULL)
2113 return NULL; 2154 return NULL;
2114 2155
2115 if (bd_claim(bdev, sb)) { 2156 if (bd_claim(bdev, sb)) {
2116 printk(KERN_ERR 2157 ext3_msg(sb, KERN_ERR,
2117 "EXT3: failed to claim external journal device.\n"); 2158 "error: failed to claim external journal device");
2118 blkdev_put(bdev, FMODE_READ|FMODE_WRITE); 2159 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
2119 return NULL; 2160 return NULL;
2120 } 2161 }
@@ -2122,8 +2163,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2122 blocksize = sb->s_blocksize; 2163 blocksize = sb->s_blocksize;
2123 hblock = bdev_logical_block_size(bdev); 2164 hblock = bdev_logical_block_size(bdev);
2124 if (blocksize < hblock) { 2165 if (blocksize < hblock) {
2125 printk(KERN_ERR 2166 ext3_msg(sb, KERN_ERR,
2126 "EXT3-fs: blocksize too small for journal device.\n"); 2167 "error: blocksize too small for journal device");
2127 goto out_bdev; 2168 goto out_bdev;
2128 } 2169 }
2129 2170
@@ -2131,8 +2172,8 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2131 offset = EXT3_MIN_BLOCK_SIZE % blocksize; 2172 offset = EXT3_MIN_BLOCK_SIZE % blocksize;
2132 set_blocksize(bdev, blocksize); 2173 set_blocksize(bdev, blocksize);
2133 if (!(bh = __bread(bdev, sb_block, blocksize))) { 2174 if (!(bh = __bread(bdev, sb_block, blocksize))) {
2134 printk(KERN_ERR "EXT3-fs: couldn't read superblock of " 2175 ext3_msg(sb, KERN_ERR, "error: couldn't read superblock of "
2135 "external journal\n"); 2176 "external journal");
2136 goto out_bdev; 2177 goto out_bdev;
2137 } 2178 }
2138 2179
@@ -2140,14 +2181,14 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2140 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || 2181 if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) ||
2141 !(le32_to_cpu(es->s_feature_incompat) & 2182 !(le32_to_cpu(es->s_feature_incompat) &
2142 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { 2183 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
2143 printk(KERN_ERR "EXT3-fs: external journal has " 2184 ext3_msg(sb, KERN_ERR, "error: external journal has "
2144 "bad superblock\n"); 2185 "bad superblock");
2145 brelse(bh); 2186 brelse(bh);
2146 goto out_bdev; 2187 goto out_bdev;
2147 } 2188 }
2148 2189
2149 if (memcmp(EXT3_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { 2190 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"); 2191 ext3_msg(sb, KERN_ERR, "error: journal UUID does not match");
2151 brelse(bh); 2192 brelse(bh);
2152 goto out_bdev; 2193 goto out_bdev;
2153 } 2194 }
@@ -2159,19 +2200,21 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
2159 journal = journal_init_dev(bdev, sb->s_bdev, 2200 journal = journal_init_dev(bdev, sb->s_bdev,
2160 start, len, blocksize); 2201 start, len, blocksize);
2161 if (!journal) { 2202 if (!journal) {
2162 printk(KERN_ERR "EXT3-fs: failed to create device journal\n"); 2203 ext3_msg(sb, KERN_ERR,
2204 "error: failed to create device journal");
2163 goto out_bdev; 2205 goto out_bdev;
2164 } 2206 }
2165 journal->j_private = sb; 2207 journal->j_private = sb;
2166 ll_rw_block(READ, 1, &journal->j_sb_buffer); 2208 ll_rw_block(READ, 1, &journal->j_sb_buffer);
2167 wait_on_buffer(journal->j_sb_buffer); 2209 wait_on_buffer(journal->j_sb_buffer);
2168 if (!buffer_uptodate(journal->j_sb_buffer)) { 2210 if (!buffer_uptodate(journal->j_sb_buffer)) {
2169 printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); 2211 ext3_msg(sb, KERN_ERR, "I/O error on journal device");
2170 goto out_journal; 2212 goto out_journal;
2171 } 2213 }
2172 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { 2214 if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
2173 printk(KERN_ERR "EXT3-fs: External journal has more than one " 2215 ext3_msg(sb, KERN_ERR,
2174 "user (unsupported) - %d\n", 2216 "error: external journal has more than one "
2217 "user (unsupported) - %d",
2175 be32_to_cpu(journal->j_superblock->s_nr_users)); 2218 be32_to_cpu(journal->j_superblock->s_nr_users));
2176 goto out_journal; 2219 goto out_journal;
2177 } 2220 }
@@ -2197,8 +2240,8 @@ static int ext3_load_journal(struct super_block *sb,
2197 2240
2198 if (journal_devnum && 2241 if (journal_devnum &&
2199 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 2242 journal_devnum != le32_to_cpu(es->s_journal_dev)) {
2200 printk(KERN_INFO "EXT3-fs: external journal device major/minor " 2243 ext3_msg(sb, KERN_INFO, "external journal device major/minor "
2201 "numbers have changed\n"); 2244 "numbers have changed");
2202 journal_dev = new_decode_dev(journal_devnum); 2245 journal_dev = new_decode_dev(journal_devnum);
2203 } else 2246 } else
2204 journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev)); 2247 journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
@@ -2213,21 +2256,21 @@ static int ext3_load_journal(struct super_block *sb,
2213 2256
2214 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) { 2257 if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER)) {
2215 if (sb->s_flags & MS_RDONLY) { 2258 if (sb->s_flags & MS_RDONLY) {
2216 printk(KERN_INFO "EXT3-fs: INFO: recovery " 2259 ext3_msg(sb, KERN_INFO,
2217 "required on readonly filesystem.\n"); 2260 "recovery required on readonly filesystem");
2218 if (really_read_only) { 2261 if (really_read_only) {
2219 printk(KERN_ERR "EXT3-fs: write access " 2262 ext3_msg(sb, KERN_ERR, "error: write access "
2220 "unavailable, cannot proceed.\n"); 2263 "unavailable, cannot proceed");
2221 return -EROFS; 2264 return -EROFS;
2222 } 2265 }
2223 printk (KERN_INFO "EXT3-fs: write access will " 2266 ext3_msg(sb, KERN_INFO,
2224 "be enabled during recovery.\n"); 2267 "write access will be enabled during recovery");
2225 } 2268 }
2226 } 2269 }
2227 2270
2228 if (journal_inum && journal_dev) { 2271 if (journal_inum && journal_dev) {
2229 printk(KERN_ERR "EXT3-fs: filesystem has both journal " 2272 ext3_msg(sb, KERN_ERR, "error: filesystem has both journal "
2230 "and inode journals!\n"); 2273 "and inode journals");
2231 return -EINVAL; 2274 return -EINVAL;
2232 } 2275 }
2233 2276
@@ -2242,7 +2285,7 @@ static int ext3_load_journal(struct super_block *sb,
2242 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { 2285 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
2243 err = journal_update_format(journal); 2286 err = journal_update_format(journal);
2244 if (err) { 2287 if (err) {
2245 printk(KERN_ERR "EXT3-fs: error updating journal.\n"); 2288 ext3_msg(sb, KERN_ERR, "error updating journal");
2246 journal_destroy(journal); 2289 journal_destroy(journal);
2247 return err; 2290 return err;
2248 } 2291 }
@@ -2254,7 +2297,7 @@ static int ext3_load_journal(struct super_block *sb,
2254 err = journal_load(journal); 2297 err = journal_load(journal);
2255 2298
2256 if (err) { 2299 if (err) {
2257 printk(KERN_ERR "EXT3-fs: error loading journal.\n"); 2300 ext3_msg(sb, KERN_ERR, "error loading journal");
2258 journal_destroy(journal); 2301 journal_destroy(journal);
2259 return err; 2302 return err;
2260 } 2303 }
@@ -2273,16 +2316,17 @@ static int ext3_load_journal(struct super_block *sb,
2273 return 0; 2316 return 0;
2274} 2317}
2275 2318
2276static int ext3_create_journal(struct super_block * sb, 2319static int ext3_create_journal(struct super_block *sb,
2277 struct ext3_super_block * es, 2320 struct ext3_super_block *es,
2278 unsigned int journal_inum) 2321 unsigned int journal_inum)
2279{ 2322{
2280 journal_t *journal; 2323 journal_t *journal;
2281 int err; 2324 int err;
2282 2325
2283 if (sb->s_flags & MS_RDONLY) { 2326 if (sb->s_flags & MS_RDONLY) {
2284 printk(KERN_ERR "EXT3-fs: readonly filesystem when trying to " 2327 ext3_msg(sb, KERN_ERR,
2285 "create journal.\n"); 2328 "error: readonly filesystem when trying to "
2329 "create journal");
2286 return -EROFS; 2330 return -EROFS;
2287 } 2331 }
2288 2332
@@ -2290,12 +2334,12 @@ static int ext3_create_journal(struct super_block * sb,
2290 if (!journal) 2334 if (!journal)
2291 return -EINVAL; 2335 return -EINVAL;
2292 2336
2293 printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n", 2337 ext3_msg(sb, KERN_INFO, "creating new journal on inode %u",
2294 journal_inum); 2338 journal_inum);
2295 2339
2296 err = journal_create(journal); 2340 err = journal_create(journal);
2297 if (err) { 2341 if (err) {
2298 printk(KERN_ERR "EXT3-fs: error creating journal.\n"); 2342 ext3_msg(sb, KERN_ERR, "error creating journal");
2299 journal_destroy(journal); 2343 journal_destroy(journal);
2300 return -EIO; 2344 return -EIO;
2301 } 2345 }
@@ -2376,8 +2420,8 @@ out:
2376 * has recorded an error from a previous lifetime, move that error to the 2420 * has recorded an error from a previous lifetime, move that error to the
2377 * main filesystem now. 2421 * main filesystem now.
2378 */ 2422 */
2379static void ext3_clear_journal_err(struct super_block * sb, 2423static void ext3_clear_journal_err(struct super_block *sb,
2380 struct ext3_super_block * es) 2424 struct ext3_super_block *es)
2381{ 2425{
2382 journal_t *journal; 2426 journal_t *journal;
2383 int j_errno; 2427 int j_errno;
@@ -2568,10 +2612,10 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2568 __le32 ret; 2612 __le32 ret;
2569 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, 2613 if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
2570 ~EXT3_FEATURE_RO_COMPAT_SUPP))) { 2614 ~EXT3_FEATURE_RO_COMPAT_SUPP))) {
2571 printk(KERN_WARNING "EXT3-fs: %s: couldn't " 2615 ext3_msg(sb, KERN_WARNING,
2572 "remount RDWR because of unsupported " 2616 "warning: couldn't remount RDWR "
2573 "optional features (%x).\n", 2617 "because of unsupported optional "
2574 sb->s_id, le32_to_cpu(ret)); 2618 "features (%x)", le32_to_cpu(ret));
2575 err = -EROFS; 2619 err = -EROFS;
2576 goto restore_opts; 2620 goto restore_opts;
2577 } 2621 }
@@ -2582,11 +2626,10 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2582 * require a full umount/remount for now. 2626 * require a full umount/remount for now.
2583 */ 2627 */
2584 if (es->s_last_orphan) { 2628 if (es->s_last_orphan) {
2585 printk(KERN_WARNING "EXT3-fs: %s: couldn't " 2629 ext3_msg(sb, KERN_WARNING, "warning: couldn't "
2586 "remount RDWR because of unprocessed " 2630 "remount RDWR because of unprocessed "
2587 "orphan inode list. Please " 2631 "orphan inode list. Please "
2588 "umount/remount instead.\n", 2632 "umount/remount instead.");
2589 sb->s_id);
2590 err = -EINVAL; 2633 err = -EINVAL;
2591 goto restore_opts; 2634 goto restore_opts;
2592 } 2635 }
@@ -2686,13 +2729,11 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2686 buf->f_bsize = sb->s_blocksize; 2729 buf->f_bsize = sb->s_blocksize;
2687 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last; 2730 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); 2731 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); 2732 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)) 2733 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
2692 buf->f_bavail = 0; 2734 buf->f_bavail = 0;
2693 buf->f_files = le32_to_cpu(es->s_inodes_count); 2735 buf->f_files = le32_to_cpu(es->s_inodes_count);
2694 buf->f_ffree = percpu_counter_sum_positive(&sbi->s_freeinodes_counter); 2736 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; 2737 buf->f_namelen = EXT3_NAME_LEN;
2697 fsid = le64_to_cpup((void *)es->s_uuid) ^ 2738 fsid = le64_to_cpup((void *)es->s_uuid) ^
2698 le64_to_cpup((void *)es->s_uuid + sizeof(u64)); 2739 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
@@ -2837,9 +2878,9 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2837 if (EXT3_SB(sb)->s_qf_names[type]) { 2878 if (EXT3_SB(sb)->s_qf_names[type]) {
2838 /* Quotafile not of fs root? */ 2879 /* Quotafile not of fs root? */
2839 if (path.dentry->d_parent != sb->s_root) 2880 if (path.dentry->d_parent != sb->s_root)
2840 printk(KERN_WARNING 2881 ext3_msg(sb, KERN_WARNING,
2841 "EXT3-fs: Quota file not on filesystem root. " 2882 "warning: Quota file not on filesystem root. "
2842 "Journaled quota will not work.\n"); 2883 "Journaled quota will not work.");
2843 } 2884 }
2844 2885
2845 /* 2886 /*
@@ -2921,8 +2962,9 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
2921 handle_t *handle = journal_current_handle(); 2962 handle_t *handle = journal_current_handle();
2922 2963
2923 if (!handle) { 2964 if (!handle) {
2924 printk(KERN_WARNING "EXT3-fs: Quota write (off=%Lu, len=%Lu)" 2965 ext3_msg(sb, KERN_WARNING,
2925 " cancelled because transaction is not started.\n", 2966 "warning: quota write (off=%llu, len=%llu)"
2967 " cancelled because transaction is not started.",
2926 (unsigned long long)off, (unsigned long long)len); 2968 (unsigned long long)off, (unsigned long long)len);
2927 return -EIO; 2969 return -EIO;
2928 } 2970 }
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index 545e37c4b91e..387d92d00b97 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -960,6 +960,10 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
960 if (error) 960 if (error)
961 goto cleanup; 961 goto cleanup;
962 962
963 error = ext3_journal_get_write_access(handle, is.iloc.bh);
964 if (error)
965 goto cleanup;
966
963 if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { 967 if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) {
964 struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); 968 struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc);
965 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); 969 memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size);
@@ -985,9 +989,6 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
985 if (flags & XATTR_CREATE) 989 if (flags & XATTR_CREATE)
986 goto cleanup; 990 goto cleanup;
987 } 991 }
988 error = ext3_journal_get_write_access(handle, is.iloc.bh);
989 if (error)
990 goto cleanup;
991 if (!value) { 992 if (!value) {
992 if (!is.s.not_found) 993 if (!is.s.not_found)
993 error = ext3_xattr_ibody_set(handle, inode, &i, &is); 994 error = ext3_xattr_ibody_set(handle, inode, &i, &is);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8b58a144c31b..768c111a77ec 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -769,9 +769,22 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
769#if defined(CONFIG_QUOTA) 769#if defined(CONFIG_QUOTA)
770 struct ext4_sb_info *sbi = EXT4_SB(sb); 770 struct ext4_sb_info *sbi = EXT4_SB(sb);
771 771
772 if (sbi->s_jquota_fmt) 772 if (sbi->s_jquota_fmt) {
773 seq_printf(seq, ",jqfmt=%s", 773 char *fmtname = "";
774 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold" : "vfsv0"); 774
775 switch (sbi->s_jquota_fmt) {
776 case QFMT_VFS_OLD:
777 fmtname = "vfsold";
778 break;
779 case QFMT_VFS_V0:
780 fmtname = "vfsv0";
781 break;
782 case QFMT_VFS_V1:
783 fmtname = "vfsv1";
784 break;
785 }
786 seq_printf(seq, ",jqfmt=%s", fmtname);
787 }
775 788
776 if (sbi->s_qf_names[USRQUOTA]) 789 if (sbi->s_qf_names[USRQUOTA])
777 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]); 790 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
@@ -1084,9 +1097,9 @@ enum {
1084 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 1097 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
1085 Opt_data_err_abort, Opt_data_err_ignore, 1098 Opt_data_err_abort, Opt_data_err_ignore,
1086 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 1099 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
1087 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, 1100 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
1088 Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, 1101 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
1089 Opt_usrquota, Opt_grpquota, Opt_i_version, 1102 Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
1090 Opt_stripe, Opt_delalloc, Opt_nodelalloc, 1103 Opt_stripe, Opt_delalloc, Opt_nodelalloc,
1091 Opt_block_validity, Opt_noblock_validity, 1104 Opt_block_validity, Opt_noblock_validity,
1092 Opt_inode_readahead_blks, Opt_journal_ioprio, 1105 Opt_inode_readahead_blks, Opt_journal_ioprio,
@@ -1137,6 +1150,7 @@ static const match_table_t tokens = {
1137 {Opt_grpjquota, "grpjquota=%s"}, 1150 {Opt_grpjquota, "grpjquota=%s"},
1138 {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, 1151 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
1139 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, 1152 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
1153 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
1140 {Opt_grpquota, "grpquota"}, 1154 {Opt_grpquota, "grpquota"},
1141 {Opt_noquota, "noquota"}, 1155 {Opt_noquota, "noquota"},
1142 {Opt_quota, "quota"}, 1156 {Opt_quota, "quota"},
@@ -1439,6 +1453,9 @@ clear_qf_name:
1439 goto set_qf_format; 1453 goto set_qf_format;
1440 case Opt_jqfmt_vfsv0: 1454 case Opt_jqfmt_vfsv0:
1441 qfmt = QFMT_VFS_V0; 1455 qfmt = QFMT_VFS_V0;
1456 goto set_qf_format;
1457 case Opt_jqfmt_vfsv1:
1458 qfmt = QFMT_VFS_V1;
1442set_qf_format: 1459set_qf_format:
1443 if (sb_any_quota_loaded(sb) && 1460 if (sb_any_quota_loaded(sb) &&
1444 sbi->s_jquota_fmt != qfmt) { 1461 sbi->s_jquota_fmt != qfmt) {
@@ -1481,6 +1498,7 @@ set_qf_format:
1481 case Opt_offgrpjquota: 1498 case Opt_offgrpjquota:
1482 case Opt_jqfmt_vfsold: 1499 case Opt_jqfmt_vfsold:
1483 case Opt_jqfmt_vfsv0: 1500 case Opt_jqfmt_vfsv0:
1501 case Opt_jqfmt_vfsv1:
1484 ext4_msg(sb, KERN_ERR, 1502 ext4_msg(sb, KERN_ERR,
1485 "journaled quota options not supported"); 1503 "journaled quota options not supported");
1486 break; 1504 break;
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index defb932eee9a..0b3fa7974fa8 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -36,286 +36,323 @@ static void *zisofs_zlib_workspace;
36static DEFINE_MUTEX(zisofs_zlib_lock); 36static DEFINE_MUTEX(zisofs_zlib_lock);
37 37
38/* 38/*
39 * When decompressing, we typically obtain more than one page 39 * Read data of @inode from @block_start to @block_end and uncompress
40 * per reference. We inject the additional pages into the page 40 * to one zisofs block. Store the data in the @pages array with @pcount
41 * cache as a form of readahead. 41 * entries. Start storing at offset @poffset of the first page.
42 */ 42 */
43static int zisofs_readpage(struct file *file, struct page *page) 43static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,
44 loff_t block_end, int pcount,
45 struct page **pages, unsigned poffset,
46 int *errp)
44{ 47{
45 struct inode *inode = file->f_path.dentry->d_inode;
46 struct address_space *mapping = inode->i_mapping;
47 unsigned int maxpage, xpage, fpage, blockindex;
48 unsigned long offset;
49 unsigned long blockptr, blockendptr, cstart, cend, csize;
50 struct buffer_head *bh, *ptrbh[2];
51 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
52 unsigned int bufshift = ISOFS_BUFFER_BITS(inode);
53 unsigned long bufmask = bufsize - 1;
54 int err = -EIO;
55 int i;
56 unsigned int header_size = ISOFS_I(inode)->i_format_parm[0];
57 unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1]; 48 unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
58 /* unsigned long zisofs_block_size = 1UL << zisofs_block_shift; */ 49 unsigned int bufsize = ISOFS_BUFFER_SIZE(inode);
59 unsigned int zisofs_block_page_shift = zisofs_block_shift-PAGE_CACHE_SHIFT; 50 unsigned int bufshift = ISOFS_BUFFER_BITS(inode);
60 unsigned long zisofs_block_pages = 1UL << zisofs_block_page_shift; 51 unsigned int bufmask = bufsize - 1;
61 unsigned long zisofs_block_page_mask = zisofs_block_pages-1; 52 int i, block_size = block_end - block_start;
62 struct page *pages[zisofs_block_pages]; 53 z_stream stream = { .total_out = 0,
63 unsigned long index = page->index; 54 .avail_in = 0,
64 int indexblocks; 55 .avail_out = 0, };
65 56 int zerr;
66 /* We have already been given one page, this is the one 57 int needblocks = (block_size + (block_start & bufmask) + bufmask)
67 we must do. */ 58 >> bufshift;
68 xpage = index & zisofs_block_page_mask; 59 int haveblocks;
69 pages[xpage] = page; 60 blkcnt_t blocknum;
70 61 struct buffer_head *bhs[needblocks + 1];
71 /* The remaining pages need to be allocated and inserted */ 62 int curbh, curpage;
72 offset = index & ~zisofs_block_page_mask; 63
73 blockindex = offset >> zisofs_block_page_shift; 64 if (block_size > deflateBound(1UL << zisofs_block_shift)) {
74 maxpage = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 65 *errp = -EIO;
75
76 /*
77 * If this page is wholly outside i_size we just return zero;
78 * do_generic_file_read() will handle this for us
79 */
80 if (page->index >= maxpage) {
81 SetPageUptodate(page);
82 unlock_page(page);
83 return 0; 66 return 0;
84 } 67 }
85 68 /* Empty block? */
86 maxpage = min(zisofs_block_pages, maxpage-offset); 69 if (block_size == 0) {
87 70 for ( i = 0 ; i < pcount ; i++ ) {
88 for ( i = 0 ; i < maxpage ; i++, offset++ ) { 71 if (!pages[i])
89 if ( i != xpage ) { 72 continue;
90 pages[i] = grab_cache_page_nowait(mapping, offset); 73 memset(page_address(pages[i]), 0, PAGE_CACHE_SIZE);
91 } 74 flush_dcache_page(pages[i]);
92 page = pages[i]; 75 SetPageUptodate(pages[i]);
93 if ( page ) {
94 ClearPageError(page);
95 kmap(page);
96 } 76 }
77 return ((loff_t)pcount) << PAGE_CACHE_SHIFT;
97 } 78 }
98 79
99 /* This is the last page filled, plus one; used in case of abort. */ 80 /* Because zlib is not thread-safe, do all the I/O at the top. */
100 fpage = 0; 81 blocknum = block_start >> bufshift;
82 memset(bhs, 0, (needblocks + 1) * sizeof(struct buffer_head *));
83 haveblocks = isofs_get_blocks(inode, blocknum, bhs, needblocks);
84 ll_rw_block(READ, haveblocks, bhs);
101 85
102 /* Find the pointer to this specific chunk */ 86 curbh = 0;
103 /* Note: we're not using isonum_731() here because the data is known aligned */ 87 curpage = 0;
104 /* Note: header_size is in 32-bit words (4 bytes) */ 88 /*
105 blockptr = (header_size + blockindex) << 2; 89 * First block is special since it may be fractional. We also wait for
106 blockendptr = blockptr + 4; 90 * it before grabbing the zlib mutex; odds are that the subsequent
91 * blocks are going to come in in short order so we don't hold the zlib
92 * mutex longer than necessary.
93 */
107 94
108 indexblocks = ((blockptr^blockendptr) >> bufshift) ? 2 : 1; 95 if (!bhs[0])
109 ptrbh[0] = ptrbh[1] = NULL; 96 goto b_eio;
110 97
111 if ( isofs_get_blocks(inode, blockptr >> bufshift, ptrbh, indexblocks) != indexblocks ) { 98 wait_on_buffer(bhs[0]);
112 if ( ptrbh[0] ) brelse(ptrbh[0]); 99 if (!buffer_uptodate(bhs[0])) {
113 printk(KERN_DEBUG "zisofs: Null buffer on reading block table, inode = %lu, block = %lu\n", 100 *errp = -EIO;
114 inode->i_ino, blockptr >> bufshift); 101 goto b_eio;
115 goto eio;
116 }
117 ll_rw_block(READ, indexblocks, ptrbh);
118
119 bh = ptrbh[0];
120 if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) {
121 printk(KERN_DEBUG "zisofs: Failed to read block table, inode = %lu, block = %lu\n",
122 inode->i_ino, blockptr >> bufshift);
123 if ( ptrbh[1] )
124 brelse(ptrbh[1]);
125 goto eio;
126 }
127 cstart = le32_to_cpu(*(__le32 *)(bh->b_data + (blockptr & bufmask)));
128
129 if ( indexblocks == 2 ) {
130 /* We just crossed a block boundary. Switch to the next block */
131 brelse(bh);
132 bh = ptrbh[1];
133 if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) {
134 printk(KERN_DEBUG "zisofs: Failed to read block table, inode = %lu, block = %lu\n",
135 inode->i_ino, blockendptr >> bufshift);
136 goto eio;
137 }
138 } 102 }
139 cend = le32_to_cpu(*(__le32 *)(bh->b_data + (blockendptr & bufmask)));
140 brelse(bh);
141 103
142 if (cstart > cend) 104 stream.workspace = zisofs_zlib_workspace;
143 goto eio; 105 mutex_lock(&zisofs_zlib_lock);
144 106
145 csize = cend-cstart; 107 zerr = zlib_inflateInit(&stream);
146 108 if (zerr != Z_OK) {
147 if (csize > deflateBound(1UL << zisofs_block_shift)) 109 if (zerr == Z_MEM_ERROR)
148 goto eio; 110 *errp = -ENOMEM;
149 111 else
150 /* Now page[] contains an array of pages, any of which can be NULL, 112 *errp = -EIO;
151 and the locks on which we hold. We should now read the data and 113 printk(KERN_DEBUG "zisofs: zisofs_inflateInit returned %d\n",
152 release the pages. If the pages are NULL the decompressed data 114 zerr);
153 for that particular page should be discarded. */ 115 goto z_eio;
154 116 }
155 if ( csize == 0 ) { 117
156 /* This data block is empty. */ 118 while (curpage < pcount && curbh < haveblocks &&
157 119 zerr != Z_STREAM_END) {
158 for ( fpage = 0 ; fpage < maxpage ; fpage++ ) { 120 if (!stream.avail_out) {
159 if ( (page = pages[fpage]) != NULL ) { 121 if (pages[curpage]) {
160 memset(page_address(page), 0, PAGE_CACHE_SIZE); 122 stream.next_out = page_address(pages[curpage])
161 123 + poffset;
162 flush_dcache_page(page); 124 stream.avail_out = PAGE_CACHE_SIZE - poffset;
163 SetPageUptodate(page); 125 poffset = 0;
164 kunmap(page); 126 } else {
165 unlock_page(page); 127 stream.next_out = (void *)&zisofs_sink_page;
166 if ( fpage == xpage ) 128 stream.avail_out = PAGE_CACHE_SIZE;
167 err = 0; /* The critical page */
168 else
169 page_cache_release(page);
170 } 129 }
171 } 130 }
172 } else { 131 if (!stream.avail_in) {
173 /* This data block is compressed. */ 132 wait_on_buffer(bhs[curbh]);
174 z_stream stream; 133 if (!buffer_uptodate(bhs[curbh])) {
175 int bail = 0, left_out = -1; 134 *errp = -EIO;
176 int zerr; 135 break;
177 int needblocks = (csize + (cstart & bufmask) + bufmask) >> bufshift; 136 }
178 int haveblocks; 137 stream.next_in = bhs[curbh]->b_data +
179 struct buffer_head *bhs[needblocks+1]; 138 (block_start & bufmask);
180 struct buffer_head **bhptr; 139 stream.avail_in = min_t(unsigned, bufsize -
181 140 (block_start & bufmask),
182 /* Because zlib is not thread-safe, do all the I/O at the top. */ 141 block_size);
183 142 block_size -= stream.avail_in;
184 blockptr = cstart >> bufshift; 143 block_start = 0;
185 memset(bhs, 0, (needblocks+1)*sizeof(struct buffer_head *));
186 haveblocks = isofs_get_blocks(inode, blockptr, bhs, needblocks);
187 ll_rw_block(READ, haveblocks, bhs);
188
189 bhptr = &bhs[0];
190 bh = *bhptr++;
191
192 /* First block is special since it may be fractional.
193 We also wait for it before grabbing the zlib
194 mutex; odds are that the subsequent blocks are
195 going to come in in short order so we don't hold
196 the zlib mutex longer than necessary. */
197
198 if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) {
199 printk(KERN_DEBUG "zisofs: Hit null buffer, fpage = %d, xpage = %d, csize = %ld\n",
200 fpage, xpage, csize);
201 goto b_eio;
202 }
203 stream.next_in = bh->b_data + (cstart & bufmask);
204 stream.avail_in = min(bufsize-(cstart & bufmask), csize);
205 csize -= stream.avail_in;
206
207 stream.workspace = zisofs_zlib_workspace;
208 mutex_lock(&zisofs_zlib_lock);
209
210 zerr = zlib_inflateInit(&stream);
211 if ( zerr != Z_OK ) {
212 if ( err && zerr == Z_MEM_ERROR )
213 err = -ENOMEM;
214 printk(KERN_DEBUG "zisofs: zisofs_inflateInit returned %d\n",
215 zerr);
216 goto z_eio;
217 } 144 }
218 145
219 while ( !bail && fpage < maxpage ) { 146 while (stream.avail_out && stream.avail_in) {
220 page = pages[fpage]; 147 zerr = zlib_inflate(&stream, Z_SYNC_FLUSH);
221 if ( page ) 148 if (zerr == Z_BUF_ERROR && stream.avail_in == 0)
222 stream.next_out = page_address(page); 149 break;
223 else 150 if (zerr == Z_STREAM_END)
224 stream.next_out = (void *)&zisofs_sink_page; 151 break;
225 stream.avail_out = PAGE_CACHE_SIZE; 152 if (zerr != Z_OK) {
226 153 /* EOF, error, or trying to read beyond end of input */
227 while ( stream.avail_out ) { 154 if (zerr == Z_MEM_ERROR)
228 int ao, ai; 155 *errp = -ENOMEM;
229 if ( stream.avail_in == 0 && left_out ) { 156 else {
230 if ( !csize ) { 157 printk(KERN_DEBUG
231 printk(KERN_WARNING "zisofs: ZF read beyond end of input\n"); 158 "zisofs: zisofs_inflate returned"
232 bail = 1; 159 " %d, inode = %lu,"
233 break; 160 " page idx = %d, bh idx = %d,"
234 } else { 161 " avail_in = %d,"
235 bh = *bhptr++; 162 " avail_out = %d\n",
236 if ( !bh || 163 zerr, inode->i_ino, curpage,
237 (wait_on_buffer(bh), !buffer_uptodate(bh)) ) { 164 curbh, stream.avail_in,
238 /* Reached an EIO */ 165 stream.avail_out);
239 printk(KERN_DEBUG "zisofs: Hit null buffer, fpage = %d, xpage = %d, csize = %ld\n", 166 *errp = -EIO;
240 fpage, xpage, csize);
241
242 bail = 1;
243 break;
244 }
245 stream.next_in = bh->b_data;
246 stream.avail_in = min(csize,bufsize);
247 csize -= stream.avail_in;
248 }
249 }
250 ao = stream.avail_out; ai = stream.avail_in;
251 zerr = zlib_inflate(&stream, Z_SYNC_FLUSH);
252 left_out = stream.avail_out;
253 if ( zerr == Z_BUF_ERROR && stream.avail_in == 0 )
254 continue;
255 if ( zerr != Z_OK ) {
256 /* EOF, error, or trying to read beyond end of input */
257 if ( err && zerr == Z_MEM_ERROR )
258 err = -ENOMEM;
259 if ( zerr != Z_STREAM_END )
260 printk(KERN_DEBUG "zisofs: zisofs_inflate returned %d, inode = %lu, index = %lu, fpage = %d, xpage = %d, avail_in = %d, avail_out = %d, ai = %d, ao = %d\n",
261 zerr, inode->i_ino, index,
262 fpage, xpage,
263 stream.avail_in, stream.avail_out,
264 ai, ao);
265 bail = 1;
266 break;
267 } 167 }
168 goto inflate_out;
268 } 169 }
170 }
269 171
270 if ( stream.avail_out && zerr == Z_STREAM_END ) { 172 if (!stream.avail_out) {
271 /* Fractional page written before EOF. This may 173 /* This page completed */
272 be the last page in the file. */ 174 if (pages[curpage]) {
273 memset(stream.next_out, 0, stream.avail_out); 175 flush_dcache_page(pages[curpage]);
274 stream.avail_out = 0; 176 SetPageUptodate(pages[curpage]);
275 } 177 }
178 curpage++;
179 }
180 if (!stream.avail_in)
181 curbh++;
182 }
183inflate_out:
184 zlib_inflateEnd(&stream);
276 185
277 if ( !stream.avail_out ) { 186z_eio:
278 /* This page completed */ 187 mutex_unlock(&zisofs_zlib_lock);
279 if ( page ) { 188
280 flush_dcache_page(page); 189b_eio:
281 SetPageUptodate(page); 190 for (i = 0; i < haveblocks; i++)
282 kunmap(page); 191 brelse(bhs[i]);
283 unlock_page(page); 192 return stream.total_out;
284 if ( fpage == xpage ) 193}
285 err = 0; /* The critical page */ 194
286 else 195/*
287 page_cache_release(page); 196 * Uncompress data so that pages[full_page] is fully uptodate and possibly
288 } 197 * fills in other pages if we have data for them.
289 fpage++; 198 */
290 } 199static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,
200 struct page **pages)
201{
202 loff_t start_off, end_off;
203 loff_t block_start, block_end;
204 unsigned int header_size = ISOFS_I(inode)->i_format_parm[0];
205 unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
206 unsigned int blockptr;
207 loff_t poffset = 0;
208 blkcnt_t cstart_block, cend_block;
209 struct buffer_head *bh;
210 unsigned int blkbits = ISOFS_BUFFER_BITS(inode);
211 unsigned int blksize = 1 << blkbits;
212 int err;
213 loff_t ret;
214
215 BUG_ON(!pages[full_page]);
216
217 /*
218 * We want to read at least 'full_page' page. Because we have to
219 * uncompress the whole compression block anyway, fill the surrounding
220 * pages with the data we have anyway...
221 */
222 start_off = page_offset(pages[full_page]);
223 end_off = min_t(loff_t, start_off + PAGE_CACHE_SIZE, inode->i_size);
224
225 cstart_block = start_off >> zisofs_block_shift;
226 cend_block = (end_off + (1 << zisofs_block_shift) - 1)
227 >> zisofs_block_shift;
228
229 WARN_ON(start_off - (full_page << PAGE_CACHE_SHIFT) !=
230 ((cstart_block << zisofs_block_shift) & PAGE_CACHE_MASK));
231
232 /* Find the pointer to this specific chunk */
233 /* Note: we're not using isonum_731() here because the data is known aligned */
234 /* Note: header_size is in 32-bit words (4 bytes) */
235 blockptr = (header_size + cstart_block) << 2;
236 bh = isofs_bread(inode, blockptr >> blkbits);
237 if (!bh)
238 return -EIO;
239 block_start = le32_to_cpu(*(__le32 *)
240 (bh->b_data + (blockptr & (blksize - 1))));
241
242 while (cstart_block < cend_block && pcount > 0) {
243 /* Load end of the compressed block in the file */
244 blockptr += 4;
245 /* Traversed to next block? */
246 if (!(blockptr & (blksize - 1))) {
247 brelse(bh);
248
249 bh = isofs_bread(inode, blockptr >> blkbits);
250 if (!bh)
251 return -EIO;
252 }
253 block_end = le32_to_cpu(*(__le32 *)
254 (bh->b_data + (blockptr & (blksize - 1))));
255 if (block_start > block_end) {
256 brelse(bh);
257 return -EIO;
258 }
259 err = 0;
260 ret = zisofs_uncompress_block(inode, block_start, block_end,
261 pcount, pages, poffset, &err);
262 poffset += ret;
263 pages += poffset >> PAGE_CACHE_SHIFT;
264 pcount -= poffset >> PAGE_CACHE_SHIFT;
265 full_page -= poffset >> PAGE_CACHE_SHIFT;
266 poffset &= ~PAGE_CACHE_MASK;
267
268 if (err) {
269 brelse(bh);
270 /*
271 * Did we finish reading the page we really wanted
272 * to read?
273 */
274 if (full_page < 0)
275 return 0;
276 return err;
291 } 277 }
292 zlib_inflateEnd(&stream);
293 278
294 z_eio: 279 block_start = block_end;
295 mutex_unlock(&zisofs_zlib_lock); 280 cstart_block++;
281 }
282
283 if (poffset && *pages) {
284 memset(page_address(*pages) + poffset, 0,
285 PAGE_CACHE_SIZE - poffset);
286 flush_dcache_page(*pages);
287 SetPageUptodate(*pages);
288 }
289 return 0;
290}
296 291
297 b_eio: 292/*
298 for ( i = 0 ; i < haveblocks ; i++ ) { 293 * When decompressing, we typically obtain more than one page
299 if ( bhs[i] ) 294 * per reference. We inject the additional pages into the page
300 brelse(bhs[i]); 295 * cache as a form of readahead.
296 */
297static int zisofs_readpage(struct file *file, struct page *page)
298{
299 struct inode *inode = file->f_path.dentry->d_inode;
300 struct address_space *mapping = inode->i_mapping;
301 int err;
302 int i, pcount, full_page;
303 unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];
304 unsigned int zisofs_pages_per_cblock =
305 PAGE_CACHE_SHIFT <= zisofs_block_shift ?
306 (1 << (zisofs_block_shift - PAGE_CACHE_SHIFT)) : 0;
307 struct page *pages[max_t(unsigned, zisofs_pages_per_cblock, 1)];
308 pgoff_t index = page->index, end_index;
309
310 end_index = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
311 /*
312 * If this page is wholly outside i_size we just return zero;
313 * do_generic_file_read() will handle this for us
314 */
315 if (index >= end_index) {
316 SetPageUptodate(page);
317 unlock_page(page);
318 return 0;
319 }
320
321 if (PAGE_CACHE_SHIFT <= zisofs_block_shift) {
322 /* We have already been given one page, this is the one
323 we must do. */
324 full_page = index & (zisofs_pages_per_cblock - 1);
325 pcount = min_t(int, zisofs_pages_per_cblock,
326 end_index - (index & ~(zisofs_pages_per_cblock - 1)));
327 index -= full_page;
328 } else {
329 full_page = 0;
330 pcount = 1;
331 }
332 pages[full_page] = page;
333
334 for (i = 0; i < pcount; i++, index++) {
335 if (i != full_page)
336 pages[i] = grab_cache_page_nowait(mapping, index);
337 if (pages[i]) {
338 ClearPageError(pages[i]);
339 kmap(pages[i]);
301 } 340 }
302 } 341 }
303 342
304eio: 343 err = zisofs_fill_pages(inode, full_page, pcount, pages);
305 344
306 /* Release any residual pages, do not SetPageUptodate */ 345 /* Release any residual pages, do not SetPageUptodate */
307 while ( fpage < maxpage ) { 346 for (i = 0; i < pcount; i++) {
308 page = pages[fpage]; 347 if (pages[i]) {
309 if ( page ) { 348 flush_dcache_page(pages[i]);
310 flush_dcache_page(page); 349 if (i == full_page && err)
311 if ( fpage == xpage ) 350 SetPageError(pages[i]);
312 SetPageError(page); 351 kunmap(pages[i]);
313 kunmap(page); 352 unlock_page(pages[i]);
314 unlock_page(page); 353 if (i != full_page)
315 if ( fpage != xpage ) 354 page_cache_release(pages[i]);
316 page_cache_release(page);
317 } 355 }
318 fpage++;
319 } 356 }
320 357
321 /* At this point, err contains 0 or -EIO depending on the "critical" page */ 358 /* At this point, err contains 0 or -EIO depending on the "critical" page */
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index c2fb2dd0131f..96a685c550fd 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -518,8 +518,7 @@ repeat:
518 if (algo == SIG('p', 'z')) { 518 if (algo == SIG('p', 'z')) {
519 int block_shift = 519 int block_shift =
520 isonum_711(&rr->u.ZF.parms[1]); 520 isonum_711(&rr->u.ZF.parms[1]);
521 if (block_shift < PAGE_CACHE_SHIFT 521 if (block_shift > 17) {
522 || block_shift > 17) {
523 printk(KERN_WARNING "isofs: " 522 printk(KERN_WARNING "isofs: "
524 "Can't handle ZF block " 523 "Can't handle ZF block "
525 "size of 2^%d\n", 524 "size of 2^%d\n",
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 8896c1d4febe..6a10238d2c63 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -286,7 +286,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
286 if (err) { 286 if (err) {
287 /* 287 /*
288 * Because AS_EIO is cleared by 288 * Because AS_EIO is cleared by
289 * wait_on_page_writeback_range(), set it again so 289 * filemap_fdatawait_range(), set it again so
290 * that user process can get -EIO from fsync(). 290 * that user process can get -EIO from fsync().
291 */ 291 */
292 set_bit(AS_EIO, 292 set_bit(AS_EIO,
diff --git a/fs/namei.c b/fs/namei.c
index d3c190c35fcc..87f97ba90ad1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1656,6 +1656,15 @@ struct file *do_filp_open(int dfd, const char *pathname,
1656 int will_write; 1656 int will_write;
1657 int flag = open_to_namei_flags(open_flag); 1657 int flag = open_to_namei_flags(open_flag);
1658 1658
1659 /*
1660 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
1661 * check for O_DSYNC if the need any syncing at all we enforce it's
1662 * always set instead of having to deal with possibly weird behaviour
1663 * for malicious applications setting only __O_SYNC.
1664 */
1665 if (open_flag & __O_SYNC)
1666 open_flag |= O_DSYNC;
1667
1659 if (!acc_mode) 1668 if (!acc_mode)
1660 acc_mode = MAY_OPEN | ACC_MODE(flag); 1669 acc_mode = MAY_OPEN | ACC_MODE(flag);
1661 1670
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index f5fdd39e037a..6b891328f332 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -581,7 +581,7 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode)
581{ 581{
582 struct nfs_open_context *ctx; 582 struct nfs_open_context *ctx;
583 583
584 if (IS_SYNC(inode) || (filp->f_flags & O_SYNC)) 584 if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC))
585 return 1; 585 return 1;
586 ctx = nfs_file_open_context(filp); 586 ctx = nfs_file_open_context(filp);
587 if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags)) 587 if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags))
@@ -622,7 +622,7 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
622 622
623 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); 623 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
624 result = generic_file_aio_write(iocb, iov, nr_segs, pos); 624 result = generic_file_aio_write(iocb, iov, nr_segs, pos);
625 /* Return error values for O_SYNC and IS_SYNC() */ 625 /* Return error values for O_DSYNC and IS_SYNC() */
626 if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) { 626 if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) {
627 int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode); 627 int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode);
628 if (err < 0) 628 if (err < 0)
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index c84b5cc1a943..b1ce2ea9b93b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -774,7 +774,7 @@ int nfs_updatepage(struct file *file, struct page *page,
774 */ 774 */
775 if (nfs_write_pageuptodate(page, inode) && 775 if (nfs_write_pageuptodate(page, inode) &&
776 inode->i_flock == NULL && 776 inode->i_flock == NULL &&
777 !(file->f_flags & O_SYNC)) { 777 !(file->f_flags & O_DSYNC)) {
778 count = max(count + offset, nfs_page_length(page)); 778 count = max(count + offset, nfs_page_length(page));
779 offset = 0; 779 offset = 0;
780 } 780 }
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index de059f490586..3d30a1c974a8 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2006,7 +2006,7 @@ out_dio:
2006 /* buffered aio wouldn't have proper lock coverage today */ 2006 /* buffered aio wouldn't have proper lock coverage today */
2007 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); 2007 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
2008 2008
2009 if ((file->f_flags & O_SYNC && !direct_io) || IS_SYNC(inode)) { 2009 if ((file->f_flags & O_DSYNC && !direct_io) || IS_SYNC(inode)) {
2010 ret = filemap_fdatawrite_range(file->f_mapping, pos, 2010 ret = filemap_fdatawrite_range(file->f_mapping, pos,
2011 pos + count - 1); 2011 pos + count - 1);
2012 if (ret < 0) 2012 if (ret < 0)
diff --git a/fs/ocfs2/quota.h b/fs/ocfs2/quota.h
index e5df9d170b0c..123bc520a2c0 100644
--- a/fs/ocfs2/quota.h
+++ b/fs/ocfs2/quota.h
@@ -17,10 +17,6 @@
17 17
18#include "ocfs2.h" 18#include "ocfs2.h"
19 19
20/* Common stuff */
21/* id number of quota format */
22#define QFMT_OCFS2 3
23
24/* 20/*
25 * In-memory structures 21 * In-memory structures
26 */ 22 */
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 1a2c50a759fa..21f9e71223ca 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -1325,7 +1325,7 @@ out:
1325 return status; 1325 return status;
1326} 1326}
1327 1327
1328static struct quota_format_ops ocfs2_format_ops = { 1328static const struct quota_format_ops ocfs2_format_ops = {
1329 .check_quota_file = ocfs2_local_check_quota_file, 1329 .check_quota_file = ocfs2_local_check_quota_file,
1330 .read_file_info = ocfs2_local_read_info, 1330 .read_file_info = ocfs2_local_read_info,
1331 .write_file_info = ocfs2_global_write_info, 1331 .write_file_info = ocfs2_global_write_info,
diff --git a/fs/quota/Kconfig b/fs/quota/Kconfig
index 353e78a9ebee..efc02ebb8c70 100644
--- a/fs/quota/Kconfig
+++ b/fs/quota/Kconfig
@@ -46,12 +46,14 @@ config QFMT_V1
46 format say Y here. 46 format say Y here.
47 47
48config QFMT_V2 48config QFMT_V2
49 tristate "Quota format v2 support" 49 tristate "Quota format vfsv0 and vfsv1 support"
50 depends on QUOTA 50 depends on QUOTA
51 select QUOTA_TREE 51 select QUOTA_TREE
52 help 52 help
53 This quota format allows using quotas with 32-bit UIDs/GIDs. If you 53 This config option enables kernel support for vfsv0 and vfsv1 quota
54 need this functionality say Y here. 54 formats. Both these formats support 32-bit UIDs/GIDs and vfsv1 format
55 also supports 64-bit inode and block quota limits. If you need this
56 functionality say Y here.
55 57
56config QUOTACTL 58config QUOTACTL
57 bool 59 bool
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index eb5a755718f6..cd6bb9a33c13 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2164,7 +2164,9 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
2164 struct dentry *dentry; 2164 struct dentry *dentry;
2165 int error; 2165 int error;
2166 2166
2167 mutex_lock(&sb->s_root->d_inode->i_mutex);
2167 dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name)); 2168 dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name));
2169 mutex_unlock(&sb->s_root->d_inode->i_mutex);
2168 if (IS_ERR(dentry)) 2170 if (IS_ERR(dentry))
2169 return PTR_ERR(dentry); 2171 return PTR_ERR(dentry);
2170 2172
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index 0edcf42b1778..2ae757e9c008 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -204,7 +204,7 @@ out:
204 return ret; 204 return ret;
205} 205}
206 206
207static struct quota_format_ops v1_format_ops = { 207static const struct quota_format_ops v1_format_ops = {
208 .check_quota_file = v1_check_quota_file, 208 .check_quota_file = v1_check_quota_file,
209 .read_file_info = v1_read_file_info, 209 .read_file_info = v1_read_file_info,
210 .write_file_info = v1_write_file_info, 210 .write_file_info = v1_write_file_info,
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index a5475fb1ae44..3dfc23e02135 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -23,14 +23,23 @@ MODULE_LICENSE("GPL");
23 23
24#define __QUOTA_V2_PARANOIA 24#define __QUOTA_V2_PARANOIA
25 25
26static void v2_mem2diskdqb(void *dp, struct dquot *dquot); 26static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot);
27static void v2_disk2memdqb(struct dquot *dquot, void *dp); 27static void v2r0_disk2memdqb(struct dquot *dquot, void *dp);
28static int v2_is_id(void *dp, struct dquot *dquot); 28static int v2r0_is_id(void *dp, struct dquot *dquot);
29 29static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot);
30static struct qtree_fmt_operations v2_qtree_ops = { 30static void v2r1_disk2memdqb(struct dquot *dquot, void *dp);
31 .mem2disk_dqblk = v2_mem2diskdqb, 31static int v2r1_is_id(void *dp, struct dquot *dquot);
32 .disk2mem_dqblk = v2_disk2memdqb, 32
33 .is_id = v2_is_id, 33static struct qtree_fmt_operations v2r0_qtree_ops = {
34 .mem2disk_dqblk = v2r0_mem2diskdqb,
35 .disk2mem_dqblk = v2r0_disk2memdqb,
36 .is_id = v2r0_is_id,
37};
38
39static struct qtree_fmt_operations v2r1_qtree_ops = {
40 .mem2disk_dqblk = v2r1_mem2diskdqb,
41 .disk2mem_dqblk = v2r1_disk2memdqb,
42 .is_id = v2r1_is_id,
34}; 43};
35 44
36#define QUOTABLOCK_BITS 10 45#define QUOTABLOCK_BITS 10
@@ -46,23 +55,33 @@ static inline qsize_t v2_qbtos(qsize_t blocks)
46 return blocks << QUOTABLOCK_BITS; 55 return blocks << QUOTABLOCK_BITS;
47} 56}
48 57
58static int v2_read_header(struct super_block *sb, int type,
59 struct v2_disk_dqheader *dqhead)
60{
61 ssize_t size;
62
63 size = sb->s_op->quota_read(sb, type, (char *)dqhead,
64 sizeof(struct v2_disk_dqheader), 0);
65 if (size != sizeof(struct v2_disk_dqheader)) {
66 printk(KERN_WARNING "quota_v2: Failed header read:"
67 " expected=%zd got=%zd\n",
68 sizeof(struct v2_disk_dqheader), size);
69 return 0;
70 }
71 return 1;
72}
73
49/* Check whether given file is really vfsv0 quotafile */ 74/* Check whether given file is really vfsv0 quotafile */
50static int v2_check_quota_file(struct super_block *sb, int type) 75static int v2_check_quota_file(struct super_block *sb, int type)
51{ 76{
52 struct v2_disk_dqheader dqhead; 77 struct v2_disk_dqheader dqhead;
53 ssize_t size;
54 static const uint quota_magics[] = V2_INITQMAGICS; 78 static const uint quota_magics[] = V2_INITQMAGICS;
55 static const uint quota_versions[] = V2_INITQVERSIONS; 79 static const uint quota_versions[] = V2_INITQVERSIONS;
56 80
57 size = sb->s_op->quota_read(sb, type, (char *)&dqhead, 81 if (!v2_read_header(sb, type, &dqhead))
58 sizeof(struct v2_disk_dqheader), 0);
59 if (size != sizeof(struct v2_disk_dqheader)) {
60 printk("quota_v2: failed read expected=%zd got=%zd\n",
61 sizeof(struct v2_disk_dqheader), size);
62 return 0; 82 return 0;
63 }
64 if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] || 83 if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
65 le32_to_cpu(dqhead.dqh_version) != quota_versions[type]) 84 le32_to_cpu(dqhead.dqh_version) > quota_versions[type])
66 return 0; 85 return 0;
67 return 1; 86 return 1;
68} 87}
@@ -71,14 +90,20 @@ static int v2_check_quota_file(struct super_block *sb, int type)
71static int v2_read_file_info(struct super_block *sb, int type) 90static int v2_read_file_info(struct super_block *sb, int type)
72{ 91{
73 struct v2_disk_dqinfo dinfo; 92 struct v2_disk_dqinfo dinfo;
93 struct v2_disk_dqheader dqhead;
74 struct mem_dqinfo *info = sb_dqinfo(sb, type); 94 struct mem_dqinfo *info = sb_dqinfo(sb, type);
75 struct qtree_mem_dqinfo *qinfo; 95 struct qtree_mem_dqinfo *qinfo;
76 ssize_t size; 96 ssize_t size;
97 unsigned int version;
98
99 if (!v2_read_header(sb, type, &dqhead))
100 return 0;
101 version = le32_to_cpu(dqhead.dqh_version);
77 102
78 size = sb->s_op->quota_read(sb, type, (char *)&dinfo, 103 size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
79 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); 104 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
80 if (size != sizeof(struct v2_disk_dqinfo)) { 105 if (size != sizeof(struct v2_disk_dqinfo)) {
81 printk(KERN_WARNING "Can't read info structure on device %s.\n", 106 printk(KERN_WARNING "quota_v2: Can't read info structure on device %s.\n",
82 sb->s_id); 107 sb->s_id);
83 return -1; 108 return -1;
84 } 109 }
@@ -89,9 +114,15 @@ static int v2_read_file_info(struct super_block *sb, int type)
89 return -1; 114 return -1;
90 } 115 }
91 qinfo = info->dqi_priv; 116 qinfo = info->dqi_priv;
92 /* limits are stored as unsigned 32-bit data */ 117 if (version == 0) {
93 info->dqi_maxblimit = 0xffffffff; 118 /* limits are stored as unsigned 32-bit data */
94 info->dqi_maxilimit = 0xffffffff; 119 info->dqi_maxblimit = 0xffffffff;
120 info->dqi_maxilimit = 0xffffffff;
121 } else {
122 /* used space is stored as unsigned 64-bit value */
123 info->dqi_maxblimit = 0xffffffffffffffff; /* 2^64-1 */
124 info->dqi_maxilimit = 0xffffffffffffffff;
125 }
95 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); 126 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
96 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); 127 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
97 info->dqi_flags = le32_to_cpu(dinfo.dqi_flags); 128 info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
@@ -103,8 +134,13 @@ static int v2_read_file_info(struct super_block *sb, int type)
103 qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS; 134 qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
104 qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS; 135 qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
105 qinfo->dqi_qtree_depth = qtree_depth(qinfo); 136 qinfo->dqi_qtree_depth = qtree_depth(qinfo);
106 qinfo->dqi_entry_size = sizeof(struct v2_disk_dqblk); 137 if (version == 0) {
107 qinfo->dqi_ops = &v2_qtree_ops; 138 qinfo->dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
139 qinfo->dqi_ops = &v2r0_qtree_ops;
140 } else {
141 qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
142 qinfo->dqi_ops = &v2r1_qtree_ops;
143 }
108 return 0; 144 return 0;
109} 145}
110 146
@@ -135,9 +171,9 @@ static int v2_write_file_info(struct super_block *sb, int type)
135 return 0; 171 return 0;
136} 172}
137 173
138static void v2_disk2memdqb(struct dquot *dquot, void *dp) 174static void v2r0_disk2memdqb(struct dquot *dquot, void *dp)
139{ 175{
140 struct v2_disk_dqblk *d = dp, empty; 176 struct v2r0_disk_dqblk *d = dp, empty;
141 struct mem_dqblk *m = &dquot->dq_dqb; 177 struct mem_dqblk *m = &dquot->dq_dqb;
142 178
143 m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit); 179 m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit);
@@ -149,15 +185,15 @@ static void v2_disk2memdqb(struct dquot *dquot, void *dp)
149 m->dqb_curspace = le64_to_cpu(d->dqb_curspace); 185 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
150 m->dqb_btime = le64_to_cpu(d->dqb_btime); 186 m->dqb_btime = le64_to_cpu(d->dqb_btime);
151 /* We need to escape back all-zero structure */ 187 /* We need to escape back all-zero structure */
152 memset(&empty, 0, sizeof(struct v2_disk_dqblk)); 188 memset(&empty, 0, sizeof(struct v2r0_disk_dqblk));
153 empty.dqb_itime = cpu_to_le64(1); 189 empty.dqb_itime = cpu_to_le64(1);
154 if (!memcmp(&empty, dp, sizeof(struct v2_disk_dqblk))) 190 if (!memcmp(&empty, dp, sizeof(struct v2r0_disk_dqblk)))
155 m->dqb_itime = 0; 191 m->dqb_itime = 0;
156} 192}
157 193
158static void v2_mem2diskdqb(void *dp, struct dquot *dquot) 194static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot)
159{ 195{
160 struct v2_disk_dqblk *d = dp; 196 struct v2r0_disk_dqblk *d = dp;
161 struct mem_dqblk *m = &dquot->dq_dqb; 197 struct mem_dqblk *m = &dquot->dq_dqb;
162 struct qtree_mem_dqinfo *info = 198 struct qtree_mem_dqinfo *info =
163 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 199 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
@@ -175,9 +211,60 @@ static void v2_mem2diskdqb(void *dp, struct dquot *dquot)
175 d->dqb_itime = cpu_to_le64(1); 211 d->dqb_itime = cpu_to_le64(1);
176} 212}
177 213
178static int v2_is_id(void *dp, struct dquot *dquot) 214static int v2r0_is_id(void *dp, struct dquot *dquot)
215{
216 struct v2r0_disk_dqblk *d = dp;
217 struct qtree_mem_dqinfo *info =
218 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
219
220 if (qtree_entry_unused(info, dp))
221 return 0;
222 return le32_to_cpu(d->dqb_id) == dquot->dq_id;
223}
224
225static void v2r1_disk2memdqb(struct dquot *dquot, void *dp)
226{
227 struct v2r1_disk_dqblk *d = dp, empty;
228 struct mem_dqblk *m = &dquot->dq_dqb;
229
230 m->dqb_ihardlimit = le64_to_cpu(d->dqb_ihardlimit);
231 m->dqb_isoftlimit = le64_to_cpu(d->dqb_isoftlimit);
232 m->dqb_curinodes = le64_to_cpu(d->dqb_curinodes);
233 m->dqb_itime = le64_to_cpu(d->dqb_itime);
234 m->dqb_bhardlimit = v2_qbtos(le64_to_cpu(d->dqb_bhardlimit));
235 m->dqb_bsoftlimit = v2_qbtos(le64_to_cpu(d->dqb_bsoftlimit));
236 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
237 m->dqb_btime = le64_to_cpu(d->dqb_btime);
238 /* We need to escape back all-zero structure */
239 memset(&empty, 0, sizeof(struct v2r1_disk_dqblk));
240 empty.dqb_itime = cpu_to_le64(1);
241 if (!memcmp(&empty, dp, sizeof(struct v2r1_disk_dqblk)))
242 m->dqb_itime = 0;
243}
244
245static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
246{
247 struct v2r1_disk_dqblk *d = dp;
248 struct mem_dqblk *m = &dquot->dq_dqb;
249 struct qtree_mem_dqinfo *info =
250 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
251
252 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
253 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
254 d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
255 d->dqb_itime = cpu_to_le64(m->dqb_itime);
256 d->dqb_bhardlimit = cpu_to_le64(v2_stoqb(m->dqb_bhardlimit));
257 d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit));
258 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
259 d->dqb_btime = cpu_to_le64(m->dqb_btime);
260 d->dqb_id = cpu_to_le32(dquot->dq_id);
261 if (qtree_entry_unused(info, dp))
262 d->dqb_itime = cpu_to_le64(1);
263}
264
265static int v2r1_is_id(void *dp, struct dquot *dquot)
179{ 266{
180 struct v2_disk_dqblk *d = dp; 267 struct v2r1_disk_dqblk *d = dp;
181 struct qtree_mem_dqinfo *info = 268 struct qtree_mem_dqinfo *info =
182 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 269 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
183 270
@@ -207,7 +294,7 @@ static int v2_free_file_info(struct super_block *sb, int type)
207 return 0; 294 return 0;
208} 295}
209 296
210static struct quota_format_ops v2_format_ops = { 297static const struct quota_format_ops v2_format_ops = {
211 .check_quota_file = v2_check_quota_file, 298 .check_quota_file = v2_check_quota_file,
212 .read_file_info = v2_read_file_info, 299 .read_file_info = v2_read_file_info,
213 .write_file_info = v2_write_file_info, 300 .write_file_info = v2_write_file_info,
@@ -217,20 +304,32 @@ static struct quota_format_ops v2_format_ops = {
217 .release_dqblk = v2_release_dquot, 304 .release_dqblk = v2_release_dquot,
218}; 305};
219 306
220static struct quota_format_type v2_quota_format = { 307static struct quota_format_type v2r0_quota_format = {
221 .qf_fmt_id = QFMT_VFS_V0, 308 .qf_fmt_id = QFMT_VFS_V0,
222 .qf_ops = &v2_format_ops, 309 .qf_ops = &v2_format_ops,
223 .qf_owner = THIS_MODULE 310 .qf_owner = THIS_MODULE
224}; 311};
225 312
313static struct quota_format_type v2r1_quota_format = {
314 .qf_fmt_id = QFMT_VFS_V1,
315 .qf_ops = &v2_format_ops,
316 .qf_owner = THIS_MODULE
317};
318
226static int __init init_v2_quota_format(void) 319static int __init init_v2_quota_format(void)
227{ 320{
228 return register_quota_format(&v2_quota_format); 321 int ret;
322
323 ret = register_quota_format(&v2r0_quota_format);
324 if (ret)
325 return ret;
326 return register_quota_format(&v2r1_quota_format);
229} 327}
230 328
231static void __exit exit_v2_quota_format(void) 329static void __exit exit_v2_quota_format(void)
232{ 330{
233 unregister_quota_format(&v2_quota_format); 331 unregister_quota_format(&v2r0_quota_format);
332 unregister_quota_format(&v2r1_quota_format);
234} 333}
235 334
236module_init(init_v2_quota_format); 335module_init(init_v2_quota_format);
diff --git a/fs/quota/quotaio_v2.h b/fs/quota/quotaio_v2.h
index 530fe580685c..f1966b42c2fd 100644
--- a/fs/quota/quotaio_v2.h
+++ b/fs/quota/quotaio_v2.h
@@ -17,8 +17,8 @@
17} 17}
18 18
19#define V2_INITQVERSIONS {\ 19#define V2_INITQVERSIONS {\
20 0, /* USRQUOTA */\ 20 1, /* USRQUOTA */\
21 0 /* GRPQUOTA */\ 21 1 /* GRPQUOTA */\
22} 22}
23 23
24/* First generic header */ 24/* First generic header */
@@ -32,7 +32,7 @@ struct v2_disk_dqheader {
32 * (as it appears on disk) - the file is a radix tree whose leaves point 32 * (as it appears on disk) - the file is a radix tree whose leaves point
33 * to blocks of these structures. 33 * to blocks of these structures.
34 */ 34 */
35struct v2_disk_dqblk { 35struct v2r0_disk_dqblk {
36 __le32 dqb_id; /* id this quota applies to */ 36 __le32 dqb_id; /* id this quota applies to */
37 __le32 dqb_ihardlimit; /* absolute limit on allocated inodes */ 37 __le32 dqb_ihardlimit; /* absolute limit on allocated inodes */
38 __le32 dqb_isoftlimit; /* preferred inode limit */ 38 __le32 dqb_isoftlimit; /* preferred inode limit */
@@ -44,6 +44,19 @@ struct v2_disk_dqblk {
44 __le64 dqb_itime; /* time limit for excessive inode use */ 44 __le64 dqb_itime; /* time limit for excessive inode use */
45}; 45};
46 46
47struct v2r1_disk_dqblk {
48 __le32 dqb_id; /* id this quota applies to */
49 __le32 dqb_pad;
50 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
51 __le64 dqb_isoftlimit; /* preferred inode limit */
52 __le64 dqb_curinodes; /* current # allocated inodes */
53 __le64 dqb_bhardlimit; /* absolute limit on disk space (in QUOTABLOCK_SIZE) */
54 __le64 dqb_bsoftlimit; /* preferred limit on disk space (in QUOTABLOCK_SIZE) */
55 __le64 dqb_curspace; /* current space occupied (in bytes) */
56 __le64 dqb_btime; /* time limit for excessive disk use */
57 __le64 dqb_itime; /* time limit for excessive inode use */
58};
59
47/* Header with type and version specific information */ 60/* Header with type and version specific information */
48struct v2_disk_dqinfo { 61struct v2_disk_dqinfo {
49 __le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */ 62 __le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */
diff --git a/fs/sync.c b/fs/sync.c
index d104591b066b..36752a683481 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -295,10 +295,11 @@ SYSCALL_DEFINE1(fdatasync, unsigned int, fd)
295 */ 295 */
296int generic_write_sync(struct file *file, loff_t pos, loff_t count) 296int generic_write_sync(struct file *file, loff_t pos, loff_t count)
297{ 297{
298 if (!(file->f_flags & O_SYNC) && !IS_SYNC(file->f_mapping->host)) 298 if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host))
299 return 0; 299 return 0;
300 return vfs_fsync_range(file, file->f_path.dentry, pos, 300 return vfs_fsync_range(file, file->f_path.dentry, pos,
301 pos + count - 1, 1); 301 pos + count - 1,
302 (file->f_flags & __O_SYNC) ? 0 : 1);
302} 303}
303EXPORT_SYMBOL(generic_write_sync); 304EXPORT_SYMBOL(generic_write_sync);
304 305
@@ -452,9 +453,7 @@ int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
452 453
453 ret = 0; 454 ret = 0;
454 if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { 455 if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
455 ret = wait_on_page_writeback_range(mapping, 456 ret = filemap_fdatawait_range(mapping, offset, endbyte);
456 offset >> PAGE_CACHE_SHIFT,
457 endbyte >> PAGE_CACHE_SHIFT);
458 if (ret < 0) 457 if (ret < 0)
459 goto out; 458 goto out;
460 } 459 }
@@ -467,9 +466,7 @@ int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
467 } 466 }
468 467
469 if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { 468 if (flags & SYNC_FILE_RANGE_WAIT_AFTER) {
470 ret = wait_on_page_writeback_range(mapping, 469 ret = filemap_fdatawait_range(mapping, offset, endbyte);
471 offset >> PAGE_CACHE_SHIFT,
472 endbyte >> PAGE_CACHE_SHIFT);
473 } 470 }
474out: 471out:
475 return ret; 472 return ret;
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 78dbfcd5eec2..1bf47f219c97 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -806,7 +806,7 @@ write_retry:
806 XFS_STATS_ADD(xs_write_bytes, ret); 806 XFS_STATS_ADD(xs_write_bytes, ret);
807 807
808 /* Handle various SYNC-type writes */ 808 /* Handle various SYNC-type writes */
809 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { 809 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
810 loff_t end = pos + ret - 1; 810 loff_t end = pos + ret - 1;
811 int error2; 811 int error2;
812 812