Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165914
b: refs/heads/master
c: 33b4d47
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Sep 22, 2009
1 parent 0a68123 commit 574e293
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b2da372b0324b5c604fc8790e70a7efbeacb0b6
refs/heads/master: 33b4d47f5e24b986f486d7de9a2df915ad1fdfbc
18 changes: 16 additions & 2 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,8 @@ int btrfs_check_metadata_free_space(struct btrfs_root *root)
/* get the space info for where the metadata will live */
alloc_target = btrfs_get_alloc_profile(root, 0);
meta_sinfo = __find_space_info(info, alloc_target);
if (!meta_sinfo)
goto alloc;

again:
spin_lock(&meta_sinfo->lock);
Expand All @@ -2795,14 +2797,18 @@ int btrfs_check_metadata_free_space(struct btrfs_root *root)
if (!meta_sinfo->full) {
meta_sinfo->force_alloc = 1;
spin_unlock(&meta_sinfo->lock);

alloc:
trans = btrfs_start_transaction(root, 1);
if (!trans)
return -ENOMEM;

ret = do_chunk_alloc(trans, root->fs_info->extent_root,
2 * 1024 * 1024, alloc_target, 0);
btrfs_end_transaction(trans, root);
if (!meta_sinfo) {
meta_sinfo = __find_space_info(info,
alloc_target);
}
goto again;
}
spin_unlock(&meta_sinfo->lock);
Expand Down Expand Up @@ -2838,6 +2844,9 @@ int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,
bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);

data_sinfo = BTRFS_I(inode)->space_info;
if (!data_sinfo)
goto alloc;

again:
/* make sure we have enough space to handle the data first */
spin_lock(&data_sinfo->lock);
Expand All @@ -2856,7 +2865,7 @@ int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,

data_sinfo->force_alloc = 1;
spin_unlock(&data_sinfo->lock);

alloc:
alloc_target = btrfs_get_alloc_profile(root, 1);
trans = btrfs_start_transaction(root, 1);
if (!trans)
Expand All @@ -2868,6 +2877,11 @@ int btrfs_check_data_free_space(struct btrfs_root *root, struct inode *inode,
btrfs_end_transaction(trans, root);
if (ret)
return ret;

if (!data_sinfo) {
btrfs_set_inode_space_info(root, inode);
data_sinfo = BTRFS_I(inode)->space_info;
}
goto again;
}
spin_unlock(&data_sinfo->lock);
Expand Down

0 comments on commit 574e293

Please sign in to comment.