Skip to content

Commit 27eb427

Browse files
committed
Merge branch 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs updates from Chris Mason: "We have a lot of subvolume quota improvements in here, along with big piles of cleanups from Dave Sterba and Anand Jain and others. Josef pitched in a batch of allocator fixes based on production use here at FB. We found that mount -o ssd_spread greatly improved our performance on hardware raid5/6, but it exposed some CPU bottlenecks in the allocator. These patches make a huge difference" * 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (100 commits) Btrfs: fix hole punching when using the no-holes feature Btrfs: find_free_extent: Do not erroneously skip LOOP_CACHING_WAIT state btrfs: Fix a data space underflow warning btrfs: qgroup: Fix a rebase bug which will cause qgroup double free btrfs: qgroup: Fix a race in delayed_ref which leads to abort trans btrfs: clear PF_NOFREEZE in cleaner_kthread() btrfs: qgroup: Don't copy extent buffer to do qgroup rescan btrfs: add balance filters limits, stripes and usage to supported mask btrfs: extend balance filter usage to take minimum and maximum btrfs: add balance filter for stripes btrfs: extend balance filter limit to take minimum and maximum btrfs: fix use after free iterating extrefs btrfs: check unsupported filters in balance arguments Btrfs: fix regression running delayed references when using qgroups Btrfs: fix regression when running delayed references Btrfs: don't do extra bitmap search in one bit case Btrfs: keep track of largest extent in bitmaps Btrfs: don't keep trying to build clusters if we are fragmented Btrfs: cut down on loops through the allocator Btrfs: don't continue setting up space cache when enospc ...
2 parents 7130098 + 2959a32 commit 27eb427

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2768
-1068
lines changed

fs/btrfs/backref.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
362362
goto out;
363363
}
364364

365+
if (btrfs_test_is_dummy_root(root)) {
366+
srcu_read_unlock(&fs_info->subvol_srcu, index);
367+
ret = -ENOENT;
368+
goto out;
369+
}
370+
365371
if (path->search_commit_root)
366372
root_level = btrfs_header_level(root->commit_root);
367373
else if (time_seq == (u64)-1)

fs/btrfs/check-integrity.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
667667
selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
668668
if (NULL == selected_super) {
669669
printk(KERN_INFO "btrfsic: error, kmalloc failed!\n");
670-
return -1;
670+
return -ENOMEM;
671671
}
672672

673673
list_for_each_entry(device, dev_head, dev_list) {
@@ -845,8 +845,8 @@ static int btrfsic_process_superblock_dev_mirror(
845845
superblock_tmp->never_written = 0;
846846
superblock_tmp->mirror_num = 1 + superblock_mirror_num;
847847
if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE)
848-
printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)"
849-
" @%llu (%s/%llu/%d)\n",
848+
btrfs_info_in_rcu(device->dev_root->fs_info,
849+
"new initial S-block (bdev %p, %s) @%llu (%s/%llu/%d)",
850850
superblock_bdev,
851851
rcu_str_deref(device->name), dev_bytenr,
852852
dev_state->name, dev_bytenr,
@@ -1660,7 +1660,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
16601660
sizeof(*block_ctx->pagev)) *
16611661
num_pages, GFP_NOFS);
16621662
if (!block_ctx->mem_to_free)
1663-
return -1;
1663+
return -ENOMEM;
16641664
block_ctx->datav = block_ctx->mem_to_free;
16651665
block_ctx->pagev = (struct page **)(block_ctx->datav + num_pages);
16661666
for (i = 0; i < num_pages; i++) {

fs/btrfs/compression.c

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,13 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
745745
return ret;
746746
}
747747

748-
static struct list_head comp_idle_workspace[BTRFS_COMPRESS_TYPES];
749-
static spinlock_t comp_workspace_lock[BTRFS_COMPRESS_TYPES];
750-
static int comp_num_workspace[BTRFS_COMPRESS_TYPES];
751-
static atomic_t comp_alloc_workspace[BTRFS_COMPRESS_TYPES];
752-
static wait_queue_head_t comp_workspace_wait[BTRFS_COMPRESS_TYPES];
748+
static struct {
749+
struct list_head idle_ws;
750+
spinlock_t ws_lock;
751+
int num_ws;
752+
atomic_t alloc_ws;
753+
wait_queue_head_t ws_wait;
754+
} btrfs_comp_ws[BTRFS_COMPRESS_TYPES];
753755

