Lines Matching defs:trans

96 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
100 static int link_to_fixup_dir(struct btrfs_trans_handle *trans,
103 static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
137 static int start_log_trans(struct btrfs_trans_handle *trans,
147 if (btrfs_need_log_full_commit(trans)) {
161 ret = btrfs_init_log_root_tree(trans, fs_info);
166 ret = btrfs_add_log_tree(trans, root);
283 /* the trans handle for the current replay */
284 struct btrfs_trans_handle *trans;
316 ret = btrfs_pin_extent_for_log_replay(wc->trans, eb->start,
344 static noinline int overwrite_item(struct btrfs_trans_handle *trans,
460 ret = btrfs_insert_empty_item(trans, root, path,
537 trans->transid);
573 static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
624 ret = btrfs_lookup_file_extent(trans, root, path,
656 ret = btrfs_drop_extents(trans, root, inode, start, extent_end, 1);
670 ret = btrfs_insert_empty_item(trans, root, path, key,
692 ret = btrfs_qgroup_trace_extent(trans,
720 ret = btrfs_inc_extent_ref(trans, &ref);
728 ret = btrfs_alloc_logged_file_extent(trans,
806 ret = btrfs_del_csums(trans,
811 ret = btrfs_csum_file_blocks(trans,
823 ret = overwrite_item(trans, root, path, eb, slot, key);
835 ret = btrfs_update_inode(trans, root, inode);
850 static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
880 ret = link_to_fixup_dir(trans, root, path, location.objectid);
884 ret = btrfs_unlink_inode(trans, root, dir, BTRFS_I(inode), name,
889 ret = btrfs_run_delayed_items(trans);
985 static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
1050 ret = btrfs_unlink_inode(trans, root, dir, inode,
1055 ret = btrfs_run_delayed_items(trans);
1124 ret = btrfs_unlink_inode(trans, root,
1131 trans);
1149 di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir),
1155 ret = drop_one_dir_item(trans, root, path, dir, di);
1162 di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir),
1167 ret = drop_one_dir_item(trans, root, path, dir, di);
1227 static int unlink_old_inode_refs(struct btrfs_trans_handle *trans,
1287 ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
1299 ret = btrfs_run_delayed_items(trans);
1357 static int add_link(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1394 ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(other_inode),
1405 ret = btrfs_run_delayed_items(trans);
1409 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
1424 static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
1515 ret = __add_inode_ref(trans, root, path, log,
1540 ret = btrfs_unlink_inode(trans, root,
1559 ret = btrfs_run_delayed_items(trans);
1565 ret = add_link(trans, root, dir, inode, name, namelen,
1570 btrfs_update_inode(trans, root, inode);
1591 ret = unlink_old_inode_refs(trans, root, path, BTRFS_I(inode), eb, slot,
1597 ret = overwrite_item(trans, root, path, eb, slot, key);
1606 static int insert_orphan_item(struct btrfs_trans_handle *trans,
1611 ret = btrfs_insert_orphan_item(trans, root, ino);
1729 static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
1758 btrfs_update_inode(trans, root, inode);
1764 ret = replay_dir_deletes(trans, root, NULL, path,
1769 ret = insert_orphan_item(trans, root, ino);
1777 static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1789 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
1805 ret = btrfs_del_item(trans, root, path);
1816 ret = fixup_inode_link_count(trans, root, inode);
1838 static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
1855 ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
1863 ret = btrfs_update_inode(trans, root, inode);
1877 static noinline int insert_one_name(struct btrfs_trans_handle *trans,
1897 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
1923 static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1958 ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
1966 dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
1969 dst_di = btrfs_lookup_dir_index_item(trans, root, path,
2011 ret = drop_one_dir_item(trans, root, path, BTRFS_I(dir), dst_di);
2021 ret = btrfs_update_inode(trans, root, dir);
2061 ret = insert_one_name(trans, root, key->objectid, key->offset,
2078 static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
2097 ret = replay_one_name(trans, root, path, eb, di, key);
2142 ret = link_to_fixup_dir(trans, root, fixup_path,
2240 static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
2279 log_di = btrfs_lookup_dir_item(trans, log, log_path,
2283 log_di = btrfs_lookup_dir_index_item(trans, log,
2299 ret = link_to_fixup_dir(trans, root,
2308 ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
2311 ret = btrfs_run_delayed_items(trans);
2343 static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
2404 di = btrfs_lookup_xattr(trans, root, path, ino,
2412 ret = btrfs_delete_one_dir_name(trans, root,
2451 static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
2521 ret = check_item_in_log(trans, root, log, path,
2611 ret = replay_xattr_deletes(wc->trans, root, log,
2617 ret = replay_dir_deletes(wc->trans,
2622 ret = overwrite_item(wc->trans, root, path,
2646 ret = btrfs_drop_extents(wc->trans, root, inode,
2650 ret = btrfs_update_inode(wc->trans,
2658 ret = link_to_fixup_dir(wc->trans, root,
2669 ret = replay_one_dir_item(wc->trans, root, path,
2680 ret = overwrite_item(wc->trans, root, path,
2686 ret = add_inode_ref(wc->trans, root, log, path,
2692 ret = replay_one_extent(wc->trans, root, path,
2697 ret = replay_one_dir_item(wc->trans, root, path,
2730 static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
2780 if (trans) {
2786 ret = btrfs_pin_reserved_extent(trans,
2820 static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
2849 if (trans) {
2855 ret = btrfs_pin_reserved_extent(trans,
2881 static int walk_log_tree(struct btrfs_trans_handle *trans,
2902 wret = walk_down_log_tree(trans, log, path, &level, wc);
2910 wret = walk_up_log_tree(trans, log, path, &level, wc);
2931 if (trans) {
2937 ret = btrfs_pin_reserved_extent(trans,
2958 static int update_log_root(struct btrfs_trans_handle *trans,
2967 ret = btrfs_insert_root(trans, fs_info->log_root_tree,
2970 ret = btrfs_update_root(trans, fs_info->log_root_tree,
3059 int btrfs_sync_log(struct btrfs_trans_handle *trans,
3109 if (btrfs_need_log_full_commit(trans)) {
3127 btrfs_abort_transaction(trans, ret);
3128 btrfs_set_log_full_commit(trans);
3172 ret = update_log_root(trans, log, &new_root_item);
3178 btrfs_set_log_full_commit(trans);
3181 btrfs_abort_transaction(trans, ret);
3222 if (btrfs_need_log_full_commit(trans)) {
3235 btrfs_set_log_full_commit(trans);
3236 btrfs_abort_transaction(trans, ret);
3245 btrfs_set_log_full_commit(trans);
3267 btrfs_set_log_full_commit(trans);
3268 btrfs_abort_transaction(trans, ret);
3307 static void free_log_tree(struct btrfs_trans_handle *trans,
3316 ret = walk_log_tree(trans, log, &wc);
3318 if (trans)
3319 btrfs_abort_transaction(trans, ret);
3334 int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
3337 free_log_tree(trans, root->log_root);
3344 int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
3348 free_log_tree(trans, fs_info->log_root_tree);
3364 static bool inode_logged(struct btrfs_trans_handle *trans,
3367 if (inode->logged_trans == trans->transid)
3370 if (inode->last_trans == trans->transid &&
3372 !test_bit(BTRFS_FS_LOG_RECOVERING, &trans->fs_info->flags))
3399 int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
3412 if (!inode_logged(trans, dir))
3428 di = btrfs_lookup_dir_item(trans, log, path, dir_ino,
3435 ret = btrfs_delete_one_dir_name(trans, log, path, di);
3443 di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino,
3450 ret = btrfs_delete_one_dir_name(trans, log, path, di);
3469 ret = btrfs_search_slot(trans, log, &key, path, 0, 1);
3496 btrfs_set_log_full_commit(trans);
3500 btrfs_abort_transaction(trans, err);
3509 int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
3518 if (!inode_logged(trans, inode))
3527 ret = btrfs_del_inode_ref(trans, log, name, name_len, btrfs_ino(inode),
3531 btrfs_set_log_full_commit(trans);
3534 btrfs_abort_transaction(trans, ret);
3545 static noinline int insert_dir_log_key(struct btrfs_trans_handle *trans,
3561 ret = btrfs_insert_empty_item(trans, log, path, &key, sizeof(*item));
3578 static noinline int log_dir_items(struct btrfs_trans_handle *trans,
3602 ret = btrfs_search_forward(root, &min_key, path, trans->transid);
3642 ret = overwrite_item(trans, log, dst_path,
3688 ret = overwrite_item(trans, log, dst_path, src, i,
3721 (btrfs_dir_transid(src, di) == trans->transid ||
3745 if (btrfs_header_generation(path->nodes[0]) != trans->transid) {
3746 ret = overwrite_item(trans, log, dst_path,
3766 ret = insert_dir_log_key(trans, log, path, key_type,
3786 static noinline int log_directory_changes(struct btrfs_trans_handle *trans,
3801 ret = log_dir_items(trans, root, inode, path, dst_path, key_type,
3823 static int drop_objectid_items(struct btrfs_trans_handle *trans,
3838 ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
3859 ret = btrfs_del_items(trans, log, path, start_slot,
3875 static void fill_inode_item(struct btrfs_trans_handle *trans,
3922 btrfs_set_token_inode_transid(&token, item, trans->transid);
3928 static int log_inode_item(struct btrfs_trans_handle *trans,
3935 ret = btrfs_insert_empty_item(trans, log, path,
3941 fill_inode_item(trans, path->nodes[0], inode_item, &inode->vfs_inode,
3947 static int log_csums(struct btrfs_trans_handle *trans,
3961 if (inode->last_reflink_trans < trans->transid)
3962 return btrfs_csum_file_blocks(trans, log_root, sums);
3983 ret = btrfs_del_csums(trans, log_root, sums->bytenr, sums->len);
3985 ret = btrfs_csum_file_blocks(trans, log_root, sums);
3993 static noinline int copy_items(struct btrfs_trans_handle *trans,
4000 struct btrfs_fs_info *fs_info = trans->fs_info;
4029 ret = btrfs_insert_empty_items(trans, log, dst_path,
4046 fill_inode_item(trans, dst_path->nodes[0], inode_item,
4065 if (btrfs_file_extent_generation(src, extent) < trans->transid)
4111 ret = log_csums(trans, inode, log, sums);
4134 static int log_extent_csums(struct btrfs_trans_handle *trans,
4201 ret = log_csums(trans, inode, log_root, sums);
4221 ret = btrfs_lookup_csums_range(trans->fs_info->csum_root,
4233 ret = log_csums(trans, inode, log_root, sums);
4241 static int log_one_extent(struct btrfs_trans_handle *trans,
4257 ret = log_extent_csums(trans, inode, log, em, ctx);
4261 ret = __btrfs_drop_extents(trans, log, inode, path, em->start,
4272 ret = btrfs_insert_empty_item(trans, log, path, &key,
4282 btrfs_set_token_file_extent_generation(&token, fi, trans->transid);
4326 static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
4393 ret = copy_items(trans, inode, dst_path, path,
4424 ret = btrfs_truncate_inode_items(trans,
4447 ret = copy_items(trans, inode, dst_path, path,
4455 static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4523 ret = log_one_extent(trans, inode, root, em, path, ctx);
4533 ret = btrfs_log_prealloc_extents(trans, inode, path);
4552 atomic_inc(&trans->transaction->pending_ordered);
4611 static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans,
4642 ret = copy_items(trans, inode, dst_path, path,
4668 ret = copy_items(trans, inode, dst_path, path,
4689 static int btrfs_log_holes(struct btrfs_trans_handle *trans,
4740 ret = btrfs_insert_file_extent(trans, root->log_root,
4772 ret = btrfs_insert_file_extent(trans, root->log_root,
4924 static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
4970 ret = btrfs_log_inode(trans, root,
5017 if (BTRFS_I(inode)->logged_trans == trans->transid) {
5030 ret = btrfs_log_inode(trans, root, BTRFS_I(inode),
5095 static int copy_inode_items_to_log(struct btrfs_trans_handle *trans,
5114 ret = btrfs_search_forward(root, min_key, path, trans->transid);
5141 inode->generation == trans->transid &&
5159 ret = copy_items(trans, inode, dst_path, path,
5166 ret = log_conflicting_inodes(trans, root, path,
5177 ret = copy_items(trans, inode, dst_path, path,
5195 ret = copy_items(trans, inode, dst_path, path, ins_start_slot,
5209 ret = copy_items(trans, inode, dst_path, path,
5228 ret = copy_items(trans, inode, dst_path, path, ins_start_slot,
5240 ret = btrfs_log_prealloc_extents(trans, inode, dst_path);
5260 static int btrfs_log_inode(struct btrfs_trans_handle *trans,
5318 ret = btrfs_commit_inode_delayed_items(trans, inode);
5360 ret = drop_objectid_items(trans, log, path, ino, max_key_type);
5384 ret = drop_objectid_items(trans, log, path, ino,
5392 ret = btrfs_truncate_inode_items(trans,
5404 ret = drop_objectid_items(trans, log, path, ino,
5418 err = copy_inode_items_to_log(trans, inode, &min_key, &max_key,
5427 err = btrfs_log_all_xattrs(trans, root, inode, path, dst_path);
5434 err = btrfs_log_holes(trans, root, inode, path);
5442 err = log_inode_item(trans, log, dst_path, inode);
5444 err = btrfs_log_all_xattrs(trans, root, inode, path,
5452 ret = btrfs_log_changed_extents(trans, root, inode, dst_path,
5468 ret = log_directory_changes(trans, root, inode, path, dst_path,
5490 inode->logged_trans = trans->transid;
5529 static bool btrfs_must_commit_transaction(struct btrfs_trans_handle *trans,
5541 btrfs_set_log_full_commit(trans);
5555 static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
5582 if (btrfs_must_commit_transaction(trans, inode)) {
5592 if (btrfs_must_commit_transaction(trans, inode))
5655 static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
5695 ret = btrfs_search_forward(log, &min_key, path, trans->transid);
5721 if (btrfs_dir_transid(leaf, di) < trans->transid &&
5735 if (btrfs_inode_in_log(BTRFS_I(di_inode), trans->transid)) {
5743 ret = btrfs_log_inode(trans, root, BTRFS_I(di_inode),
5746 btrfs_must_commit_transaction(trans, BTRFS_I(di_inode)))
5786 static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
5790 struct btrfs_fs_info *fs_info = trans->fs_info;
5887 ret = btrfs_log_inode(trans, root, BTRFS_I(dir_inode),
5890 btrfs_must_commit_transaction(trans, BTRFS_I(dir_inode)))
5893 ret = log_new_dir_dentries(trans, root,
5907 static int log_new_ancestors(struct btrfs_trans_handle *trans,
5938 ret = btrfs_log_inode(trans, root, BTRFS_I(inode),
5972 static int log_new_ancestors_fast(struct btrfs_trans_handle *trans,
5993 ret = btrfs_log_inode(trans, root, inode,
6010 static int log_all_new_ancestors(struct btrfs_trans_handle *trans,
6026 return log_new_ancestors_fast(trans, inode, parent, ctx);
6081 ret = log_new_ancestors(trans, root, path, ctx);
6099 static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
6134 ret = check_parent_dirs_for_sync(trans, inode, parent, sb,
6144 if ((btrfs_inode_in_log(inode, trans->transid) &&
6151 ret = start_log_trans(trans, root, ctx);
6155 ret = btrfs_log_inode(trans, root, inode, inode_only, ctx);
6217 ret = btrfs_log_all_parents(trans, inode, ctx);
6222 ret = log_all_new_ancestors(trans, inode, parent, ctx);
6227 ret = log_new_dir_dentries(trans, root, inode, ctx);
6232 btrfs_set_log_full_commit(trans);
6249 int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
6256 ret = btrfs_log_inode_parent(trans, BTRFS_I(d_inode(dentry)), parent,
6271 struct btrfs_trans_handle *trans;
6287 trans = btrfs_start_transaction(fs_info->tree_root, 0);
6288 if (IS_ERR(trans)) {
6289 ret = PTR_ERR(trans);
6293 wc.trans = trans;
6296 ret = walk_log_tree(trans, log_root_tree, &wc);
6352 ret = btrfs_pin_extent_for_log_replay(trans,
6365 btrfs_record_root_in_trans(trans, wc.replay_dest);
6366 ret = walk_log_tree(trans, log, &wc);
6369 ret = fixup_inode_link_counts(trans, wc.replay_dest,
6419 ret = btrfs_commit_transaction(trans);
6429 if (wc.trans)
6430 btrfs_end_transaction(wc.trans);
6447 void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
6462 inode->last_unlink_trans = trans->transid;
6469 if (dir->logged_trans == trans->transid)
6476 if (inode->logged_trans == trans->transid)
6494 dir->last_unlink_trans = trans->transid;
6510 void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans,
6514 dir->last_unlink_trans = trans->transid;
6522 void btrfs_log_new_name(struct btrfs_trans_handle *trans,
6533 inode->last_unlink_trans = trans->transid;
6539 if (!inode_logged(trans, inode) &&
6540 (!old_dir || !inode_logged(trans, old_dir)))
6552 btrfs_log_inode_parent(trans, inode, parent, LOG_INODE_EXISTS, &ctx);