H A D | delayed-inode.c | 51 struct btrfs_delayed_node *delayed_node, btrfs_init_delayed_node() 54 delayed_node->root = root; btrfs_init_delayed_node() 55 delayed_node->inode_id = inode_id; btrfs_init_delayed_node() 56 atomic_set(&delayed_node->refs, 0); btrfs_init_delayed_node() 57 delayed_node->count = 0; btrfs_init_delayed_node() 58 delayed_node->flags = 0; btrfs_init_delayed_node() 59 delayed_node->ins_root = RB_ROOT; btrfs_init_delayed_node() 60 delayed_node->del_root = RB_ROOT; btrfs_init_delayed_node() 61 mutex_init(&delayed_node->mutex); btrfs_init_delayed_node() 62 delayed_node->index_cnt = 0; btrfs_init_delayed_node() 63 INIT_LIST_HEAD(&delayed_node->n_list); btrfs_init_delayed_node() 64 INIT_LIST_HEAD(&delayed_node->p_list); btrfs_init_delayed_node() 65 delayed_node->bytes_reserved = 0; btrfs_init_delayed_node() 66 memset(&delayed_node->inode_item, 0, sizeof(delayed_node->inode_item)); btrfs_init_delayed_node() 94 node = ACCESS_ONCE(btrfs_inode->delayed_node); btrfs_get_delayed_node() 103 if (btrfs_inode->delayed_node) { btrfs_get_delayed_node() 105 BUG_ON(btrfs_inode->delayed_node != node); btrfs_get_delayed_node() 109 btrfs_inode->delayed_node = node; btrfs_get_delayed_node() 157 btrfs_inode->delayed_node = node; btrfs_get_or_create_delayed_node() 165 * Call it when holding delayed_node->mutex 189 /* Call it when holding delayed_node->mutex */ btrfs_dequeue_delayed_node() 252 struct btrfs_delayed_node *delayed_node, __btrfs_release_delayed_node() 257 if (!delayed_node) __btrfs_release_delayed_node() 260 delayed_root = delayed_node->root->fs_info->delayed_root; __btrfs_release_delayed_node() 262 mutex_lock(&delayed_node->mutex); __btrfs_release_delayed_node() 263 if (delayed_node->count) __btrfs_release_delayed_node() 264 btrfs_queue_delayed_node(delayed_root, delayed_node, mod); __btrfs_release_delayed_node() 266 btrfs_dequeue_delayed_node(delayed_root, delayed_node); __btrfs_release_delayed_node() 267 mutex_unlock(&delayed_node->mutex); __btrfs_release_delayed_node() 269 if (atomic_dec_and_test(&delayed_node->refs)) { __btrfs_release_delayed_node() 271 struct btrfs_root *root = delayed_node->root; __btrfs_release_delayed_node() 273 if (atomic_read(&delayed_node->refs) == 0) { __btrfs_release_delayed_node() 275 delayed_node->inode_id); __btrfs_release_delayed_node() 280 kmem_cache_free(delayed_node_cache, delayed_node); __btrfs_release_delayed_node() 323 item->delayed_node = NULL; btrfs_alloc_delayed_item() 331 * @delayed_node: pointer to the delayed node 391 struct btrfs_delayed_node *delayed_node, __btrfs_lookup_delayed_insertion_item() 396 item = __btrfs_lookup_delayed_item(&delayed_node->ins_root, key, __btrfs_lookup_delayed_insertion_item() 401 static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node, __btrfs_add_delayed_item() argument 412 root = &delayed_node->ins_root; __btrfs_add_delayed_item() 414 root = &delayed_node->del_root; __btrfs_add_delayed_item() 436 ins->delayed_node = delayed_node; __btrfs_add_delayed_item() 441 ins->key.offset >= delayed_node->index_cnt) __btrfs_add_delayed_item() 442 delayed_node->index_cnt = ins->key.offset + 1; __btrfs_add_delayed_item() 444 delayed_node->count++; __btrfs_add_delayed_item() 445 atomic_inc(&delayed_node->root->fs_info->delayed_root->items); __btrfs_add_delayed_item() 477 delayed_root = delayed_item->delayed_node->root->fs_info->delayed_root; __btrfs_remove_delayed_item() 484 root = &delayed_item->delayed_node->ins_root; __btrfs_remove_delayed_item() 486 root = &delayed_item->delayed_node->del_root; __btrfs_remove_delayed_item() 489 delayed_item->delayed_node->count--; __btrfs_remove_delayed_item() 504 struct btrfs_delayed_node *delayed_node) __btrfs_first_delayed_insertion_item() 509 p = rb_first(&delayed_node->ins_root); __btrfs_first_delayed_insertion_item() 517 struct btrfs_delayed_node *delayed_node) __btrfs_first_delayed_deletion_item() 522 p = rb_first(&delayed_node->del_root); __btrfs_first_delayed_deletion_item() 1006 static void btrfs_release_delayed_inode(struct btrfs_delayed_node *delayed_node) btrfs_release_delayed_inode() argument 1010 if (delayed_node && btrfs_release_delayed_inode() 1011 test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { btrfs_release_delayed_inode() 1012 BUG_ON(!delayed_node->root); btrfs_release_delayed_inode() 1013 clear_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags); btrfs_release_delayed_inode() 1014 delayed_node->count--; btrfs_release_delayed_inode() 1016 delayed_root = delayed_node->root->fs_info->delayed_root; btrfs_release_delayed_inode() 1021 static void btrfs_release_delayed_iref(struct btrfs_delayed_node *delayed_node) btrfs_release_delayed_iref() argument 1025 ASSERT(delayed_node->root); btrfs_release_delayed_iref() 1026 clear_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags); btrfs_release_delayed_iref() 1027 delayed_node->count--; btrfs_release_delayed_iref() 1029 delayed_root = delayed_node->root->fs_info->delayed_root; btrfs_release_delayed_iref() 1220 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); btrfs_commit_inode_delayed_items() local 1225 if (!delayed_node) btrfs_commit_inode_delayed_items() 1228 mutex_lock(&delayed_node->mutex); btrfs_commit_inode_delayed_items() 1229 if (!delayed_node->count) { btrfs_commit_inode_delayed_items() 1230 mutex_unlock(&delayed_node->mutex); btrfs_commit_inode_delayed_items() 1231 btrfs_release_delayed_node(delayed_node); btrfs_commit_inode_delayed_items() 1234 mutex_unlock(&delayed_node->mutex); btrfs_commit_inode_delayed_items() 1238 btrfs_release_delayed_node(delayed_node); btrfs_commit_inode_delayed_items() 1244 trans->block_rsv = &delayed_node->root->fs_info->delayed_block_rsv; btrfs_commit_inode_delayed_items() 1246 ret = __btrfs_commit_inode_delayed_items(trans, path, delayed_node); btrfs_commit_inode_delayed_items() 1248 btrfs_release_delayed_node(delayed_node); btrfs_commit_inode_delayed_items() 1258 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); btrfs_commit_inode_delayed_inode() local 1263 if (!delayed_node) btrfs_commit_inode_delayed_inode() 1266 mutex_lock(&delayed_node->mutex); btrfs_commit_inode_delayed_inode() 1267 if (!test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { btrfs_commit_inode_delayed_inode() 1268 mutex_unlock(&delayed_node->mutex); btrfs_commit_inode_delayed_inode() 1269 btrfs_release_delayed_node(delayed_node); btrfs_commit_inode_delayed_inode() 1272 mutex_unlock(&delayed_node->mutex); btrfs_commit_inode_delayed_inode() 1274 trans = btrfs_join_transaction(delayed_node->root); btrfs_commit_inode_delayed_inode() 1288 trans->block_rsv = &delayed_node->root->fs_info->delayed_block_rsv; btrfs_commit_inode_delayed_inode() 1290 mutex_lock(&delayed_node->mutex); btrfs_commit_inode_delayed_inode() 1291 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) btrfs_commit_inode_delayed_inode() 1292 ret = __btrfs_update_delayed_inode(trans, delayed_node->root, btrfs_commit_inode_delayed_inode() 1293 path, delayed_node); btrfs_commit_inode_delayed_inode() 1296 mutex_unlock(&delayed_node->mutex); btrfs_commit_inode_delayed_inode() 1301 btrfs_end_transaction(trans, delayed_node->root); btrfs_commit_inode_delayed_inode() 1302 btrfs_btree_balance_dirty(delayed_node->root); btrfs_commit_inode_delayed_inode() 1304 btrfs_release_delayed_node(delayed_node); btrfs_commit_inode_delayed_inode() 1311 struct btrfs_delayed_node *delayed_node; btrfs_remove_delayed_node() local 1313 delayed_node = ACCESS_ONCE(BTRFS_I(inode)->delayed_node); btrfs_remove_delayed_node() 1314 if (!delayed_node) btrfs_remove_delayed_node() 1317 BTRFS_I(inode)->delayed_node = NULL; btrfs_remove_delayed_node() 1318 btrfs_release_delayed_node(delayed_node); btrfs_remove_delayed_node() 1333 struct btrfs_delayed_node *delayed_node = NULL; btrfs_async_run_delayed_root() local 1349 delayed_node = btrfs_first_prepared_delayed_node(delayed_root); btrfs_async_run_delayed_root() 1350 if (!delayed_node) btrfs_async_run_delayed_root() 1354 root = delayed_node->root; btrfs_async_run_delayed_root() 1363 __btrfs_commit_inode_delayed_items(trans, path, delayed_node); btrfs_async_run_delayed_root() 1373 btrfs_release_prepared_delayed_node(delayed_node); btrfs_async_run_delayed_root() 1461 struct btrfs_delayed_node *delayed_node; btrfs_insert_delayed_dir_index() local 1466 delayed_node = btrfs_get_or_create_delayed_node(dir); btrfs_insert_delayed_dir_index() 1467 if (IS_ERR(delayed_node)) btrfs_insert_delayed_dir_index() 1468 return PTR_ERR(delayed_node); btrfs_insert_delayed_dir_index() 1496 mutex_lock(&delayed_node->mutex); btrfs_insert_delayed_dir_index() 1497 ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item); btrfs_insert_delayed_dir_index() 1502 name_len, name, delayed_node->root->objectid, btrfs_insert_delayed_dir_index() 1503 delayed_node->inode_id, ret); btrfs_insert_delayed_dir_index() 1506 mutex_unlock(&delayed_node->mutex); btrfs_insert_delayed_dir_index() 1509 btrfs_release_delayed_node(delayed_node); btrfs_insert_delayed_dir_index() 1586 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); btrfs_inode_delayed_dir_index_count() local 1588 if (!delayed_node) btrfs_inode_delayed_dir_index_count() 1596 if (!delayed_node->index_cnt) { btrfs_inode_delayed_dir_index_count() 1597 btrfs_release_delayed_node(delayed_node); btrfs_inode_delayed_dir_index_count() 1601 BTRFS_I(inode)->index_cnt = delayed_node->index_cnt; btrfs_inode_delayed_dir_index_count() 1602 btrfs_release_delayed_node(delayed_node); btrfs_inode_delayed_dir_index_count() 1609 struct btrfs_delayed_node *delayed_node; btrfs_get_delayed_items() local 1612 delayed_node = btrfs_get_delayed_node(inode); btrfs_get_delayed_items() 1613 if (!delayed_node) btrfs_get_delayed_items() 1616 mutex_lock(&delayed_node->mutex); btrfs_get_delayed_items() 1617 item = __btrfs_first_delayed_insertion_item(delayed_node); btrfs_get_delayed_items() 1624 item = __btrfs_first_delayed_deletion_item(delayed_node); btrfs_get_delayed_items() 1630 mutex_unlock(&delayed_node->mutex); btrfs_get_delayed_items() 1640 atomic_dec(&delayed_node->refs); btrfs_get_delayed_items() 1783 struct btrfs_delayed_node *delayed_node; btrfs_fill_inode() local 1786 delayed_node = btrfs_get_delayed_node(inode); btrfs_fill_inode() 1787 if (!delayed_node) btrfs_fill_inode() 1790 mutex_lock(&delayed_node->mutex); btrfs_fill_inode() 1791 if (!test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { btrfs_fill_inode() 1792 mutex_unlock(&delayed_node->mutex); btrfs_fill_inode() 1793 btrfs_release_delayed_node(delayed_node); btrfs_fill_inode() 1797 inode_item = &delayed_node->inode_item; btrfs_fill_inode() 1830 mutex_unlock(&delayed_node->mutex); btrfs_fill_inode() 1831 btrfs_release_delayed_node(delayed_node); btrfs_fill_inode() 1838 struct btrfs_delayed_node *delayed_node; btrfs_delayed_update_inode() local 1841 delayed_node = btrfs_get_or_create_delayed_node(inode); btrfs_delayed_update_inode() 1842 if (IS_ERR(delayed_node)) btrfs_delayed_update_inode() 1843 return PTR_ERR(delayed_node); btrfs_delayed_update_inode() 1845 mutex_lock(&delayed_node->mutex); btrfs_delayed_update_inode() 1846 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { btrfs_delayed_update_inode() 1847 fill_stack_inode_item(trans, &delayed_node->inode_item, inode); btrfs_delayed_update_inode() 1852 delayed_node); btrfs_delayed_update_inode() 1856 fill_stack_inode_item(trans, &delayed_node->inode_item, inode); btrfs_delayed_update_inode() 1857 set_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags); btrfs_delayed_update_inode() 1858 delayed_node->count++; btrfs_delayed_update_inode() 1861 mutex_unlock(&delayed_node->mutex); btrfs_delayed_update_inode() 1862 btrfs_release_delayed_node(delayed_node); btrfs_delayed_update_inode() 1868 struct btrfs_delayed_node *delayed_node; btrfs_delayed_delete_inode_ref() local 1878 delayed_node = btrfs_get_or_create_delayed_node(inode); btrfs_delayed_delete_inode_ref() 1879 if (IS_ERR(delayed_node)) btrfs_delayed_delete_inode_ref() 1880 return PTR_ERR(delayed_node); btrfs_delayed_delete_inode_ref() 1896 mutex_lock(&delayed_node->mutex); btrfs_delayed_delete_inode_ref() 1897 if (test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags)) btrfs_delayed_delete_inode_ref() 1900 set_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags); btrfs_delayed_delete_inode_ref() 1901 delayed_node->count++; btrfs_delayed_delete_inode_ref() 1904 mutex_unlock(&delayed_node->mutex); btrfs_delayed_delete_inode_ref() 1905 btrfs_release_delayed_node(delayed_node); btrfs_delayed_delete_inode_ref() 1909 static void __btrfs_kill_delayed_node(struct btrfs_delayed_node *delayed_node) __btrfs_kill_delayed_node() argument 1911 struct btrfs_root *root = delayed_node->root; __btrfs_kill_delayed_node() 1914 mutex_lock(&delayed_node->mutex); __btrfs_kill_delayed_node() 1915 curr_item = __btrfs_first_delayed_insertion_item(delayed_node); __btrfs_kill_delayed_node() 1923 curr_item = __btrfs_first_delayed_deletion_item(delayed_node); __btrfs_kill_delayed_node() 1931 if (test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags)) __btrfs_kill_delayed_node() 1932 btrfs_release_delayed_iref(delayed_node); __btrfs_kill_delayed_node() 1934 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { __btrfs_kill_delayed_node() 1935 btrfs_delayed_inode_release_metadata(root, delayed_node); __btrfs_kill_delayed_node() 1936 btrfs_release_delayed_inode(delayed_node); __btrfs_kill_delayed_node() 1938 mutex_unlock(&delayed_node->mutex); __btrfs_kill_delayed_node() 1943 struct btrfs_delayed_node *delayed_node; btrfs_kill_delayed_inode_items() local 1945 delayed_node = btrfs_get_delayed_node(inode); btrfs_kill_delayed_inode_items() 1946 if (!delayed_node) btrfs_kill_delayed_inode_items() 1949 __btrfs_kill_delayed_node(delayed_node); btrfs_kill_delayed_inode_items() 1950 btrfs_release_delayed_node(delayed_node); btrfs_kill_delayed_inode_items() 50 btrfs_init_delayed_node( struct btrfs_delayed_node *delayed_node, struct btrfs_root *root, u64 inode_id) btrfs_init_delayed_node() argument 251 __btrfs_release_delayed_node( struct btrfs_delayed_node *delayed_node, int mod) __btrfs_release_delayed_node() argument 390 __btrfs_lookup_delayed_insertion_item( struct btrfs_delayed_node *delayed_node, struct btrfs_key *key) __btrfs_lookup_delayed_insertion_item() argument 503 __btrfs_first_delayed_insertion_item( struct btrfs_delayed_node *delayed_node) __btrfs_first_delayed_insertion_item() argument 516 __btrfs_first_delayed_deletion_item( struct btrfs_delayed_node *delayed_node) __btrfs_first_delayed_deletion_item() argument
|