Lines Matching refs:delayed_node
47 struct btrfs_delayed_node *delayed_node, in btrfs_init_delayed_node() argument
50 delayed_node->root = root; in btrfs_init_delayed_node()
51 delayed_node->inode_id = inode_id; in btrfs_init_delayed_node()
52 refcount_set(&delayed_node->refs, 0); in btrfs_init_delayed_node()
53 delayed_node->ins_root = RB_ROOT_CACHED; in btrfs_init_delayed_node()
54 delayed_node->del_root = RB_ROOT_CACHED; in btrfs_init_delayed_node()
55 mutex_init(&delayed_node->mutex); in btrfs_init_delayed_node()
56 INIT_LIST_HEAD(&delayed_node->n_list); in btrfs_init_delayed_node()
57 INIT_LIST_HEAD(&delayed_node->p_list); in btrfs_init_delayed_node()
67 node = READ_ONCE(btrfs_inode->delayed_node); in btrfs_get_delayed_node()
77 if (btrfs_inode->delayed_node) { in btrfs_get_delayed_node()
79 BUG_ON(btrfs_inode->delayed_node != node); in btrfs_get_delayed_node()
102 btrfs_inode->delayed_node = node; in btrfs_get_delayed_node()
151 btrfs_inode->delayed_node = node; in btrfs_get_or_create_delayed_node()
246 struct btrfs_delayed_node *delayed_node, in __btrfs_release_delayed_node() argument
251 if (!delayed_node) in __btrfs_release_delayed_node()
254 delayed_root = delayed_node->root->fs_info->delayed_root; in __btrfs_release_delayed_node()
256 mutex_lock(&delayed_node->mutex); in __btrfs_release_delayed_node()
257 if (delayed_node->count) in __btrfs_release_delayed_node()
258 btrfs_queue_delayed_node(delayed_root, delayed_node, mod); in __btrfs_release_delayed_node()
260 btrfs_dequeue_delayed_node(delayed_root, delayed_node); in __btrfs_release_delayed_node()
261 mutex_unlock(&delayed_node->mutex); in __btrfs_release_delayed_node()
263 if (refcount_dec_and_test(&delayed_node->refs)) { in __btrfs_release_delayed_node()
264 struct btrfs_root *root = delayed_node->root; in __btrfs_release_delayed_node()
271 ASSERT(refcount_read(&delayed_node->refs) == 0); in __btrfs_release_delayed_node()
273 delayed_node->inode_id); in __btrfs_release_delayed_node()
275 kmem_cache_free(delayed_node_cache, delayed_node); in __btrfs_release_delayed_node()
321 item->delayed_node = node; in btrfs_alloc_delayed_item()
359 static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node, in __btrfs_add_delayed_item() argument
369 root = &delayed_node->ins_root; in __btrfs_add_delayed_item()
371 root = &delayed_node->del_root; in __btrfs_add_delayed_item()
395 ins->index >= delayed_node->index_cnt) in __btrfs_add_delayed_item()
396 delayed_node->index_cnt = ins->index + 1; in __btrfs_add_delayed_item()
398 delayed_node->count++; in __btrfs_add_delayed_item()
399 atomic_inc(&delayed_node->root->fs_info->delayed_root->items); in __btrfs_add_delayed_item()
415 struct btrfs_delayed_node *delayed_node = delayed_item->delayed_node; in __btrfs_remove_delayed_item() local
424 lockdep_assert_held(&delayed_node->mutex); in __btrfs_remove_delayed_item()
426 delayed_root = delayed_node->root->fs_info->delayed_root; in __btrfs_remove_delayed_item()
431 root = &delayed_node->ins_root; in __btrfs_remove_delayed_item()
433 root = &delayed_node->del_root; in __btrfs_remove_delayed_item()
437 delayed_node->count--; in __btrfs_remove_delayed_item()
452 struct btrfs_delayed_node *delayed_node) in __btrfs_first_delayed_insertion_item() argument
457 p = rb_first_cached(&delayed_node->ins_root); in __btrfs_first_delayed_insertion_item()
465 struct btrfs_delayed_node *delayed_node) in __btrfs_first_delayed_deletion_item() argument
470 p = rb_first_cached(&delayed_node->del_root); in __btrfs_first_delayed_deletion_item()
515 item->delayed_node->inode_id, in btrfs_delayed_item_reserve_metadata()
544 item->delayed_node->inode_id, in btrfs_delayed_item_release_metadata()
652 struct btrfs_delayed_node *node = first_item->delayed_node; in btrfs_insert_delayed_item()
840 const u64 ino = item->delayed_node->inode_id; in btrfs_batch_delete_items()
972 static void btrfs_release_delayed_inode(struct btrfs_delayed_node *delayed_node) in btrfs_release_delayed_inode() argument
976 if (delayed_node && in btrfs_release_delayed_inode()
977 test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { in btrfs_release_delayed_inode()
978 BUG_ON(!delayed_node->root); in btrfs_release_delayed_inode()
979 clear_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags); in btrfs_release_delayed_inode()
980 delayed_node->count--; in btrfs_release_delayed_inode()
982 delayed_root = delayed_node->root->fs_info->delayed_root; in btrfs_release_delayed_inode()
987 static void btrfs_release_delayed_iref(struct btrfs_delayed_node *delayed_node) in btrfs_release_delayed_iref() argument
990 if (test_and_clear_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags)) { in btrfs_release_delayed_iref()
993 ASSERT(delayed_node->root); in btrfs_release_delayed_iref()
994 delayed_node->count--; in btrfs_release_delayed_iref()
996 delayed_root = delayed_node->root->fs_info->delayed_root; in btrfs_release_delayed_iref()
1205 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); in btrfs_commit_inode_delayed_items() local
1210 if (!delayed_node) in btrfs_commit_inode_delayed_items()
1213 mutex_lock(&delayed_node->mutex); in btrfs_commit_inode_delayed_items()
1214 if (!delayed_node->count) { in btrfs_commit_inode_delayed_items()
1215 mutex_unlock(&delayed_node->mutex); in btrfs_commit_inode_delayed_items()
1216 btrfs_release_delayed_node(delayed_node); in btrfs_commit_inode_delayed_items()
1219 mutex_unlock(&delayed_node->mutex); in btrfs_commit_inode_delayed_items()
1223 btrfs_release_delayed_node(delayed_node); in btrfs_commit_inode_delayed_items()
1228 trans->block_rsv = &delayed_node->root->fs_info->delayed_block_rsv; in btrfs_commit_inode_delayed_items()
1230 ret = __btrfs_commit_inode_delayed_items(trans, path, delayed_node); in btrfs_commit_inode_delayed_items()
1232 btrfs_release_delayed_node(delayed_node); in btrfs_commit_inode_delayed_items()
1243 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); in btrfs_commit_inode_delayed_inode() local
1248 if (!delayed_node) in btrfs_commit_inode_delayed_inode()
1251 mutex_lock(&delayed_node->mutex); in btrfs_commit_inode_delayed_inode()
1252 if (!test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { in btrfs_commit_inode_delayed_inode()
1253 mutex_unlock(&delayed_node->mutex); in btrfs_commit_inode_delayed_inode()
1254 btrfs_release_delayed_node(delayed_node); in btrfs_commit_inode_delayed_inode()
1257 mutex_unlock(&delayed_node->mutex); in btrfs_commit_inode_delayed_inode()
1259 trans = btrfs_join_transaction(delayed_node->root); in btrfs_commit_inode_delayed_inode()
1274 mutex_lock(&delayed_node->mutex); in btrfs_commit_inode_delayed_inode()
1275 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) in btrfs_commit_inode_delayed_inode()
1276 ret = __btrfs_update_delayed_inode(trans, delayed_node->root, in btrfs_commit_inode_delayed_inode()
1277 path, delayed_node); in btrfs_commit_inode_delayed_inode()
1280 mutex_unlock(&delayed_node->mutex); in btrfs_commit_inode_delayed_inode()
1288 btrfs_release_delayed_node(delayed_node); in btrfs_commit_inode_delayed_inode()
1295 struct btrfs_delayed_node *delayed_node; in btrfs_remove_delayed_node() local
1297 delayed_node = READ_ONCE(inode->delayed_node); in btrfs_remove_delayed_node()
1298 if (!delayed_node) in btrfs_remove_delayed_node()
1301 inode->delayed_node = NULL; in btrfs_remove_delayed_node()
1302 btrfs_release_delayed_node(delayed_node); in btrfs_remove_delayed_node()
1317 struct btrfs_delayed_node *delayed_node = NULL; in btrfs_async_run_delayed_root() local
1334 delayed_node = btrfs_first_prepared_delayed_node(delayed_root); in btrfs_async_run_delayed_root()
1335 if (!delayed_node) in btrfs_async_run_delayed_root()
1338 root = delayed_node->root; in btrfs_async_run_delayed_root()
1343 btrfs_release_prepared_delayed_node(delayed_node); in btrfs_async_run_delayed_root()
1351 __btrfs_commit_inode_delayed_items(trans, path, delayed_node); in btrfs_async_run_delayed_root()
1358 btrfs_release_prepared_delayed_node(delayed_node); in btrfs_async_run_delayed_root()
1464 struct btrfs_delayed_node *delayed_node; in btrfs_insert_delayed_dir_index() local
1471 delayed_node = btrfs_get_or_create_delayed_node(dir); in btrfs_insert_delayed_dir_index()
1472 if (IS_ERR(delayed_node)) in btrfs_insert_delayed_dir_index()
1473 return PTR_ERR(delayed_node); in btrfs_insert_delayed_dir_index()
1476 delayed_node, in btrfs_insert_delayed_dir_index()
1495 mutex_lock(&delayed_node->mutex); in btrfs_insert_delayed_dir_index()
1505 ret = __btrfs_add_delayed_item(delayed_node, delayed_item); in btrfs_insert_delayed_dir_index()
1509 name_len, name, index, btrfs_root_id(delayed_node->root), in btrfs_insert_delayed_dir_index()
1510 delayed_node->inode_id, dir->index_cnt, in btrfs_insert_delayed_dir_index()
1511 delayed_node->index_cnt, ret); in btrfs_insert_delayed_dir_index()
1514 mutex_unlock(&delayed_node->mutex); in btrfs_insert_delayed_dir_index()
1518 if (delayed_node->index_item_leaves == 0 || in btrfs_insert_delayed_dir_index()
1519 delayed_node->curr_index_batch_size + data_len > leaf_data_size) { in btrfs_insert_delayed_dir_index()
1520 delayed_node->curr_index_batch_size = data_len; in btrfs_insert_delayed_dir_index()
1523 delayed_node->curr_index_batch_size += data_len; in btrfs_insert_delayed_dir_index()
1536 mutex_unlock(&delayed_node->mutex); in btrfs_insert_delayed_dir_index()
1540 delayed_node->index_item_leaves++; in btrfs_insert_delayed_dir_index()
1544 mutex_unlock(&delayed_node->mutex); in btrfs_insert_delayed_dir_index()
1547 btrfs_release_delayed_node(delayed_node); in btrfs_insert_delayed_dir_index()
1652 struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); in btrfs_inode_delayed_dir_index_count() local
1654 if (!delayed_node) in btrfs_inode_delayed_dir_index_count()
1662 if (!delayed_node->index_cnt) { in btrfs_inode_delayed_dir_index_count()
1663 btrfs_release_delayed_node(delayed_node); in btrfs_inode_delayed_dir_index_count()
1667 inode->index_cnt = delayed_node->index_cnt; in btrfs_inode_delayed_dir_index_count()
1668 btrfs_release_delayed_node(delayed_node); in btrfs_inode_delayed_dir_index_count()
1677 struct btrfs_delayed_node *delayed_node; in btrfs_readdir_get_delayed_items() local
1680 delayed_node = btrfs_get_delayed_node(BTRFS_I(inode)); in btrfs_readdir_get_delayed_items()
1681 if (!delayed_node) in btrfs_readdir_get_delayed_items()
1691 mutex_lock(&delayed_node->mutex); in btrfs_readdir_get_delayed_items()
1692 item = __btrfs_first_delayed_insertion_item(delayed_node); in btrfs_readdir_get_delayed_items()
1699 item = __btrfs_first_delayed_deletion_item(delayed_node); in btrfs_readdir_get_delayed_items()
1705 mutex_unlock(&delayed_node->mutex); in btrfs_readdir_get_delayed_items()
1715 refcount_dec(&delayed_node->refs); in btrfs_readdir_get_delayed_items()
1860 struct btrfs_delayed_node *delayed_node; in btrfs_fill_inode() local
1863 delayed_node = btrfs_get_delayed_node(BTRFS_I(inode)); in btrfs_fill_inode()
1864 if (!delayed_node) in btrfs_fill_inode()
1867 mutex_lock(&delayed_node->mutex); in btrfs_fill_inode()
1868 if (!test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { in btrfs_fill_inode()
1869 mutex_unlock(&delayed_node->mutex); in btrfs_fill_inode()
1870 btrfs_release_delayed_node(delayed_node); in btrfs_fill_inode()
1874 inode_item = &delayed_node->inode_item; in btrfs_fill_inode()
1911 mutex_unlock(&delayed_node->mutex); in btrfs_fill_inode()
1912 btrfs_release_delayed_node(delayed_node); in btrfs_fill_inode()
1920 struct btrfs_delayed_node *delayed_node; in btrfs_delayed_update_inode() local
1923 delayed_node = btrfs_get_or_create_delayed_node(inode); in btrfs_delayed_update_inode()
1924 if (IS_ERR(delayed_node)) in btrfs_delayed_update_inode()
1925 return PTR_ERR(delayed_node); in btrfs_delayed_update_inode()
1927 mutex_lock(&delayed_node->mutex); in btrfs_delayed_update_inode()
1928 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { in btrfs_delayed_update_inode()
1929 fill_stack_inode_item(trans, &delayed_node->inode_item, in btrfs_delayed_update_inode()
1934 ret = btrfs_delayed_inode_reserve_metadata(trans, root, delayed_node); in btrfs_delayed_update_inode()
1938 fill_stack_inode_item(trans, &delayed_node->inode_item, &inode->vfs_inode); in btrfs_delayed_update_inode()
1939 set_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags); in btrfs_delayed_update_inode()
1940 delayed_node->count++; in btrfs_delayed_update_inode()
1943 mutex_unlock(&delayed_node->mutex); in btrfs_delayed_update_inode()
1944 btrfs_release_delayed_node(delayed_node); in btrfs_delayed_update_inode()
1951 struct btrfs_delayed_node *delayed_node; in btrfs_delayed_delete_inode_ref() local
1961 delayed_node = btrfs_get_or_create_delayed_node(inode); in btrfs_delayed_delete_inode_ref()
1962 if (IS_ERR(delayed_node)) in btrfs_delayed_delete_inode_ref()
1963 return PTR_ERR(delayed_node); in btrfs_delayed_delete_inode_ref()
1979 mutex_lock(&delayed_node->mutex); in btrfs_delayed_delete_inode_ref()
1980 if (test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags)) in btrfs_delayed_delete_inode_ref()
1983 set_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags); in btrfs_delayed_delete_inode_ref()
1984 delayed_node->count++; in btrfs_delayed_delete_inode_ref()
1987 mutex_unlock(&delayed_node->mutex); in btrfs_delayed_delete_inode_ref()
1988 btrfs_release_delayed_node(delayed_node); in btrfs_delayed_delete_inode_ref()
1992 static void __btrfs_kill_delayed_node(struct btrfs_delayed_node *delayed_node) in __btrfs_kill_delayed_node() argument
1994 struct btrfs_root *root = delayed_node->root; in __btrfs_kill_delayed_node()
1998 mutex_lock(&delayed_node->mutex); in __btrfs_kill_delayed_node()
1999 curr_item = __btrfs_first_delayed_insertion_item(delayed_node); in __btrfs_kill_delayed_node()
2006 if (delayed_node->index_item_leaves > 0) { in __btrfs_kill_delayed_node()
2007 btrfs_delayed_item_release_leaves(delayed_node, in __btrfs_kill_delayed_node()
2008 delayed_node->index_item_leaves); in __btrfs_kill_delayed_node()
2009 delayed_node->index_item_leaves = 0; in __btrfs_kill_delayed_node()
2012 curr_item = __btrfs_first_delayed_deletion_item(delayed_node); in __btrfs_kill_delayed_node()
2020 btrfs_release_delayed_iref(delayed_node); in __btrfs_kill_delayed_node()
2022 if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) { in __btrfs_kill_delayed_node()
2023 btrfs_delayed_inode_release_metadata(fs_info, delayed_node, false); in __btrfs_kill_delayed_node()
2024 btrfs_release_delayed_inode(delayed_node); in __btrfs_kill_delayed_node()
2026 mutex_unlock(&delayed_node->mutex); in __btrfs_kill_delayed_node()
2031 struct btrfs_delayed_node *delayed_node; in btrfs_kill_delayed_inode_items() local
2033 delayed_node = btrfs_get_delayed_node(inode); in btrfs_kill_delayed_inode_items()
2034 if (!delayed_node) in btrfs_kill_delayed_inode_items()
2037 __btrfs_kill_delayed_node(delayed_node); in btrfs_kill_delayed_inode_items()
2038 btrfs_release_delayed_node(delayed_node); in btrfs_kill_delayed_inode_items()