summaryrefslogtreecommitdiff
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-23 19:47:49 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-23 19:47:49 -0400
commitd561c025ee3a0aee53a225bedce0ee35fe12f335 (patch)
treedf73aa103723162c3a980104ae204f93e91c9caa /fs/btrfs/super.c
parent7f5c15160e1436a53d01f9190db11c2a3a4d788a (diff)
downloadlwn-d561c025ee3a0aee53a225bedce0ee35fe12f335.tar.gz
lwn-d561c025ee3a0aee53a225bedce0ee35fe12f335.zip
Btrfs: very minimal locking
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a2db05594695..0ca1080e0198 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -453,25 +453,21 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
struct inode *inode;
int err;
+ mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
inode = btrfs_new_inode(trans, dir, mode);
err = PTR_ERR(inode);
if (IS_ERR(inode))
- return err;
+ goto out_unlock;
// FIXME mark the inode dirty
err = btrfs_add_nondir(trans, dentry, inode);
dir->i_sb->s_dirt = 1;
btrfs_end_transaction(trans, root);
+out_unlock:
+ mutex_unlock(&root->fs_info->fs_mutex);
return err;
}
-static void btrfs_write_super(struct super_block *sb)
-{
- sb->s_dirt = 0;
-printk("btrfs write_super!\n");
- filemap_flush(sb->s_bdev->bd_inode->i_mapping);
-}
-
static int btrfs_sync_fs(struct super_block *sb, int wait)
{
struct btrfs_trans_handle *trans;
@@ -479,17 +475,29 @@ static int btrfs_sync_fs(struct super_block *sb, int wait)
int ret;
sb->s_dirt = 0;
- return 0;
+ if (!wait) {
+ filemap_flush(sb->s_bdev->bd_inode->i_mapping);
+ return 0;
+ }
+ filemap_write_and_wait(sb->s_bdev->bd_inode->i_mapping);
root = btrfs_sb(sb);
+ mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
ret = btrfs_commit_transaction(trans, root);
sb->s_dirt = 0;
BUG_ON(ret);
printk("btrfs sync_fs\n");
+ mutex_unlock(&root->fs_info->fs_mutex);
return 0;
}
+static void btrfs_write_super(struct super_block *sb)
+{
+ btrfs_sync_fs(sb, 1);
+}
+
+
static int btrfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{