.. | .. |
---|
11 | 11 | #include "free-space-cache.h" |
---|
12 | 12 | #include "inode-map.h" |
---|
13 | 13 | #include "transaction.h" |
---|
| 14 | +#include "delalloc-space.h" |
---|
14 | 15 | |
---|
15 | 16 | static void fail_caching_thread(struct btrfs_root *root) |
---|
16 | 17 | { |
---|
.. | .. |
---|
106 | 107 | |
---|
107 | 108 | if (last != (u64)-1 && last + 1 != key.objectid) { |
---|
108 | 109 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
---|
109 | | - key.objectid - last - 1); |
---|
| 110 | + key.objectid - last - 1, 0); |
---|
110 | 111 | wake_up(&root->ino_cache_wait); |
---|
111 | 112 | } |
---|
112 | 113 | |
---|
.. | .. |
---|
117 | 118 | |
---|
118 | 119 | if (last < root->highest_objectid - 1) { |
---|
119 | 120 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
---|
120 | | - root->highest_objectid - last - 1); |
---|
| 121 | + root->highest_objectid - last - 1, 0); |
---|
121 | 122 | } |
---|
122 | 123 | |
---|
123 | 124 | spin_lock(&root->ino_cache_lock); |
---|
.. | .. |
---|
174 | 175 | ret = btrfs_find_free_objectid(root, &objectid); |
---|
175 | 176 | if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) { |
---|
176 | 177 | __btrfs_add_free_space(fs_info, ctl, objectid, |
---|
177 | | - BTRFS_LAST_FREE_OBJECTID - objectid + 1); |
---|
| 178 | + BTRFS_LAST_FREE_OBJECTID - objectid + 1, |
---|
| 179 | + 0); |
---|
| 180 | + wake_up(&root->ino_cache_wait); |
---|
178 | 181 | } |
---|
179 | 182 | |
---|
180 | 183 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", |
---|
.. | .. |
---|
219 | 222 | return; |
---|
220 | 223 | again: |
---|
221 | 224 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { |
---|
222 | | - __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
---|
| 225 | + __btrfs_add_free_space(fs_info, pinned, objectid, 1, 0); |
---|
223 | 226 | } else { |
---|
224 | 227 | down_write(&fs_info->commit_root_sem); |
---|
225 | 228 | spin_lock(&root->ino_cache_lock); |
---|
.. | .. |
---|
232 | 235 | |
---|
233 | 236 | start_caching(root); |
---|
234 | 237 | |
---|
235 | | - __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
---|
| 238 | + __btrfs_add_free_space(fs_info, pinned, objectid, 1, 0); |
---|
236 | 239 | |
---|
237 | 240 | up_write(&fs_info->commit_root_sem); |
---|
238 | 241 | } |
---|
.. | .. |
---|
279 | 282 | spin_unlock(rbroot_lock); |
---|
280 | 283 | if (count) |
---|
281 | 284 | __btrfs_add_free_space(root->fs_info, ctl, |
---|
282 | | - info->offset, count); |
---|
| 285 | + info->offset, count, 0); |
---|
283 | 286 | kmem_cache_free(btrfs_free_space_cachep, info); |
---|
284 | 287 | } |
---|
285 | 288 | } |
---|
.. | .. |
---|
434 | 437 | * 1 item for free space object |
---|
435 | 438 | * 3 items for pre-allocation |
---|
436 | 439 | */ |
---|
437 | | - trans->bytes_reserved = btrfs_calc_trans_metadata_size(fs_info, 10); |
---|
| 440 | + trans->bytes_reserved = btrfs_calc_insert_metadata_size(fs_info, 10); |
---|
438 | 441 | ret = btrfs_block_rsv_add(root, trans->block_rsv, |
---|
439 | 442 | trans->bytes_reserved, |
---|
440 | 443 | BTRFS_RESERVE_NO_FLUSH); |
---|
.. | .. |
---|
492 | 495 | /* Just to make sure we have enough space */ |
---|
493 | 496 | prealloc += 8 * PAGE_SIZE; |
---|
494 | 497 | |
---|
495 | | - ret = btrfs_delalloc_reserve_space(inode, &data_reserved, 0, prealloc); |
---|
| 498 | + ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved, 0, |
---|
| 499 | + prealloc); |
---|
496 | 500 | if (ret) |
---|
497 | 501 | goto out_put; |
---|
498 | 502 | |
---|
.. | .. |
---|
512 | 516 | trace_btrfs_space_reservation(fs_info, "ino_cache", trans->transid, |
---|
513 | 517 | trans->bytes_reserved, 0); |
---|
514 | 518 | btrfs_block_rsv_release(fs_info, trans->block_rsv, |
---|
515 | | - trans->bytes_reserved); |
---|
| 519 | + trans->bytes_reserved, NULL); |
---|
516 | 520 | out: |
---|
517 | 521 | trans->block_rsv = rsv; |
---|
518 | 522 | trans->bytes_reserved = num_bytes; |
---|