aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2008-08-04 23:23:47 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:06 -0400
commitb48652c101cce7a54379a49cc0cf854cec2c94e2 (patch)
tree13e8250b326b71fed80811e1ed3b19b00beded31 /fs/btrfs
parent3de9d6b649b4cc60687be92e71cef36d7d4e8f2f (diff)
Btrfs: Various small fixes.
This trivial patch contains two locking fixes and a off by one fix. --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ordered-data.c4
-rw-r--r--fs/btrfs/root-tree.c3
-rw-r--r--fs/btrfs/super.c2
-rw-r--r--fs/btrfs/transaction.c9
-rw-r--r--fs/btrfs/transaction.h3
5 files changed, 11 insertions, 10 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 676e4bd65c52..db200e6baf7e 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -548,7 +548,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
548 */ 548 */
549 test = rb_entry(node, struct btrfs_ordered_extent, rb_node); 549 test = rb_entry(node, struct btrfs_ordered_extent, rb_node);
550 if (test->file_offset > entry_end(ordered)) { 550 if (test->file_offset > entry_end(ordered)) {
551 i_size_test = test->file_offset - 1; 551 i_size_test = test->file_offset;
552 } 552 }
553 } else { 553 } else {
554 i_size_test = i_size_read(inode); 554 i_size_test = i_size_read(inode);
@@ -561,7 +561,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
561 * disk_i_size to the end of the region. 561 * disk_i_size to the end of the region.
562 */ 562 */
563 if (i_size_test > entry_end(ordered) && 563 if (i_size_test > entry_end(ordered) &&
564 !test_range_bit(io_tree, entry_end(ordered), i_size_test, 564 !test_range_bit(io_tree, entry_end(ordered), i_size_test - 1,
565 EXTENT_DELALLOC, 0)) { 565 EXTENT_DELALLOC, 0)) {
566 new_i_size = min_t(u64, i_size_test, i_size_read(inode)); 566 new_i_size = min_t(u64, i_size_test, i_size_read(inode));
567 } 567 }
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index a5c0e98b5aeb..36726696e58b 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -209,8 +209,7 @@ again:
209 goto err; 209 goto err;
210 } 210 }
211 211
212 ret = btrfs_add_dead_root(dead_root, latest, 212 ret = btrfs_add_dead_root(dead_root, latest);
213 &root->fs_info->dead_roots);
214 if (ret) 213 if (ret)
215 goto err; 214 goto err;
216 goto again; 215 goto again;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a6a418b6894b..eb4b357d05e1 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -449,7 +449,9 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
449 s->s_flags |= MS_ACTIVE; 449 s->s_flags |= MS_ACTIVE;
450 } 450 }
451 451
452 mutex_lock(&s->s_root->d_inode->i_mutex);
452 root = lookup_one_len(subvol_name, s->s_root, strlen(subvol_name)); 453 root = lookup_one_len(subvol_name, s->s_root, strlen(subvol_name));
454 mutex_unlock(&s->s_root->d_inode->i_mutex);
453 if (IS_ERR(root)) { 455 if (IS_ERR(root)) {
454 up_write(&s->s_umount); 456 up_write(&s->s_umount);
455 deactivate_super(s); 457 deactivate_super(s);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index a2c821e3c3a7..ebf5362da1d2 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -389,9 +389,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
389 return 0; 389 return 0;
390} 390}
391 391
392int btrfs_add_dead_root(struct btrfs_root *root, 392int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest)
393 struct btrfs_root *latest,
394 struct list_head *dead_list)
395{ 393{
396 struct btrfs_dirty_root *dirty; 394 struct btrfs_dirty_root *dirty;
397 395
@@ -400,7 +398,10 @@ int btrfs_add_dead_root(struct btrfs_root *root,
400 return -ENOMEM; 398 return -ENOMEM;
401 dirty->root = root; 399 dirty->root = root;
402 dirty->latest_root = latest; 400 dirty->latest_root = latest;
403 list_add(&dirty->list, dead_list); 401
402 mutex_lock(&root->fs_info->trans_mutex);
403 list_add(&dirty->list, &latest->fs_info->dead_roots);
404 mutex_unlock(&root->fs_info->trans_mutex);
404 return 0; 405 return 0;
405} 406}
406 407
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 2c73caeebb2c..598baa312417 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -90,8 +90,7 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
90int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, 90int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
91 struct btrfs_root *root); 91 struct btrfs_root *root);
92 92
93int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest, 93int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest);
94 struct list_head *dead_list);
95int btrfs_defrag_root(struct btrfs_root *root, int cacheonly); 94int btrfs_defrag_root(struct btrfs_root *root, int cacheonly);
96int btrfs_clean_old_snapshots(struct btrfs_root *root); 95int btrfs_clean_old_snapshots(struct btrfs_root *root);
97int btrfs_commit_transaction(struct btrfs_trans_handle *trans, 96int btrfs_commit_transaction(struct btrfs_trans_handle *trans,