Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[safe/jmp/linux-2.6] / fs / ext3 / super.c
index 6900ff0..4a97041 100644 (file)
@@ -48,8 +48,8 @@ static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
                             unsigned long journal_devnum);
 static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
                               unsigned int);
-static void ext3_commit_super (struct super_block * sb,
-                              struct ext3_super_block * es,
+static int ext3_commit_super(struct super_block *sb,
+                              struct ext3_super_block *es,
                               int sync);
 static void ext3_mark_recovery_complete(struct super_block * sb,
                                        struct ext3_super_block * es);
@@ -60,9 +60,9 @@ static const char *ext3_decode_error(struct super_block * sb, int errno,
                                     char nbuf[16]);
 static int ext3_remount (struct super_block * sb, int * flags, char * data);
 static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf);
-static void ext3_unlockfs(struct super_block *sb);
+static int ext3_unfreeze(struct super_block *sb);
 static void ext3_write_super (struct super_block * sb);
-static void ext3_write_super_lockfs(struct super_block *sb);
+static int ext3_freeze(struct super_block *sb);
 
 /*
  * Wrappers for journal_start/end.
@@ -439,6 +439,7 @@ static void ext3_put_super (struct super_block * sb)
                ext3_blkdev_remove(sbi);
        }
        sb->s_fs_info = NULL;
+       kfree(sbi->s_blockgroup_lock);
        kfree(sbi);
        return;
 }
@@ -733,7 +734,9 @@ static struct dquot_operations ext3_quota_operations = {
        .acquire_dquot  = ext3_acquire_dquot,
        .release_dquot  = ext3_release_dquot,
        .mark_dirty     = ext3_mark_dquot_dirty,
-       .write_info     = ext3_write_info
+       .write_info     = ext3_write_info,
+       .alloc_dquot    = dquot_alloc,
+       .destroy_dquot  = dquot_destroy,
 };
 
 static struct quotactl_ops ext3_qctl_operations = {
@@ -756,8 +759,8 @@ static const struct super_operations ext3_sops = {
        .put_super      = ext3_put_super,
        .write_super    = ext3_write_super,
        .sync_fs        = ext3_sync_fs,
-       .write_super_lockfs = ext3_write_super_lockfs,
-       .unlockfs       = ext3_unlockfs,
+       .freeze_fs      = ext3_freeze,
+       .unfreeze_fs    = ext3_unfreeze,
        .statfs         = ext3_statfs,
        .remount_fs     = ext3_remount,
        .clear_inode    = ext3_clear_inode,
@@ -1056,8 +1059,7 @@ static int parse_options (char *options, struct super_block *sb,
                case Opt_grpjquota:
                        qtype = GRPQUOTA;
 set_qf_name:
-                       if ((sb_any_quota_enabled(sb) ||
-                            sb_any_quota_suspended(sb)) &&
+                       if (sb_any_quota_loaded(sb) &&
                            !sbi->s_qf_names[qtype]) {
                                printk(KERN_ERR
                                        "EXT3-fs: Cannot change journaled "
@@ -1096,8 +1098,7 @@ set_qf_name:
                case Opt_offgrpjquota:
                        qtype = GRPQUOTA;
 clear_qf_name:
-                       if ((sb_any_quota_enabled(sb) ||
-                            sb_any_quota_suspended(sb)) &&
+                       if (sb_any_quota_loaded(sb) &&
                            sbi->s_qf_names[qtype]) {
                                printk(KERN_ERR "EXT3-fs: Cannot change "
                                        "journaled quota options when "
@@ -1116,8 +1117,7 @@ clear_qf_name:
                case Opt_jqfmt_vfsv0:
                        qfmt = QFMT_VFS_V0;
 set_qf_format:
-                       if ((sb_any_quota_enabled(sb) ||
-                            sb_any_quota_suspended(sb)) &&
+                       if (sb_any_quota_loaded(sb) &&
                            sbi->s_jquota_fmt != qfmt) {
                                printk(KERN_ERR "EXT3-fs: Cannot change "
                                        "journaled quota options when "
@@ -1136,8 +1136,7 @@ set_qf_format:
                        set_opt(sbi->s_mount_opt, GRPQUOTA);
                        break;
                case Opt_noquota:
-                       if (sb_any_quota_enabled(sb) ||
-                           sb_any_quota_suspended(sb)) {
+                       if (sb_any_quota_loaded(sb)) {
                                printk(KERN_ERR "EXT3-fs: Cannot change quota "
                                        "options when quota turned on.\n");
                                return 0;
@@ -1569,6 +1568,13 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
        sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
+
+       sbi->s_blockgroup_lock =
+               kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
+       if (!sbi->s_blockgroup_lock) {
+               kfree(sbi);
+               return -ENOMEM;
+       }
        sb->s_fs_info = sbi;
        sbi->s_mount_opt = 0;
        sbi->s_resuid = EXT3_DEF_RESUID;
@@ -1821,7 +1827,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
                goto failed_mount;
        }
 
-       bgl_lock_init(&sbi->s_blockgroup_lock);
+       bgl_lock_init(sbi->s_blockgroup_lock);
 
        for (i = 0; i < db_count; i++) {
                block = descriptor_loc(sb, logic_sb_block, i);
@@ -2305,21 +2311,23 @@ static int ext3_create_journal(struct super_block * sb,
        return 0;
 }
 
-static void ext3_commit_super (struct super_block * sb,
-                              struct ext3_super_block * es,
+static int ext3_commit_super(struct super_block *sb,
+                              struct ext3_super_block *es,
                               int sync)
 {
        struct buffer_head *sbh = EXT3_SB(sb)->s_sbh;
+       int error = 0;
 
        if (!sbh)
-               return;
+               return error;
        es->s_wtime = cpu_to_le32(get_seconds());
        es->s_free_blocks_count = cpu_to_le32(ext3_count_free_blocks(sb));
        es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb));
        BUFFER_TRACE(sbh, "marking dirty");
        mark_buffer_dirty(sbh);
        if (sync)
-               sync_dirty_buffer(sbh);
+               error = sync_dirty_buffer(sbh);
+       return error;
 }
 
 
@@ -2420,12 +2428,13 @@ static void ext3_write_super (struct super_block * sb)
 
 static int ext3_sync_fs(struct super_block *sb, int wait)
 {
-       sb->s_dirt = 0;
-       if (wait)
-               ext3_force_commit(sb);
-       else
-               journal_start_commit(EXT3_SB(sb)->s_journal, NULL);
+       tid_t target;
 
+       sb->s_dirt = 0;
+       if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) {
+               if (wait)
+                       log_wait_commit(EXT3_SB(sb)->s_journal, target);
+       }
        return 0;
 }
 
@@ -2433,12 +2442,14 @@ static int ext3_sync_fs(struct super_block *sb, int wait)
  * LVM calls this function before a (read-only) snapshot is created.  This
  * gives us a chance to flush the journal completely and mark the fs clean.
  */
