diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-08-01 14:27:34 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-08-01 14:27:34 -0400 |
commit | b43b31bdf2e662006c27cc4dcccf863312d62bc1 (patch) | |
tree | 9e12413edbd9d7a77e4c0b692dd28ca4ae5039bd /fs/btrfs/extent-tree.c | |
parent | ff95acb6733d41a8d45feb0e18b96df25e610e78 (diff) | |
parent | 38a1a919535742af677303271eb4ff731547b706 (diff) |
Merge branch 'alloc_path' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/btrfs-error-handling into for-linus
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4d08ed79405d..55bddffede73 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -663,7 +663,9 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len) | |||
663 | struct btrfs_path *path; | 663 | struct btrfs_path *path; |
664 | 664 | ||
665 | path = btrfs_alloc_path(); | 665 | path = btrfs_alloc_path(); |
666 | BUG_ON(!path); | 666 | if (!path) |
667 | return -ENOMEM; | ||
668 | |||
667 | key.objectid = start; | 669 | key.objectid = start; |
668 | key.offset = len; | 670 | key.offset = len; |
669 | btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); | 671 | btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); |
@@ -3272,6 +3274,9 @@ again: | |||
3272 | } | 3274 | } |
3273 | 3275 | ||
3274 | ret = btrfs_alloc_chunk(trans, extent_root, flags); | 3276 | ret = btrfs_alloc_chunk(trans, extent_root, flags); |
3277 | if (ret < 0 && ret != -ENOSPC) | ||
3278 | goto out; | ||
3279 | |||
3275 | spin_lock(&space_info->lock); | 3280 | spin_lock(&space_info->lock); |
3276 | if (ret) | 3281 | if (ret) |
3277 | space_info->full = 1; | 3282 | space_info->full = 1; |
@@ -3281,6 +3286,7 @@ again: | |||
3281 | space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; | 3286 | space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; |
3282 | space_info->chunk_alloc = 0; | 3287 | space_info->chunk_alloc = 0; |
3283 | spin_unlock(&space_info->lock); | 3288 | spin_unlock(&space_info->lock); |
3289 | out: | ||
3284 | mutex_unlock(&extent_root->fs_info->chunk_mutex); | 3290 | mutex_unlock(&extent_root->fs_info->chunk_mutex); |
3285 | return ret; | 3291 | return ret; |
3286 | } | 3292 | } |
@@ -5501,7 +5507,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, | |||
5501 | u32 size = sizeof(*extent_item) + sizeof(*block_info) + sizeof(*iref); | 5507 | u32 size = sizeof(*extent_item) + sizeof(*block_info) + sizeof(*iref); |
5502 | 5508 | ||
5503 | path = btrfs_alloc_path(); | 5509 | path = btrfs_alloc_path(); |
5504 | BUG_ON(!path); | 5510 | if (!path) |
5511 | return -ENOMEM; | ||
5505 | 5512 | ||
5506 | path->leave_spinning = 1; | 5513 | path->leave_spinning = 1; |
5507 | ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, | 5514 | ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, |
@@ -6272,10 +6279,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
6272 | int level; | 6279 | int level; |
6273 | 6280 | ||
6274 | path = btrfs_alloc_path(); | 6281 | path = btrfs_alloc_path(); |
6275 | BUG_ON(!path); | 6282 | if (!path) |
6283 | return -ENOMEM; | ||
6276 | 6284 | ||
6277 | wc = kzalloc(sizeof(*wc), GFP_NOFS); | 6285 | wc = kzalloc(sizeof(*wc), GFP_NOFS); |
6278 | BUG_ON(!wc); | 6286 | if (!wc) { |
6287 | btrfs_free_path(path); | ||
6288 | return -ENOMEM; | ||
6289 | } | ||
6279 | 6290 | ||
6280 | trans = btrfs_start_transaction(tree_root, 0); | 6291 | trans = btrfs_start_transaction(tree_root, 0); |
6281 | BUG_ON(IS_ERR(trans)); | 6292 | BUG_ON(IS_ERR(trans)); |
@@ -7183,7 +7194,10 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | |||
7183 | spin_unlock(&cluster->refill_lock); | 7194 | spin_unlock(&cluster->refill_lock); |
7184 | 7195 | ||
7185 | path = btrfs_alloc_path(); | 7196 | path = btrfs_alloc_path(); |
7186 | BUG_ON(!path); | 7197 | if (!path) { |
7198 | ret = -ENOMEM; | ||
7199 | goto out; | ||
7200 | } | ||
7187 | 7201 | ||
7188 | inode = lookup_free_space_inode(root, block_group, path); | 7202 | inode = lookup_free_space_inode(root, block_group, path); |
7189 | if (!IS_ERR(inode)) { | 7203 | if (!IS_ERR(inode)) { |