extent-tree.c (da633a42170165cbf20a2d3886c7480ccc832ec3) extent-tree.c (c6b305a89b1903d63652691ad5eb9f05aa0326b8)
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 3556 unchanged lines hidden (view full) ---

3565static int do_chunk_alloc(struct btrfs_trans_handle *trans,
3566 struct btrfs_root *extent_root, u64 flags, int force)
3567{
3568 struct btrfs_space_info *space_info;
3569 struct btrfs_fs_info *fs_info = extent_root->fs_info;
3570 int wait_for_alloc = 0;
3571 int ret = 0;
3572
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 3556 unchanged lines hidden (view full) ---

3565static int do_chunk_alloc(struct btrfs_trans_handle *trans,
3566 struct btrfs_root *extent_root, u64 flags, int force)
3567{
3568 struct btrfs_space_info *space_info;
3569 struct btrfs_fs_info *fs_info = extent_root->fs_info;
3570 int wait_for_alloc = 0;
3571 int ret = 0;
3572
3573 /* Don't re-enter if we're already allocating a chunk */
3574 if (trans->allocating_chunk)
3575 return -ENOSPC;
3576
3573 space_info = __find_space_info(extent_root->fs_info, flags);
3574 if (!space_info) {
3575 ret = update_space_info(extent_root->fs_info, flags,
3576 0, 0, &space_info);
3577 BUG_ON(ret); /* -ENOMEM */
3578 }
3579 BUG_ON(!space_info); /* Logic error */
3580

--- 26 unchanged lines hidden (view full) ---

3607 * allocate.
3608 */
3609 if (wait_for_alloc) {
3610 mutex_unlock(&fs_info->chunk_mutex);
3611 wait_for_alloc = 0;
3612 goto again;
3613 }
3614
3577 space_info = __find_space_info(extent_root->fs_info, flags);
3578 if (!space_info) {
3579 ret = update_space_info(extent_root->fs_info, flags,
3580 0, 0, &space_info);
3581 BUG_ON(ret); /* -ENOMEM */
3582 }
3583 BUG_ON(!space_info); /* Logic error */
3584

--- 26 unchanged lines hidden (view full) ---

3611 * allocate.
3612 */
3613 if (wait_for_alloc) {
3614 mutex_unlock(&fs_info->chunk_mutex);
3615 wait_for_alloc = 0;
3616 goto again;
3617 }
3618
3619 trans->allocating_chunk = true;
3620
3615 /*
3616 * If we have mixed data/metadata chunks we want to make sure we keep
3617 * allocating mixed chunks instead of individual chunks.
3618 */
3619 if (btrfs_mixed_space_info(space_info))
3620 flags |= (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA);
3621
3622 /*

--- 10 unchanged lines hidden (view full) ---

3633
3634 /*
3635 * Check if we have enough space in SYSTEM chunk because we may need
3636 * to update devices.
3637 */
3638 check_system_chunk(trans, extent_root, flags);
3639
3640 ret = btrfs_alloc_chunk(trans, extent_root, flags);
3621 /*
3622 * If we have mixed data/metadata chunks we want to make sure we keep
3623 * allocating mixed chunks instead of individual chunks.
3624 */
3625 if (btrfs_mixed_space_info(space_info))
3626 flags |= (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA);
3627
3628 /*

--- 10 unchanged lines hidden (view full) ---

3639
3640 /*
3641 * Check if we have enough space in SYSTEM chunk because we may need
3642 * to update devices.
3643 */
3644 check_system_chunk(trans, extent_root, flags);
3645
3646 ret = btrfs_alloc_chunk(trans, extent_root, flags);
3647 trans->allocating_chunk = false;
3641 if (ret < 0 && ret != -ENOSPC)
3642 goto out;
3643
3644 spin_lock(&space_info->lock);
3645 if (ret)
3646 space_info->full = 1;
3647 else
3648 ret = 1;

--- 4563 unchanged lines hidden ---
3648 if (ret < 0 && ret != -ENOSPC)
3649 goto out;
3650
3651 spin_lock(&space_info->lock);
3652 if (ret)
3653 space_info->full = 1;
3654 else
3655 ret = 1;

--- 4563 unchanged lines hidden ---