-static void ext3_write_super_lockfs(struct super_block *sb)
+static int ext3_freeze(struct super_block *sb)
 {
+       int error = 0;
+       journal_t *journal;
        sb->s_dirt = 0;
 
        if (!(sb->s_flags & MS_RDONLY)) {
-               journal_t *journal = EXT3_SB(sb)->s_journal;
+               journal = EXT3_SB(sb)->s_journal;
 
                /* Now we set up the journal barrier. */
                journal_lock_updates(journal);
@@ -2447,20 +2458,28 @@ static void ext3_write_super_lockfs(struct super_block *sb)
                 * We don't want to clear needs_recovery flag when we failed
                 * to flush the journal.
                 */
-               if (journal_flush(journal) < 0)
-                       return;
+               error = journal_flush(journal);
+               if (error < 0)
+                       goto out;
 
                /* Journal blocked and flushed, clear needs_recovery flag. */
                EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
-               ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1);
+               error = ext3_commit_super(sb, EXT3_SB(sb)->s_es, 1);
+               if (error)
+                       goto out;
        }
+       return 0;
+
+out:
+       journal_unlock_updates(journal);
+       return error;
 }
 
 /*
  * Called by LVM after the snapshot is done.  We need to reset the RECOVER
  * flag here, even though the filesystem is not technically dirty yet.
  */
-static void ext3_unlockfs(struct super_block *sb)
+static int ext3_unfreeze(struct super_block *sb)
 {
        if (!(sb->s_flags & MS_RDONLY)) {
                lock_super(sb);
@@ -2470,6 +2489,7 @@ static void ext3_unlockfs(struct super_block *sb)
                unlock_super(sb);
                journal_unlock_updates(EXT3_SB(sb)->s_journal);
        }
+       return 0;
 }
 
 static int ext3_remount (struct super_block * sb, int * flags, char * data)