Skip to content

Commit

Permalink
Btrfs: Various small fixes.
Browse files Browse the repository at this point in the history
This trivial patch contains two locking fixes and a off by one fix.

---

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Yan Zheng authored and Chris Mason committed Sep 25, 2008
1 parent 3de9d6b commit b48652c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/ordered-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
*/
test = rb_entry(node, struct btrfs_ordered_extent, rb_node);
if (test->file_offset > entry_end(ordered)) {
i_size_test = test->file_offset - 1;
i_size_test = test->file_offset;
}
} else {
i_size_test = i_size_read(inode);
Expand All @@ -561,7 +561,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
* disk_i_size to the end of the region.
*/
if (i_size_test > entry_end(ordered) &&
!test_range_bit(io_tree, entry_end(ordered), i_size_test,
!test_range_bit(io_tree, entry_end(ordered), i_size_test - 1,
EXTENT_DELALLOC, 0)) {
new_i_size = min_t(u64, i_size_test, i_size_read(inode));
}
Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/root-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
goto err;
}

ret = btrfs_add_dead_root(dead_root, latest,
&root->fs_info->dead_roots);
ret = btrfs_add_dead_root(dead_root, latest);
if (ret)
goto err;
goto again;
Expand Down
2 changes: 2 additions & 0 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
s->s_flags |= MS_ACTIVE;
}

mutex_lock(&s->s_root->d_inode->i_mutex);
root = lookup_one_len(subvol_name, s->s_root, strlen(subvol_name));
mutex_unlock(&s->s_root->d_inode->i_mutex);
if (IS_ERR(root)) {
up_write(&s->s_umount);
deactivate_super(s);
Expand Down
9 changes: 5 additions & 4 deletions fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
return 0;
}

int btrfs_add_dead_root(struct btrfs_root *root,
struct btrfs_root *latest,
struct list_head *dead_list)
int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest)
{
struct btrfs_dirty_root *dirty;

Expand All @@ -400,7 +398,10 @@ int btrfs_add_dead_root(struct btrfs_root *root,
return -ENOMEM;
dirty->root = root;
dirty->latest_root = latest;
list_add(&dirty->list, dead_list);

mutex_lock(&root->fs_info->trans_mutex);
list_add(&dirty->list, &latest->fs_info->dead_roots);
mutex_unlock(&root->fs_info->trans_mutex);
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
struct btrfs_root *root);

int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest,
struct list_head *dead_list);
int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest);
int btrfs_defrag_root(struct btrfs_root *root, int cacheonly);
int btrfs_clean_old_snapshots(struct btrfs_root *root);
int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
Expand Down

0 comments on commit b48652c

Please sign in to comment.