aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
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,
453 struct inode *inode; 453 struct inode *inode;
454 int err; 454 int err;
455 455
456 mutex_lock(&root->fs_info->fs_mutex);
456 trans = btrfs_start_transaction(root, 1); 457 trans = btrfs_start_transaction(root, 1);
457 inode = btrfs_new_inode(trans, dir, mode); 458 inode = btrfs_new_inode(trans, dir, mode);
458 err = PTR_ERR(inode); 459 err = PTR_ERR(inode);
459 if (IS_ERR(inode)) 460 if (IS_ERR(inode))
460 return err; 461 goto out_unlock;
461 // FIXME mark the inode dirty 462 // FIXME mark the inode dirty
462 err = btrfs_add_nondir(trans, dentry, inode); 463 err = btrfs_add_nondir(trans, dentry, inode);
463 dir->i_sb->s_dirt = 1; 464 dir->i_sb->s_dirt = 1;
464 btrfs_end_transaction(trans, root); 465 btrfs_end_transaction(trans, root);
466out_unlock:
467 mutex_unlock(&root->fs_info->fs_mutex);
465 return err; 468 return err;
466} 469}
467 470
468static void btrfs_write_super(struct super_block *sb)
469{
470 sb->s_dirt = 0;
471printk("btrfs write_super!\n");
472 filemap_flush(sb->s_bdev->bd_inode->i_mapping);
473}
474
475static int btrfs_sync_fs(struct super_block *sb, int wait) 471static int btrfs_sync_fs(struct super_block *sb, int wait)
476{ 472{
477 struct btrfs_trans_handle *trans; 473 struct btrfs_trans_handle *trans;
@@ -479,17 +475,29 @@ static int btrfs_sync_fs(struct super_block *sb, int wait)
479 int ret; 475 int ret;
480 476
481 sb->s_dirt = 0; 477 sb->s_dirt = 0;
482 return 0; 478 if (!wait) {
479 filemap_flush(sb->s_bdev->bd_inode->i_mapping);
480 return 0;
481 }
482 filemap_write_and_wait(sb->s_bdev->bd_inode->i_mapping);
483 483
484 root = btrfs_sb(sb); 484 root = btrfs_sb(sb);
485 mutex_lock(&root->fs_info->fs_mutex);
485 trans = btrfs_start_transaction(root, 1); 486 trans = btrfs_start_transaction(root, 1);
486 ret = btrfs_commit_transaction(trans, root); 487 ret = btrfs_commit_transaction(trans, root);
487 sb->s_dirt = 0; 488 sb->s_dirt = 0;
488 BUG_ON(ret); 489 BUG_ON(ret);
489printk("btrfs sync_fs\n"); 490printk("btrfs sync_fs\n");
491 mutex_unlock(&root->fs_info->fs_mutex);
490 return 0; 492 return 0;
491} 493}
492 494
495static void btrfs_write_super(struct super_block *sb)
496{
497 btrfs_sync_fs(sb, 1);
498}
499
500
493static int btrfs_get_sb(struct file_system_type *fs_type, 501static int btrfs_get_sb(struct file_system_type *fs_type,
494 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 502 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
495{ 503{