754756
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
755757
&btrfs_zlib_compress,
@@ -761,10 +763,10 @@ void __init btrfs_init_compress(void)
761763
int i;
762764

763765
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
764-
INIT_LIST_HEAD(&comp_idle_workspace[i]);
765-
spin_lock_init(&comp_workspace_lock[i]);
766-
atomic_set(&comp_alloc_workspace[i], 0);
767-
init_waitqueue_head(&comp_workspace_wait[i]);
766+
INIT_LIST_HEAD(&btrfs_comp_ws[i].idle_ws);
767+
spin_lock_init(&btrfs_comp_ws[i].ws_lock);
768+
atomic_set(&btrfs_comp_ws[i].alloc_ws, 0);
769+
init_waitqueue_head(&btrfs_comp_ws[i].ws_wait);
768770
}
769771
}
770772

@@ -778,38 +780,38 @@ static struct list_head *find_workspace(int type)
778780
int cpus = num_online_cpus();
779781
int idx = type - 1;
780782

781-
struct list_head *idle_workspace = &comp_idle_workspace[idx];
782-
spinlock_t *workspace_lock = &comp_workspace_lock[idx];
783-
atomic_t *alloc_workspace = &comp_alloc_workspace[idx];
784-
wait_queue_head_t *workspace_wait = &comp_workspace_wait[idx];
785-
int *num_workspace = &comp_num_workspace[idx];
783+
struct list_head *idle_ws = &btrfs_comp_ws[idx].idle_ws;
784+
spinlock_t *ws_lock = &btrfs_comp_ws[idx].ws_lock;
785+
atomic_t *alloc_ws = &btrfs_comp_ws[idx].alloc_ws;
786+
wait_queue_head_t *ws_wait = &btrfs_comp_ws[idx].ws_wait;
787+
int *num_ws = &btrfs_comp_ws[idx].num_ws;
786788
again:
787-
spin_lock(workspace_lock);
788-
if (!list_empty(idle_workspace)) {
789-
workspace = idle_workspace->next;
789+
spin_lock(ws_lock);
790+
if (!list_empty(idle_ws)) {
791+
workspace = idle_ws->next;
790792
list_del(workspace);
791-
(*num_workspace)--;
792-
spin_unlock(workspace_lock);
793+
(*num_ws)--;
794+
spin_unlock(ws_lock);
793795
return workspace;
794796

795797
}
796-
if (atomic_read(alloc_workspace) > cpus) {
798+
if (atomic_read(alloc_ws) > cpus) {
797799
DEFINE_WAIT(wait);
798800

799-
spin_unlock(workspace_lock);
800-
prepare_to_wait(workspace_wait, &wait, TASK_UNINTERRUPTIBLE);
801-
if (atomic_read(alloc_workspace) > cpus && !*num_workspace)
801+
spin_unlock(ws_lock);
802+
prepare_to_wait(ws_wait, &wait, TASK_UNINTERRUPTIBLE);
803+
if (atomic_read(alloc_ws) > cpus && !*num_ws)
802804
schedule();
803-
finish_wait(workspace_wait, &wait);
805+
finish_wait(ws_wait, &wait);
804806
goto again;
805807
}
806-
atomic_inc(alloc_workspace);
807-
spin_unlock(workspace_lock);
808+
atomic_inc(alloc_ws);
809+
spin_unlock(ws_lock);
808810

809811
workspace = btrfs_compress_op[idx]->alloc_workspace();
810812
if (IS_ERR(workspace)) {
811-
atomic_dec(alloc_workspace);
812-
wake_up(workspace_wait);
813+
atomic_dec(alloc_ws);
814+
wake_up(ws_wait);
813815
}
814816
return workspace;
815817
}
@@ -821,27 +823,30 @@ static struct list_head *find_workspace(int type)
821823
static void free_workspace(int type, struct list_head *workspace)
822824
{
823825
int idx = type - 1;
824-
struct list_head *idle_workspace = &comp_idle_workspace[idx];
825-
spinlock_t *workspace_lock = &comp_workspace_lock[idx];
826-
atomic_t *alloc_workspace = &comp_alloc_workspace[idx];
827-
wait_queue_head_t *workspace_wait = &comp_workspace_wait[idx];
828-
int *num_workspace = &comp_num_workspace[idx];
829-
830-
spin_lock(workspace_lock);
831-
if (*num_workspace < num_online_cpus()) {
832-
list_add(workspace, idle_workspace);
833-
(*num_workspace)++;
834-
spin_unlock(workspace_lock);
826+
struct list_head *idle_ws = &btrfs_comp_ws[idx].idle_ws;
827+
spinlock_t *ws_lock = &btrfs_comp_ws[idx].ws_lock;
828+
atomic_t *alloc_ws = &btrfs_comp_ws[idx].alloc_ws;
829+
wait_queue_head_t *ws_wait = &btrfs_comp_ws[idx].ws_wait;
830+
int *num_ws = &btrfs_comp_ws[idx].num_ws;
831+
832+
spin_lock(ws_lock);
833+
if (*num_ws < num_online_cpus()) {
834+
list_add(workspace, idle_ws);
835+
(*num_ws)++;
836+
spin_unlock(ws_lock);
835837
goto wake;
836838
}
837-
spin_unlock(workspace_lock);
839+
spin_unlock(ws_lock);
838840

839841
btrfs_compress_op[idx]->free_workspace(workspace);
840-
atomic_dec(alloc_workspace);
842+
atomic_dec(alloc_ws);
841843
wake:
844+
/*
845+
* Make sure counter is updated before we wake up waiters.
846+
*/
842847
smp_mb();
843-
if (waitqueue_active(workspace_wait))
844-
wake_up(workspace_wait);
848+
if (waitqueue_active(ws_wait))
849+
wake_up(ws_wait);
845850
}
846851

847852
/*
@@ -853,11 +858,11 @@ static void free_workspaces(void)
853858
int i;
854859

855860
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
856-
while (!list_empty(&comp_idle_workspace[i])) {
857-
workspace = comp_idle_workspace[i].next;
861+
while (!list_empty(&btrfs_comp_ws[i].idle_ws)) {
862+
workspace = btrfs_comp_ws[i].idle_ws.next;
858863
list_del(workspace);
859864
btrfs_compress_op[i]->free_workspace(workspace);
860-
atomic_dec(&comp_alloc_workspace[i]);
865+
atomic_dec(&btrfs_comp_ws[i].alloc_ws);
861866
}
862867
}
863868
}

fs/btrfs/ctree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
10111011
return ret;
10121012
if (refs == 0) {
10131013
ret = -EROFS;
1014-
btrfs_std_error(root->fs_info, ret);
1014+
btrfs_std_error(root->fs_info, ret, NULL);
10151015
return ret;
10161016
}
10171017
} else {
@@ -1927,7 +1927,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
19271927
child = read_node_slot(root, mid, 0);
19281928
if (!child) {
19291929
ret = -EROFS;
1930-
btrfs_std_error(root->fs_info, ret);
1930+
btrfs_std_error(root->fs_info, ret, NULL);
19311931
goto enospc;
19321932
}
19331933

@@ -2030,7 +2030,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
20302030
*/
20312031
if (!left) {
20322032
ret = -EROFS;
2033-
btrfs_std_error(root->fs_info, ret);
2033+
btrfs_std_error(root->fs_info, ret, NULL);
20342034
goto enospc;
20352035
}
20362036
wret = balance_node_right(trans, root, mid, left);
@@ -4940,8 +4940,8 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
49404940
{
49414941
struct extent_buffer *leaf;
49424942
struct btrfs_item *item;
4943-
int last_off;
4944-
int dsize = 0;
4943+
u32 last_off;
4944+
u32 dsize = 0;
49454945
int ret = 0;
49464946
int wret;
49474947
int i;

0 commit comments

Comments
 (0)