Lines Matching defs:trans
106 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
110 static int link_to_fixup_dir(struct btrfs_trans_handle *trans,
113 static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
148 static int start_log_trans(struct btrfs_trans_handle *trans,
165 ret = btrfs_init_log_root_tree(trans, fs_info);
182 if (btrfs_need_log_full_commit(trans)) {
210 ret = btrfs_add_log_tree(trans, root);
312 /* the trans handle for the current replay */
313 struct btrfs_trans_handle *trans;
350 ret = btrfs_pin_extent_for_log_replay(wc->trans, eb->start,
376 static int overwrite_item(struct btrfs_trans_handle *trans,
497 ret = btrfs_insert_empty_item(trans, root, path,
507 btrfs_truncate_item(trans, path, item_size, 1);
509 btrfs_extend_item(trans, path, item_size - found_size);
573 trans->transid);
577 btrfs_mark_buffer_dirty(trans, path->nodes[0]);
624 static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
676 ret = btrfs_lookup_file_extent(trans, root, path,
711 ret = btrfs_drop_extents(trans, root, BTRFS_I(inode), &drop_args);
725 ret = btrfs_insert_empty_item(trans, root, path, key,
747 ret = btrfs_qgroup_trace_extent(trans,
774 ret = btrfs_inc_extent_ref(trans, &ref);
782 ret = btrfs_alloc_logged_file_extent(trans,
864 ret = btrfs_del_csums(trans, csum_root,
868 ret = btrfs_csum_file_blocks(trans,
881 ret = overwrite_item(trans, root, path, eb, slot, key);
893 ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
899 static int unlink_inode_for_log_replay(struct btrfs_trans_handle *trans,
906 ret = btrfs_unlink_inode(trans, dir, inode, name);
915 return btrfs_run_delayed_items(trans);
926 static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
953 ret = link_to_fixup_dir(trans, root, path, location.objectid);
957 ret = unlink_inode_for_log_replay(trans, dir, BTRFS_I(inode), &name);
1050 static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
1109 ret = unlink_inode_for_log_replay(trans, dir, inode,
1172 ret = unlink_inode_for_log_replay(trans,
1190 di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir),
1195 ret = drop_one_dir_item(trans, path, dir, di);
1202 di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir), name, 0);
1206 ret = drop_one_dir_item(trans, path, dir, di);
1263 static int unlink_old_inode_refs(struct btrfs_trans_handle *trans,
1319 ret = unlink_inode_for_log_replay(trans, BTRFS_I(dir),
1347 static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
1432 ret = __add_inode_ref(trans, root, path, log,
1443 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
1448 ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
1471 ret = unlink_old_inode_refs(trans, root, path, BTRFS_I(inode), eb, slot,
1477 ret = overwrite_item(trans, root, path, eb, slot, key);
1597 static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
1626 ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
1634 ret = replay_dir_deletes(trans, root, NULL, path,
1639 ret = btrfs_insert_orphan_item(trans, root, ino);
1649 static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1661 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
1677 ret = btrfs_del_item(trans, root, path);
1688 ret = fixup_inode_link_count(trans, root, inode);
1710 static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
1727 ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
1735 ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
1749 static noinline int insert_one_name(struct btrfs_trans_handle *trans,
1769 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
1779 static int delete_conflicting_dir_entry(struct btrfs_trans_handle *trans,
1804 return drop_one_dir_item(trans, path, dir, dst_di);
1823 static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1854 ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
1861 dir_dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
1867 ret = delete_conflicting_dir_entry(trans, BTRFS_I(dir), path,
1877 index_dst_di = btrfs_lookup_dir_index_item(trans, root, path,
1884 ret = delete_conflicting_dir_entry(trans, BTRFS_I(dir), path,
1930 ret = insert_one_name(trans, root, key->objectid, key->offset,
1942 ret = btrfs_update_inode(trans, root, BTRFS_I(dir));
1952 static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
1965 ret = replay_one_name(trans, root, path, eb, di, key);
2004 ret = link_to_fixup_dir(trans, root, fixup_path, di_key.objectid);
2098 static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
2132 log_di = btrfs_lookup_dir_index_item(trans, log, log_path,
2154 ret = link_to_fixup_dir(trans, root, path, location.objectid);
2159 ret = unlink_inode_for_log_replay(trans, BTRFS_I(dir), BTRFS_I(inode),
2174 static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
2235 di = btrfs_lookup_xattr(trans, root, path, ino,
2243 ret = btrfs_delete_one_dir_name(trans, root,
2282 static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
2353 ret = check_item_in_log(trans, log, path,
2439 ret = replay_xattr_deletes(wc->trans, root, log,
2445 ret = replay_dir_deletes(wc->trans,
2450 ret = overwrite_item(wc->trans, root, path,
2478 ret = btrfs_drop_extents(wc->trans, root,
2485 ret = btrfs_update_inode(wc->trans,
2493 ret = link_to_fixup_dir(wc->trans, root,
2504 ret = replay_one_dir_item(wc->trans, root, path,
2515 ret = overwrite_item(wc->trans, root, path,
2521 ret = add_inode_ref(wc->trans, root, log, path,
2527 ret = replay_one_extent(wc->trans, root, path,
2566 static int clean_log_buffer(struct btrfs_trans_handle *trans,
2572 btrfs_clear_buffer_dirty(trans, eb);
2576 if (trans) {
2577 ret = btrfs_pin_reserved_extent(trans, eb->start, eb->len);
2580 btrfs_redirty_list_add(trans->transaction, eb);
2588 static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
2640 ret = clean_log_buffer(trans, next);
2668 static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
2692 ret = clean_log_buffer(trans, path->nodes[*level]);
2709 static int walk_log_tree(struct btrfs_trans_handle *trans,
2729 wret = walk_down_log_tree(trans, log, path, &level, wc);
2737 wret = walk_up_log_tree(trans, log, path, &level, wc);
2754 ret = clean_log_buffer(trans, path->nodes[orig_level]);
2766 static int update_log_root(struct btrfs_trans_handle *trans,
2775 ret = btrfs_insert_root(trans, fs_info->log_root_tree,
2778 ret = btrfs_update_root(trans, fs_info->log_root_tree,
2862 int btrfs_sync_log(struct btrfs_trans_handle *trans,
2914 if (btrfs_need_log_full_commit(trans)) {
2943 btrfs_set_log_full_commit(trans);
2977 ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
3000 ret = update_log_root(trans, log, &new_root_item);
3006 btrfs_set_log_full_commit(trans);
3047 if (btrfs_need_log_full_commit(trans)) {
3065 btrfs_set_log_full_commit(trans);
3070 btrfs_set_log_full_commit(trans);
3079 btrfs_set_log_full_commit(trans);
3115 btrfs_set_log_full_commit(trans);
3116 btrfs_abort_transaction(trans, ret);
3126 btrfs_set_log_full_commit(trans);
3127 btrfs_abort_transaction(trans, ret);
3172 static void free_log_tree(struct btrfs_trans_handle *trans,
3182 ret = walk_log_tree(trans, log, &wc);
3207 if (trans)
3208 btrfs_abort_transaction(trans, ret);
3225 int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
3228 free_log_tree(trans, root->log_root);
3235 int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
3239 free_log_tree(trans, fs_info->log_root_tree);
3255 static int inode_logged(const struct btrfs_trans_handle *trans,
3263 if (inode->logged_trans == trans->transid)
3281 inode->logged_trans = trans->transid - 1;
3337 inode->logged_trans = trans->transid - 1;
3346 inode->logged_trans = trans->transid;
3371 static int del_logged_dentry(struct btrfs_trans_handle *trans,
3384 di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino,
3396 return btrfs_delete_one_dir_name(trans, log, path, di);
3420 void btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
3428 ret = inode_logged(trans, dir, NULL);
3432 btrfs_set_log_full_commit(trans);
3448 ret = del_logged_dentry(trans, root->log_root, path, btrfs_ino(dir),
3454 btrfs_set_log_full_commit(trans);
3459 void btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
3468 ret = inode_logged(trans, inode, NULL);
3472 btrfs_set_log_full_commit(trans);
3482 ret = btrfs_del_inode_ref(trans, log, name, btrfs_ino(inode),
3486 btrfs_set_log_full_commit(trans);
3495 static noinline int insert_dir_log_key(struct btrfs_trans_handle *trans,
3508 ret = btrfs_insert_empty_item(trans, log, path, &key, sizeof(*item));
3533 btrfs_mark_buffer_dirty(trans, path->nodes[0]);
3538 static int flush_dir_items_batch(struct btrfs_trans_handle *trans,
3590 ret = btrfs_insert_empty_items(trans, log, dst_path, &batch);
3630 static int process_dir_items_leaf(struct btrfs_trans_handle *trans,
3680 if (btrfs_dir_transid(src, di) < trans->transid) {
3682 ret = insert_dir_log_key(trans, log, dst_path,
3735 ret = flush_dir_items_batch(trans, inode, src, dst_path,
3749 static noinline int log_dir_items(struct btrfs_trans_handle *trans,
3768 ret = btrfs_search_forward(root, &min_key, path, trans->transid);
3860 ret = process_dir_items_leaf(trans, inode, path, dst_path, ctx,
3886 if (btrfs_header_generation(path->nodes[0]) != trans->transid) {
3921 ret = insert_dir_log_key(trans, log, path, ino,
4006 static noinline int log_directory_changes(struct btrfs_trans_handle *trans,
4024 ret = log_dir_items(trans, inode, path, dst_path,
4042 static int drop_inode_items(struct btrfs_trans_handle *trans,
4058 ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
4079 ret = btrfs_del_items(trans, log, path, start_slot,
4095 static int truncate_inode_items(struct btrfs_trans_handle *trans,
4107 return btrfs_truncate_inode_items(trans, log_root, &control);
4110 static void fill_inode_item(struct btrfs_trans_handle *trans,
4165 btrfs_set_token_inode_transid(&token, item, trans->transid);
4173 static int log_inode_item(struct btrfs_trans_handle *trans,
4190 if (!inode_item_dropped && inode->logged_trans == trans->transid) {
4191 ret = btrfs_search_slot(trans, log, &inode->location, path, 0, 1);
4205 ret = btrfs_insert_empty_item(trans, log, path, &inode->location,
4213 fill_inode_item(trans, path->nodes[0], inode_item, &inode->vfs_inode,
4219 static int log_csums(struct btrfs_trans_handle *trans,
4233 if (inode->last_reflink_trans < trans->transid)
4234 return btrfs_csum_file_blocks(trans, log_root, sums);
4255 ret = btrfs_del_csums(trans, log_root, sums->logical, sums->len);
4257 ret = btrfs_csum_file_blocks(trans, log_root, sums);
4265 static noinline int copy_items(struct btrfs_trans_handle *trans,
4356 trans->transid);
4373 inode->last_reflink_trans < trans->transid)
4406 csum_root = btrfs_csum_root(trans->fs_info, disk_bytenr);
4416 ret = log_csums(trans, inode, log, sums);
4437 ret = btrfs_insert_empty_items(trans, log, dst_path, &batch);
4465 if (btrfs_file_extent_generation(src, extent) < trans->transid &&
4467 inode->last_reflink_trans < trans->transid)
4479 fill_inode_item(trans, dst_path->nodes[0], inode_item,
4491 btrfs_mark_buffer_dirty(trans, dst_path->nodes[0]);
4514 static int log_extent_csums(struct btrfs_trans_handle *trans,
4582 ret = log_csums(trans, inode, log_root, sums);
4602 csum_root = btrfs_csum_root(trans->fs_info, em->block_start);
4614 ret = log_csums(trans, inode, log_root, sums);
4622 static int log_one_extent(struct btrfs_trans_handle *trans,
4637 btrfs_set_stack_file_extent_generation(&fi, trans->transid);
4658 ret = log_extent_csums(trans, inode, log, em, ctx);
4677 ret = btrfs_drop_extents(trans, log, inode, &drop_args);
4687 ret = btrfs_insert_empty_item(trans, log, path, &key,
4696 btrfs_mark_buffer_dirty(trans, leaf);
4711 static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
4778 ret = copy_items(trans, inode, dst_path, path,
4808 ret = truncate_inode_items(trans, root->log_root, inode,
4828 ret = copy_items(trans, inode, dst_path, path,
4836 static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4865 if (em->generation < trans->transid)
4899 ret = log_one_extent(trans, inode, em, path, ctx);
4908 ret = btrfs_log_prealloc_extents(trans, inode, path);
4927 atomic_inc(&trans->transaction->pending_ordered);
4986 static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans,
5017 ret = copy_items(trans, inode, dst_path, path,
5043 ret = copy_items(trans, inode, dst_path, path,
5064 static int btrfs_log_holes(struct btrfs_trans_handle *trans,
5115 ret = btrfs_insert_hole_extent(trans, root->log_root,
5146 ret = btrfs_insert_hole_extent(trans, root->log_root, ino,
5303 static bool need_log_inode(const struct btrfs_trans_handle *trans,
5310 if (S_ISDIR(inode->vfs_inode.i_mode) && inode->last_trans < trans->transid)
5322 if (inode_logged(trans, inode, NULL) == 1 &&
5370 static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5429 if (btrfs_dir_transid(leaf, di) < trans->transid)
5442 if (!need_log_inode(trans, BTRFS_I(di_inode))) {
5450 ret = btrfs_log_inode(trans, BTRFS_I(di_inode),
5572 static int add_conflicting_inode(struct btrfs_trans_handle *trans,
5609 * case it has a last_unlink_trans == trans->transid, due to moving
5670 if (!need_log_inode(trans, BTRFS_I(inode))) {
5688 static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
5748 ret = btrfs_log_inode(trans, BTRFS_I(inode),
5766 if (!need_log_inode(trans, BTRFS_I(inode))) {
5778 ret = btrfs_log_inode(trans, BTRFS_I(inode), LOG_INODE_EXISTS, ctx);
5791 static int copy_inode_items_to_log(struct btrfs_trans_handle *trans,
5809 ret = btrfs_search_forward(root, min_key, path, trans->transid);
5836 (inode->generation == trans->transid ||
5854 ret = copy_items(trans, inode, dst_path, path,
5862 ret = add_conflicting_inode(trans, root, path,
5873 ret = copy_items(trans, inode, dst_path, path,
5891 ret = copy_items(trans, inode, dst_path, path, ins_start_slot,
5905 ret = copy_items(trans, inode, dst_path, path,
5931 ret = copy_items(trans, inode, dst_path, path, ins_start_slot,
5943 ret = btrfs_log_prealloc_extents(trans, inode, dst_path);
5949 static int insert_delayed_items_batch(struct btrfs_trans_handle *trans,
5958 ret = btrfs_insert_empty_items(trans, log, path, batch);
5977 static int log_delayed_insertion_items(struct btrfs_trans_handle *trans,
5985 const int leaf_data_size = BTRFS_LEAF_DATA_SIZE(trans->fs_info);
6038 ret = insert_delayed_items_batch(trans, log, path,
6061 ret = insert_delayed_items_batch(trans, log, path, &batch, first);
6072 static int log_delayed_deletions_full(struct btrfs_trans_handle *trans,
6106 ret = insert_dir_log_key(trans, inode->root->log_root, path,
6116 static int batch_delete_dir_index_items(struct btrfs_trans_handle *trans,
6147 return btrfs_del_items(trans, inode->root->log_root, path,
6151 static int log_delayed_deletions_incremental(struct btrfs_trans_handle *trans,
6176 ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
6180 ret = batch_delete_dir_index_items(trans, inode, path, ctx,
6209 ret = insert_dir_log_key(trans, log, path, key.objectid,
6223 static int log_delayed_deletion_items(struct btrfs_trans_handle *trans,
6239 return log_delayed_deletions_incremental(trans, inode, path,
6242 return log_delayed_deletions_full(trans, inode, path, delayed_del_list,
6250 static int log_new_delayed_dentries(struct btrfs_trans_handle *trans,
6256 struct btrfs_fs_info *fs_info = trans->fs_info;
6288 if (!need_log_inode(trans, BTRFS_I(di_inode))) {
6297 ret = btrfs_log_inode(trans, BTRFS_I(di_inode), log_mode, ctx);
6300 ret = log_new_dir_dentries(trans, BTRFS_I(di_inode), ctx);
6328 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
6410 ret = btrfs_commit_inode_delayed_items(trans, inode);
6434 ret = inode_logged(trans, inode, path);
6447 if (full_dir_logging && inode->last_unlink_trans >= trans->transid) {
6459 ret = drop_inode_items(trans, log, path, inode,
6485 ret = drop_inode_items(trans, log, path,
6493 ret = truncate_inode_items(trans, log,
6503 ret = drop_inode_items(trans, log, path, inode,
6526 ret = copy_inode_items_to_log(trans, inode, &min_key, &max_key,
6535 ret = btrfs_log_all_xattrs(trans, inode, path, dst_path);
6542 ret = btrfs_log_holes(trans, inode, path);
6550 ret = log_inode_item(trans, log, dst_path, inode, inode_item_dropped);
6561 if (!xattrs_logged && inode->logged_trans < trans->transid) {
6562 ret = btrfs_log_all_xattrs(trans, inode, path, dst_path);
6569 ret = btrfs_log_changed_extents(trans, inode, dst_path, ctx);
6582 ret = log_directory_changes(trans, inode, path, dst_path, ctx);
6585 ret = log_delayed_insertion_items(trans, inode, path,
6589 ret = log_delayed_deletion_items(trans, inode, path,
6596 inode->logged_trans = trans->transid;
6648 ret = log_conflicting_inodes(trans, inode->root, ctx);
6652 ret = log_new_delayed_dentries(trans, inode,
6662 static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
6666 struct btrfs_fs_info *fs_info = trans->fs_info;
6761 if (!need_log_inode(trans, BTRFS_I(dir_inode))) {
6767 ret = btrfs_log_inode(trans, BTRFS_I(dir_inode),
6770 ret = log_new_dir_dentries(trans,
6784 static int log_new_ancestors(struct btrfs_trans_handle *trans,
6813 if (BTRFS_I(inode)->generation >= trans->transid &&
6814 need_log_inode(trans, BTRFS_I(inode)))
6815 ret = btrfs_log_inode(trans, BTRFS_I(inode),
6849 static int log_new_ancestors_fast(struct btrfs_trans_handle *trans,
6868 if (inode->generation >= trans->transid &&
6869 need_log_inode(trans, inode)) {
6870 ret = btrfs_log_inode(trans, inode,
6887 static int log_all_new_ancestors(struct btrfs_trans_handle *trans,
6903 return log_new_ancestors_fast(trans, inode, parent, ctx);
6958 ret = log_new_ancestors(trans, root, path, ctx);
6976 static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
7002 if ((btrfs_inode_in_log(inode, trans->transid) &&
7009 ret = start_log_trans(trans, root, ctx);
7013 ret = btrfs_log_inode(trans, inode, inode_only, ctx);
7024 inode->generation < trans->transid &&
7025 inode->last_unlink_trans < trans->transid) {
7074 if (inode->last_unlink_trans >= trans->transid) {
7075 ret = btrfs_log_all_parents(trans, inode, ctx);
7080 ret = log_all_new_ancestors(trans, inode, parent, ctx);
7085 ret = log_new_dir_dentries(trans, inode, ctx);
7090 btrfs_set_log_full_commit(trans);
7107 int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
7114 ret = btrfs_log_inode_parent(trans, BTRFS_I(d_inode(dentry)), parent,
7129 struct btrfs_trans_handle *trans;
7145 trans = btrfs_start_transaction(fs_info->tree_root, 0);
7146 if (IS_ERR(trans)) {
7147 ret = PTR_ERR(trans);
7151 wc.trans = trans;
7154 ret = walk_log_tree(trans, log_root_tree, &wc);
7156 btrfs_abort_transaction(trans, ret);
7169 btrfs_abort_transaction(trans, ret);
7186 btrfs_abort_transaction(trans, ret);
7207 ret = btrfs_pin_extent_for_log_replay(trans,
7214 btrfs_abort_transaction(trans, ret);
7219 ret = btrfs_record_root_in_trans(trans, wc.replay_dest);
7222 btrfs_abort_transaction(trans, ret);
7224 ret = walk_log_tree(trans, log, &wc);
7227 ret = fixup_inode_link_counts(trans, wc.replay_dest,
7230 btrfs_abort_transaction(trans, ret);
7248 btrfs_abort_transaction(trans, ret);
7280 ret = btrfs_commit_transaction(trans);
7290 if (wc.trans)
7291 btrfs_end_transaction(wc.trans);
7308 void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
7323 inode->last_unlink_trans = trans->transid;
7335 if (inode_logged(trans, dir, NULL) == 1)
7344 if (inode_logged(trans, inode, NULL) == 1)
7355 dir->last_unlink_trans = trans->transid;
7371 void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans,
7375 dir->last_unlink_trans = trans->transid;
7382 * @trans: Transaction handle.
7396 void btrfs_log_new_name(struct btrfs_trans_handle *trans,
7411 inode->last_unlink_trans = trans->transid;
7417 ret = inode_logged(trans, inode, NULL);
7428 ret = inode_logged(trans, old_dir, NULL);
7443 if (old_dir && old_dir->logged_trans == trans->transid) {
7491 ret = del_logged_dentry(trans, log, path, btrfs_ino(old_dir),
7499 ret = insert_dir_log_key(trans, log, path,
7520 btrfs_log_inode_parent(trans, inode, parent, LOG_INODE_EXISTS, &ctx);
7530 btrfs_set_log_full_commit(trans);