diff options
Diffstat (limited to 'fs/btrfs/bit-radix.c')
-rw-r--r-- | fs/btrfs/bit-radix.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/bit-radix.c b/fs/btrfs/bit-radix.c index 43807cc3cce7..845422368f48 100644 --- a/fs/btrfs/bit-radix.c +++ b/fs/btrfs/bit-radix.c | |||
@@ -16,12 +16,14 @@ int set_radix_bit(struct radix_tree_root *radix, unsigned long bit) | |||
16 | 16 | ||
17 | bits = radix_tree_lookup(radix, slot); | 17 | bits = radix_tree_lookup(radix, slot); |
18 | if (!bits) { | 18 | if (!bits) { |
19 | bits = kmalloc(BIT_ARRAY_BYTES, GFP_NOIO); | 19 | bits = kmalloc(BIT_ARRAY_BYTES, GFP_NOFS); |
20 | if (!bits) | 20 | if (!bits) |
21 | return -ENOMEM; | 21 | return -ENOMEM; |
22 | memset(bits + 1, 0, BIT_ARRAY_BYTES - sizeof(unsigned long)); | 22 | memset(bits + 1, 0, BIT_ARRAY_BYTES - sizeof(unsigned long)); |
23 | bits[0] = slot; | 23 | bits[0] = slot; |
24 | radix_tree_preload(GFP_NOFS); | ||
24 | ret = radix_tree_insert(radix, slot, bits); | 25 | ret = radix_tree_insert(radix, slot, bits); |
26 | radix_tree_preload_end(); | ||
25 | if (ret) | 27 | if (ret) |
26 | return ret; | 28 | return ret; |
27 | } | 29 | } |
@@ -59,7 +61,7 @@ int clear_radix_bit(struct radix_tree_root *radix, unsigned long bit) | |||
59 | if (!bits) | 61 | if (!bits) |
60 | return 0; | 62 | return 0; |
61 | clear_bit(bit_slot, bits + 1); | 63 | clear_bit(bit_slot, bits + 1); |
62 | 64 | #if 0 | |
63 | for (i = 1; i < BIT_ARRAY_BYTES / sizeof(unsigned long); i++) { | 65 | for (i = 1; i < BIT_ARRAY_BYTES / sizeof(unsigned long); i++) { |
64 | if (bits[i]) { | 66 | if (bits[i]) { |
65 | empty = 0; | 67 | empty = 0; |
@@ -69,8 +71,11 @@ int clear_radix_bit(struct radix_tree_root *radix, unsigned long bit) | |||
69 | 71 | ||
70 | if (empty) { | 72 | if (empty) { |
71 | bits = radix_tree_delete(radix, slot); | 73 | bits = radix_tree_delete(radix, slot); |
74 | synchronize_rcu(); | ||
72 | BUG_ON(!bits); | 75 | BUG_ON(!bits); |
76 | kfree(bits); | ||
73 | } | 77 | } |
78 | #endif | ||
74 | return 0; | 79 | return 0; |
75 | } | 80 | } |
76 | 81 | ||