Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360501
b: refs/heads/master
c: 83c8266
h: refs/heads/master
i:
  360499: 5775caa
v: v3
  • Loading branch information
David Sterba authored and Josef Bacik committed Mar 1, 2013
1 parent 6c61b4e commit 6fded55
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 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: 88e081bf82ffcb9be3ad33d04c829051d66da564
refs/heads/master: 83c8266acc1d19debbf353a16aabbd892ef99462
2 changes: 1 addition & 1 deletion trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ int open_ctree(struct super_block *sb,

ret = btrfs_alloc_stripe_hash_table(fs_info);
if (ret) {
err = -ENOMEM;
err = ret;
goto fail_alloc;
}

Expand Down
31 changes: 25 additions & 6 deletions trunk/fs/btrfs/raid56.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,25 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
struct btrfs_stripe_hash *h;
int num_entries = 1 << BTRFS_STRIPE_HASH_TABLE_BITS;
int i;
int table_size;

if (info->stripe_hash_table)
return 0;

table = kzalloc(sizeof(*table) + sizeof(*h) * num_entries, GFP_NOFS);
if (!table)
return -ENOMEM;
/*
* The table is large, starting with order 4 and can go as high as
* order 7 in case lock debugging is turned on.
*
* Try harder to allocate and fallback to vmalloc to lower the chance
* of a failing mount.
*/
table_size = sizeof(*table) + sizeof(*h) * num_entries;
table = kzalloc(table_size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
if (!table) {
table = vzalloc(table_size);
if (!table)
return -ENOMEM;
}

spin_lock_init(&table->cache_lock);
INIT_LIST_HEAD(&table->stripe_cache);
Expand All @@ -209,8 +221,12 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
}

x = cmpxchg(&info->stripe_hash_table, NULL, table);
if (x)
kfree(x);
if (x) {
if (is_vmalloc_addr(x))
vfree(x);
else
kfree(x);
}
return 0;
}

Expand Down Expand Up @@ -420,7 +436,10 @@ void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info)
if (!info->stripe_hash_table)
return;
btrfs_clear_rbio_cache(info);
kfree(info->stripe_hash_table);
if (is_vmalloc_addr(info->stripe_hash_table))
vfree(info->stripe_hash_table);
else
kfree(info->stripe_hash_table);
info->stripe_hash_table = NULL;
}

Expand Down

0 comments on commit 6fded55

Please sign in to comment.