GFS2: Ensure uptodate inode size when using O_APPEND
[safe/jmp/linux-2.6] / fs / sysv / inode.c
index 425c976..9824743 100644 (file)
@@ -21,7 +21,6 @@
  *  the superblock.
  */
 
-#include <linux/smp_lock.h>
 #include <linux/highuid.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <asm/byteorder.h>
 #include "sysv.h"
 
-/* This is only called on sync() and umount(), when s_dirt=1. */
-static void sysv_write_super(struct super_block *sb)
+static int sysv_sync_fs(struct super_block *sb, int wait)
 {
        struct sysv_sb_info *sbi = SYSV_SB(sb);
        unsigned long time = get_seconds(), old_time;
 
        lock_super(sb);
-       lock_kernel();
-       if (sb->s_flags & MS_RDONLY)
-               goto clean;
 
        /*
         * If we are going to write out the super block,
@@ -54,10 +49,18 @@ static void sysv_write_super(struct super_block *sb)
                *sbi->s_sb_time = cpu_to_fs32(sbi, time);
                mark_buffer_dirty(sbi->s_bh2);
        }
-clean:
-       sb->s_dirt = 0;
-       unlock_kernel();
+
        unlock_super(sb);
+
+       return 0;
+}
+
+static void sysv_write_super(struct super_block *sb)
+{
+       if (!(sb->s_flags & MS_RDONLY))
+               sysv_sync_fs(sb, 1);
+       else
+               sb->s_dirt = 0;
 }
 
 static int sysv_remount(struct super_block *sb, int *flags, char *data)
@@ -76,8 +79,6 @@ static void sysv_put_super(struct super_block *sb)
 {
        struct sysv_sb_info *sbi = SYSV_SB(sb);
 
-       lock_kernel();
-
        if (sb->s_dirt)
                sysv_write_super(sb);
 
@@ -93,8 +94,6 @@ static void sysv_put_super(struct super_block *sb)
                brelse(sbi->s_bh2);
 
        kfree(sbi);
-
-       unlock_kernel();
 }
 
 static int sysv_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -269,7 +268,6 @@ int sysv_write_inode(struct inode *inode, int wait)
                return -EIO;
        }
 
-       lock_kernel();
        raw_inode->i_mode = cpu_to_fs16(sbi, inode->i_mode);
        raw_inode->i_uid = cpu_to_fs16(sbi, fs_high2lowuid(inode->i_uid));
        raw_inode->i_gid = cpu_to_fs16(sbi, fs_high2lowgid(inode->i_gid));
@@ -285,7 +283,6 @@ int sysv_write_inode(struct inode *inode, int wait)
        for (block = 0; block < 10+1+1+1; block++)
                write3byte(sbi, (u8 *)&si->i_data[block],
                        &raw_inode->i_data[3*block]);
-       unlock_kernel();
        mark_buffer_dirty(bh);
        if (wait) {
                 sync_dirty_buffer(bh);
@@ -309,9 +306,7 @@ static void sysv_delete_inode(struct inode *inode)
        truncate_inode_pages(&inode->i_data, 0);
        inode->i_size = 0;
        sysv_truncate(inode);
-       lock_kernel();
        sysv_free_inode(inode);
-       unlock_kernel();
 }
 
 static struct kmem_cache *sysv_inode_cachep;
@@ -345,6 +340,7 @@ const struct super_operations sysv_sops = {
        .delete_inode   = sysv_delete_inode,
        .put_super      = sysv_put_super,
        .write_super    = sysv_write_super,
+       .sync_fs        = sysv_sync_fs,
        .remount_fs     = sysv_remount,
        .statfs         = sysv_statfs,
 };