diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-23 19:47:49 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-23 19:47:49 -0400 |
commit | d561c025ee3a0aee53a225bedce0ee35fe12f335 (patch) | |
tree | df73aa103723162c3a980104ae204f93e91c9caa /fs/btrfs | |
parent | 7f5c15160e1436a53d01f9190db11c2a3a4d788a (diff) |
Btrfs: very minimal locking
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 1 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 5 | ||||
-rw-r--r-- | fs/btrfs/super.c | 26 |
4 files changed, 22 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 96cec6352f12..68cafae6a850 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -231,6 +231,7 @@ struct btrfs_fs_info { | |||
231 | struct buffer_head *sb_buffer; | 231 | struct buffer_head *sb_buffer; |
232 | struct super_block *sb; | 232 | struct super_block *sb; |
233 | struct mutex trans_mutex; | 233 | struct mutex trans_mutex; |
234 | struct mutex fs_mutex; | ||
234 | }; | 235 | }; |
235 | 236 | ||
236 | /* | 237 | /* |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3dea757d4cbb..e32ddff55b0e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -116,6 +116,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
116 | fs_info->sb_buffer = sb_buffer; | 116 | fs_info->sb_buffer = sb_buffer; |
117 | fs_info->sb = sb; | 117 | fs_info->sb = sb; |
118 | mutex_init(&fs_info->trans_mutex); | 118 | mutex_init(&fs_info->trans_mutex); |
119 | mutex_init(&fs_info->fs_mutex); | ||
119 | memset(&fs_info->current_insert, 0, sizeof(fs_info->current_insert)); | 120 | memset(&fs_info->current_insert, 0, sizeof(fs_info->current_insert)); |
120 | memset(&fs_info->last_insert, 0, sizeof(fs_info->last_insert)); | 121 | memset(&fs_info->last_insert, 0, sizeof(fs_info->last_insert)); |
121 | 122 | ||
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index c86f0e6152f2..9583a9ae8b79 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -168,9 +168,10 @@ static int pin_down_block(struct btrfs_root *root, u64 blocknr, int tag) | |||
168 | BUG_ON(!bh); | 168 | BUG_ON(!bh); |
169 | err = radix_tree_insert(&root->fs_info->pinned_radix, | 169 | err = radix_tree_insert(&root->fs_info->pinned_radix, |
170 | blocknr, bh); | 170 | blocknr, bh); |
171 | BUG_ON(err); | 171 | if (err && err != -EEXIST) { |
172 | if (err) | 172 | BUG(); |
173 | return err; | 173 | return err; |
174 | } | ||
174 | radix_tree_tag_set(&root->fs_info->pinned_radix, blocknr, | 175 | radix_tree_tag_set(&root->fs_info->pinned_radix, blocknr, |
175 | tag); | 176 | tag); |
176 | return 0; | 177 | return 0; |
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); |
466 | out_unlock: | ||
467 | mutex_unlock(&root->fs_info->fs_mutex); | ||
465 | return err; | 468 | return err; |
466 | } | 469 | } |
467 | 470 | ||
468 | static void btrfs_write_super(struct super_block *sb) | ||
469 | { | ||
470 | sb->s_dirt = 0; | ||
471 | printk("btrfs write_super!\n"); | ||
472 | filemap_flush(sb->s_bdev->bd_inode->i_mapping); | ||
473 | } | ||
474 | |||
475 | static int btrfs_sync_fs(struct super_block *sb, int wait) | 471 | static 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); |
489 | printk("btrfs sync_fs\n"); | 490 | printk("btrfs sync_fs\n"); |
491 | mutex_unlock(&root->fs_info->fs_mutex); | ||
490 | return 0; | 492 | return 0; |
491 | } | 493 | } |
492 | 494 | ||
495 | static void btrfs_write_super(struct super_block *sb) | ||
496 | { | ||
497 | btrfs_sync_fs(sb, 1); | ||
498 | } | ||
499 | |||
500 | |||
493 | static int btrfs_get_sb(struct file_system_type *fs_type, | 501 | static 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 | { |