Lines Matching +full:sync +full:- +full:token
1 // SPDX-License-Identifier: GPL-2.0
13 #include "tree-log.h"
14 #include "disk-io.h"
16 #include "print-tree.h"
20 #include "inode-map.h"
21 #include "block-group.h"
22 #include "space-info.h"
43 * ---> record transid of last unlink/rename per directory
56 * log. ---> check inode while renaming/linking.
60 * ---> check inode and old parent dir during rename
66 * of zero and redo the rm -rf
70 * rm -rf f1/foo
74 * called on f1, only its parent dir. After a crash the rm -rf must
115 * extent tree an 4x-6x higher write load than ext3.
123 * After a crash, items are copied out of the log-tree back into the
125 * allocation tree, and the log-tree freed.
141 struct btrfs_fs_info *fs_info = root->fs_info; in start_log_trans()
144 mutex_lock(&root->log_mutex); in start_log_trans()
146 if (root->log_root) { in start_log_trans()
148 ret = -EAGAIN; in start_log_trans()
152 if (!root->log_start_pid) { in start_log_trans()
153 clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); in start_log_trans()
154 root->log_start_pid = current->pid; in start_log_trans()
155 } else if (root->log_start_pid != current->pid) { in start_log_trans()
156 set_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); in start_log_trans()
159 mutex_lock(&fs_info->tree_log_mutex); in start_log_trans()
160 if (!fs_info->log_root_tree) in start_log_trans()
162 mutex_unlock(&fs_info->tree_log_mutex); in start_log_trans()
170 set_bit(BTRFS_ROOT_HAS_LOG_TREE, &root->state); in start_log_trans()
171 clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); in start_log_trans()
172 root->log_start_pid = current->pid; in start_log_trans()
175 atomic_inc(&root->log_batch); in start_log_trans()
176 atomic_inc(&root->log_writers); in start_log_trans()
177 if (ctx && !ctx->logging_new_name) { in start_log_trans()
178 int index = root->log_transid % 2; in start_log_trans()
179 list_add_tail(&ctx->list, &root->log_ctxs[index]); in start_log_trans()
180 ctx->log_transid = root->log_transid; in start_log_trans()
184 mutex_unlock(&root->log_mutex); in start_log_trans()
190 * to join, or returns -ENOENT if there were not transactions
195 int ret = -ENOENT; in join_running_log_trans()
197 if (!test_bit(BTRFS_ROOT_HAS_LOG_TREE, &root->state)) in join_running_log_trans()
200 mutex_lock(&root->log_mutex); in join_running_log_trans()
201 if (root->log_root) { in join_running_log_trans()
203 atomic_inc(&root->log_writers); in join_running_log_trans()
205 mutex_unlock(&root->log_mutex); in join_running_log_trans()
216 atomic_inc(&root->log_writers); in btrfs_pin_log_trans()
221 * and wake up anyone waiting to do a sync
225 if (atomic_dec_and_test(&root->log_writers)) { in btrfs_end_log_trans()
227 cond_wake_up_nomb(&root->log_writer_wait); in btrfs_end_log_trans()
233 return filemap_fdatawrite_range(buf->pages[0]->mapping, buf->start, in btrfs_write_tree_block()
234 buf->start + buf->len - 1); in btrfs_write_tree_block()
239 filemap_fdatawait_range(buf->pages[0]->mapping, in btrfs_wait_tree_block_writeback()
240 buf->start, buf->start + buf->len - 1); in btrfs_wait_tree_block_writeback()
256 * while flushing the log tree to disk during a sync
261 * while flushing the log tree to disk for a sync
302 struct btrfs_fs_info *fs_info = log->fs_info; in process_one_buffer()
315 if (wc->pin) in process_one_buffer()
316 ret = btrfs_pin_extent_for_log_replay(wc->trans, eb->start, in process_one_buffer()
317 eb->len); in process_one_buffer()
320 if (wc->pin && btrfs_header_level(eb) == 0) in process_one_buffer()
322 if (wc->write) in process_one_buffer()
324 if (wc->wait) in process_one_buffer()
357 bool inode_item = key->type == BTRFS_INODE_ITEM_KEY; in overwrite_item()
359 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) in overwrite_item()
373 u32 dst_size = btrfs_item_size_nr(path->nodes[0], in overwrite_item()
374 path->slots[0]); in overwrite_item()
388 return -ENOMEM; in overwrite_item()
393 dst_ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); in overwrite_item()
394 read_extent_buffer(path->nodes[0], dst_copy, dst_ptr, in overwrite_item()
404 * sync in overwrite_item()
420 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in overwrite_item()
422 nbytes = btrfs_inode_nbytes(path->nodes[0], item); in overwrite_item()
459 path->skip_release_on_error = 1; in overwrite_item()
462 path->skip_release_on_error = 0; in overwrite_item()
465 if (ret == -EEXIST || ret == -EOVERFLOW) { in overwrite_item()
467 found_size = btrfs_item_size_nr(path->nodes[0], in overwrite_item()
468 path->slots[0]); in overwrite_item()
472 btrfs_extend_item(path, item_size - found_size); in overwrite_item()
476 dst_ptr = btrfs_item_ptr_offset(path->nodes[0], in overwrite_item()
477 path->slots[0]); in overwrite_item()
488 if (key->type == BTRFS_INODE_ITEM_KEY && ret == -EEXIST) { in overwrite_item()
496 struct extent_buffer *dst_eb = path->nodes[0]; in overwrite_item()
515 S_ISDIR(btrfs_inode_mode(path->nodes[0], dst_item))) { in overwrite_item()
517 saved_i_size = btrfs_inode_size(path->nodes[0], in overwrite_item()
522 copy_extent_buffer(path->nodes[0], eb, dst_ptr, in overwrite_item()
528 btrfs_set_inode_size(path->nodes[0], dst_item, saved_i_size); in overwrite_item()
532 if (key->type == BTRFS_INODE_ITEM_KEY) { in overwrite_item()
535 if (btrfs_inode_generation(path->nodes[0], dst_item) == 0) { in overwrite_item()
536 btrfs_set_inode_generation(path->nodes[0], dst_item, in overwrite_item()
537 trans->transid); in overwrite_item()
541 btrfs_mark_buffer_dirty(path->nodes[0]); in overwrite_item()
555 inode = btrfs_iget(root->fs_info->sb, objectid, root); in read_one_inode()
579 struct btrfs_fs_info *fs_info = root->fs_info; in replay_one_extent()
582 u64 start = key->offset; in replay_one_extent()
607 fs_info->sectorsize); in replay_one_extent()
613 inode = read_one_inode(root, key->objectid); in replay_one_extent()
615 ret = -EIO; in replay_one_extent()
635 leaf = path->nodes[0]; in replay_one_extent()
636 existing = btrfs_item_ptr(leaf, path->slots[0], in replay_one_extent()
674 dest_offset = btrfs_item_ptr_offset(path->nodes[0], in replay_one_extent()
675 path->slots[0]); in replay_one_extent()
676 copy_extent_buffer(path->nodes[0], eb, dest_offset, in replay_one_extent()
682 offset = key->offset - btrfs_file_extent_offset(eb, item); in replay_one_extent()
718 root->root_key.objectid, in replay_one_extent()
719 key->objectid, offset); in replay_one_extent()
729 root->root_key.objectid, in replay_one_extent()
730 key->objectid, offset, &ins); in replay_one_extent()
746 ret = btrfs_lookup_csums_range(root->log_root, in replay_one_extent()
747 csum_start, csum_end - 1, in replay_one_extent()
784 * Which covers the 20K sub-range starting at offset 20K in replay_one_extent()
807 fs_info->csum_root, in replay_one_extent()
808 sums->bytenr, in replay_one_extent()
809 sums->len); in replay_one_extent()
812 fs_info->csum_root, sums); in replay_one_extent()
813 list_del(&sums->list); in replay_one_extent()
829 extent_end - start); in replay_one_extent()
863 leaf = path->nodes[0]; in drop_one_dir_item()
869 return -ENOMEM; in drop_one_dir_item()
876 ret = -EIO; in drop_one_dir_item()
915 if (PTR_ERR(di) != -ENOENT) in inode_in_dir()
919 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location); in inode_in_dir()
932 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location); in inode_in_dir()
961 return -ENOMEM; in backref_in_log()
971 if (key->type == BTRFS_INODE_EXTREF_KEY) in backref_in_log()
972 ret = !!btrfs_find_name_in_ext_backref(path->nodes[0], in backref_in_log()
973 path->slots[0], in backref_in_log()
977 ret = !!btrfs_find_name_in_backref(path->nodes[0], in backref_in_log()
978 path->slots[0], in backref_in_log()
1014 leaf = path->nodes[0]; in __add_inode_ref()
1026 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in __add_inode_ref()
1027 ptr_end = ptr + btrfs_item_size_nr(leaf, path->slots[0]); in __add_inode_ref()
1034 return -ENOMEM; in __add_inode_ref()
1047 inc_nlink(&inode->vfs_inode); in __add_inode_ref()
1086 leaf = path->nodes[0]; in __add_inode_ref()
1088 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in __add_inode_ref()
1089 base = btrfs_item_ptr_offset(leaf, path->slots[0]); in __add_inode_ref()
1101 return -ENOMEM; in __add_inode_ref()
1102 read_extent_buffer(leaf, victim_name, (unsigned long)&extref->name, in __add_inode_ref()
1117 ret = -ENOENT; in __add_inode_ref()
1121 inc_nlink(&inode->vfs_inode); in __add_inode_ref()
1152 if (PTR_ERR(di) != -ENOENT) in __add_inode_ref()
1187 return -ENOMEM; in extref_get_fields()
1189 read_extent_buffer(eb, *name, (unsigned long)&extref->name, in extref_get_fields()
1210 return -ENOMEM; in ref_get_fields()
1250 eb = path->nodes[0]; in unlink_old_inode_refs()
1251 ref_ptr = btrfs_item_ptr_offset(eb, path->slots[0]); in unlink_old_inode_refs()
1252 ref_end = ref_ptr + btrfs_item_size_nr(eb, path->slots[0]); in unlink_old_inode_refs()
1258 if (key->type == BTRFS_INODE_EXTREF_KEY) { in unlink_old_inode_refs()
1262 parent_id = key->offset; in unlink_old_inode_refs()
1269 if (key->type == BTRFS_INODE_EXTREF_KEY) in unlink_old_inode_refs()
1283 ret = -ENOENT; in unlink_old_inode_refs()
1307 if (key->type == BTRFS_INODE_EXTREF_KEY) in unlink_old_inode_refs()
1329 return -ENOMEM; in btrfs_inode_ref_exists()
1338 ret = btrfs_search_slot(NULL, BTRFS_I(inode)->root, &key, path, 0, 0); in btrfs_inode_ref_exists()
1346 ret = !!btrfs_find_name_in_ext_backref(path->nodes[0], in btrfs_inode_ref_exists()
1347 path->slots[0], parent_id, name, namelen); in btrfs_inode_ref_exists()
1349 ret = !!btrfs_find_name_in_backref(path->nodes[0], path->slots[0], in btrfs_inode_ref_exists()
1369 return -ENOMEM; in add_link()
1387 btrfs_dir_item_key_to_cpu(path->nodes[0], dir_item, &key); in add_link()
1391 ret = -ENOENT; in add_link()
1402 if (other_inode->i_nlink == 0) in add_link()
1448 if (key->type == BTRFS_INODE_EXTREF_KEY) { in add_inode_ref()
1457 parent_objectid = key->offset; in add_inode_ref()
1459 inode_objectid = key->objectid; in add_inode_ref()
1469 ret = -ENOENT; in add_inode_ref()
1475 ret = -EIO; in add_inode_ref()
1490 ret = -ENOENT; in add_inode_ref()
1535 * -EEXIST returned from btrfs_add_link() below. in add_inode_ref()
1537 ret = btrfs_inode_ref_exists(inode, dir, key->type, in add_inode_ref()
1549 if (!ret && inode->i_nlink == 0) in add_inode_ref()
1612 if (ret == -EEXIST) in insert_orphan_item()
1638 leaf = path->nodes[0]; in count_inode_extrefs()
1639 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in count_inode_extrefs()
1640 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in count_inode_extrefs()
1657 if (ret < 0 && ret != -ENOENT) in count_inode_extrefs()
1675 key.offset = (u64)-1; in count_inode_refs()
1682 if (path->slots[0] == 0) in count_inode_refs()
1684 path->slots[0]--; in count_inode_refs()
1687 btrfs_item_key_to_cpu(path->nodes[0], &key, in count_inode_refs()
1688 path->slots[0]); in count_inode_refs()
1692 ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); in count_inode_refs()
1693 ptr_end = ptr + btrfs_item_size_nr(path->nodes[0], in count_inode_refs()
1694 path->slots[0]); in count_inode_refs()
1699 name_len = btrfs_inode_ref_name_len(path->nodes[0], in count_inode_refs()
1707 if (path->slots[0] > 0) { in count_inode_refs()
1708 path->slots[0]--; in count_inode_refs()
1711 key.offset--; in count_inode_refs()
1740 return -ENOMEM; in fixup_inode_link_count()
1756 if (nlink != inode->i_nlink) { in fixup_inode_link_count()
1760 BTRFS_I(inode)->index_cnt = (u64)-1; in fixup_inode_link_count()
1762 if (inode->i_nlink == 0) { in fixup_inode_link_count()
1763 if (S_ISDIR(inode->i_mode)) { in fixup_inode_link_count()
1787 key.offset = (u64)-1; in fixup_inode_link_counts()
1789 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in fixup_inode_link_counts()
1795 if (path->slots[0] == 0) in fixup_inode_link_counts()
1797 path->slots[0]--; in fixup_inode_link_counts()
1800 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); in fixup_inode_link_counts()
1812 ret = -EIO; in fixup_inode_link_counts()
1826 key.offset = (u64)-1; in fixup_inode_link_counts()
1849 return -EIO; in link_to_fixup_dir()
1859 if (!inode->i_nlink) in link_to_fixup_dir()
1864 } else if (ret == -EEXIST) { in link_to_fixup_dir()
1887 inode = read_one_inode(root, location->objectid); in insert_one_name()
1889 return -ENOENT; in insert_one_name()
1894 return -EIO; in insert_one_name()
1921 * non-existing inode) and 1 if the name was replayed.
1939 bool update_size = (key->type == BTRFS_DIR_INDEX_KEY); in replay_one_name()
1942 dir = read_one_inode(root, key->objectid); in replay_one_name()
1944 return -EIO; in replay_one_name()
1949 ret = -ENOMEM; in replay_one_name()
1965 if (key->type == BTRFS_DIR_ITEM_KEY) { in replay_one_name()
1966 dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, in replay_one_name()
1968 } else if (key->type == BTRFS_DIR_INDEX_KEY) { in replay_one_name()
1970 key->objectid, in replay_one_name()
1971 key->offset, name, in replay_one_name()
1975 ret = -EINVAL; in replay_one_name()
1979 if (dst_di == ERR_PTR(-ENOENT)) in replay_one_name()
1989 if (key->type != BTRFS_DIR_INDEX_KEY) in replay_one_name()
1994 btrfs_dir_item_key_to_cpu(path->nodes[0], dst_di, &found_key); in replay_one_name()
1999 btrfs_dir_type(path->nodes[0], dst_di) == log_type) { in replay_one_name()
2015 if (key->type == BTRFS_DIR_INDEX_KEY) in replay_one_name()
2020 btrfs_i_size_write(BTRFS_I(dir), dir->i_size + name_len * 2); in replay_one_name()
2036 found_key.offset = key->objectid; in replay_one_name()
2037 ret = backref_in_log(root->log_root, &found_key, 0, name, name_len); in replay_one_name()
2049 found_key.offset = key->objectid; in replay_one_name()
2050 ret = backref_in_log(root->log_root, &found_key, key->objectid, name, in replay_one_name()
2061 ret = insert_one_name(trans, root, key->objectid, key->offset, in replay_one_name()
2063 if (ret && ret != -ENOENT && ret != -EEXIST) in replay_one_name()
2104 * If this entry refers to a non-directory (directories can not in replay_one_dir_item()
2115 * sync in replay_one_dir_item()
2119 * xfs_io -c "fsync" testdir/bar in replay_one_dir_item()
2136 ret = -ENOMEM; in replay_one_dir_item()
2175 if (*start_ret == (u64)-1) in find_dir_range()
2186 if (path->slots[0] == 0) in find_dir_range()
2188 path->slots[0]--; in find_dir_range()
2191 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); in find_dir_range()
2197 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in find_dir_range()
2199 found_end = btrfs_dir_log_end(path->nodes[0], item); in find_dir_range()
2210 nritems = btrfs_header_nritems(path->nodes[0]); in find_dir_range()
2211 path->slots[0]++; in find_dir_range()
2212 if (path->slots[0] >= nritems) { in find_dir_range()
2218 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); in find_dir_range()
2224 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in find_dir_range()
2226 found_end = btrfs_dir_log_end(path->nodes[0], item); in find_dir_range()
2262 eb = path->nodes[0]; in check_item_in_log()
2263 slot = path->slots[0]; in check_item_in_log()
2272 ret = -ENOMEM; in check_item_in_log()
2278 if (log && dir_key->type == BTRFS_DIR_ITEM_KEY) { in check_item_in_log()
2280 dir_key->objectid, in check_item_in_log()
2282 } else if (log && dir_key->type == BTRFS_DIR_INDEX_KEY) { in check_item_in_log()
2285 dir_key->objectid, in check_item_in_log()
2286 dir_key->offset, in check_item_in_log()
2289 if (!log_di || log_di == ERR_PTR(-ENOENT)) { in check_item_in_log()
2296 return -EIO; in check_item_in_log()
2357 return -ENOMEM; in replay_xattr_deletes()
2367 nritems = btrfs_header_nritems(path->nodes[0]); in replay_xattr_deletes()
2368 for (i = path->slots[0]; i < nritems; i++) { in replay_xattr_deletes()
2375 btrfs_item_key_to_cpu(path->nodes[0], &key, i); in replay_xattr_deletes()
2381 di = btrfs_item_ptr(path->nodes[0], i, struct btrfs_dir_item); in replay_xattr_deletes()
2382 total_size = btrfs_item_size_nr(path->nodes[0], i); in replay_xattr_deletes()
2385 u16 name_len = btrfs_dir_name_len(path->nodes[0], di); in replay_xattr_deletes()
2386 u16 data_len = btrfs_dir_data_len(path->nodes[0], di); in replay_xattr_deletes()
2392 ret = -ENOMEM; in replay_xattr_deletes()
2395 read_extent_buffer(path->nodes[0], name, in replay_xattr_deletes()
2405 name, name_len, -1); in replay_xattr_deletes()
2470 return -ENOMEM; in replay_dir_deletes()
2486 range_end = (u64)-1; in replay_dir_deletes()
2504 nritems = btrfs_header_nritems(path->nodes[0]); in replay_dir_deletes()
2505 if (path->slots[0] >= nritems) { in replay_dir_deletes()
2512 btrfs_item_key_to_cpu(path->nodes[0], &found_key, in replay_dir_deletes()
2513 path->slots[0]); in replay_dir_deletes()
2526 if (found_key.offset == (u64)-1) in replay_dir_deletes()
2531 if (range_end == (u64)-1) in replay_dir_deletes()
2567 struct btrfs_root *root = wc->replay_dest; in replay_one_buffer()
2583 return -ENOMEM; in replay_one_buffer()
2591 wc->stage == LOG_WALK_REPLAY_INODES) { in replay_one_buffer()
2606 wc->ignore_cur_inode = true; in replay_one_buffer()
2609 wc->ignore_cur_inode = false; in replay_one_buffer()
2611 ret = replay_xattr_deletes(wc->trans, root, log, in replay_one_buffer()
2617 ret = replay_dir_deletes(wc->trans, in replay_one_buffer()
2622 ret = overwrite_item(wc->trans, root, path, in replay_one_buffer()
2641 ret = -EIO; in replay_one_buffer()
2645 root->fs_info->sectorsize); in replay_one_buffer()
2646 ret = btrfs_drop_extents(wc->trans, root, inode, in replay_one_buffer()
2647 from, (u64)-1, 1); in replay_one_buffer()
2650 ret = btrfs_update_inode(wc->trans, in replay_one_buffer()
2658 ret = link_to_fixup_dir(wc->trans, root, in replay_one_buffer()
2664 if (wc->ignore_cur_inode) in replay_one_buffer()
2668 wc->stage == LOG_WALK_REPLAY_DIR_INDEX) { in replay_one_buffer()
2669 ret = replay_one_dir_item(wc->trans, root, path, in replay_one_buffer()
2675 if (wc->stage < LOG_WALK_REPLAY_ALL) in replay_one_buffer()
2680 ret = overwrite_item(wc->trans, root, path, in replay_one_buffer()
2686 ret = add_inode_ref(wc->trans, root, log, path, in replay_one_buffer()
2688 if (ret && ret != -ENOENT) in replay_one_buffer()
2692 ret = replay_one_extent(wc->trans, root, path, in replay_one_buffer()
2697 ret = replay_one_dir_item(wc->trans, root, path, in replay_one_buffer()
2720 spin_lock(&cache->space_info->lock); in unaccount_log_buffer()
2721 spin_lock(&cache->lock); in unaccount_log_buffer()
2722 cache->reserved -= fs_info->nodesize; in unaccount_log_buffer()
2723 cache->space_info->bytes_reserved -= fs_info->nodesize; in unaccount_log_buffer()
2724 spin_unlock(&cache->lock); in unaccount_log_buffer()
2725 spin_unlock(&cache->space_info->lock); in unaccount_log_buffer()
2735 struct btrfs_fs_info *fs_info = root->fs_info; in walk_down_log_tree()
2746 cur = path->nodes[*level]; in walk_down_log_tree()
2750 if (path->slots[*level] >= in walk_down_log_tree()
2754 bytenr = btrfs_node_blockptr(cur, path->slots[*level]); in walk_down_log_tree()
2755 ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]); in walk_down_log_tree()
2756 btrfs_node_key_to_cpu(cur, &first_key, path->slots[*level]); in walk_down_log_tree()
2757 blocksize = fs_info->nodesize; in walk_down_log_tree()
2764 ret = wc->process_func(root, next, wc, ptr_gen, in walk_down_log_tree()
2765 *level - 1); in walk_down_log_tree()
2771 path->slots[*level]++; in walk_down_log_tree()
2772 if (wc->free) { in walk_down_log_tree()
2774 *level - 1, &first_key); in walk_down_log_tree()
2793 if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) in walk_down_log_tree()
2801 ret = btrfs_read_buffer(next, ptr_gen, *level - 1, &first_key); in walk_down_log_tree()
2807 if (path->nodes[*level-1]) in walk_down_log_tree()
2808 free_extent_buffer(path->nodes[*level-1]); in walk_down_log_tree()
2809 path->nodes[*level-1] = next; in walk_down_log_tree()
2811 path->slots[*level] = 0; in walk_down_log_tree()
2814 path->slots[*level] = btrfs_header_nritems(path->nodes[*level]); in walk_down_log_tree()
2825 struct btrfs_fs_info *fs_info = root->fs_info; in walk_up_log_tree()
2830 for (i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) { in walk_up_log_tree()
2831 slot = path->slots[i]; in walk_up_log_tree()
2832 if (slot + 1 < btrfs_header_nritems(path->nodes[i])) { in walk_up_log_tree()
2833 path->slots[i]++; in walk_up_log_tree()
2838 ret = wc->process_func(root, path->nodes[*level], wc, in walk_up_log_tree()
2839 btrfs_header_generation(path->nodes[*level]), in walk_up_log_tree()
2844 if (wc->free) { in walk_up_log_tree()
2847 next = path->nodes[*level]; in walk_up_log_tree()
2856 path->nodes[*level]->start, in walk_up_log_tree()
2857 path->nodes[*level]->len); in walk_up_log_tree()
2861 if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) in walk_up_log_tree()
2865 path->nodes[*level]->start); in walk_up_log_tree()
2868 free_extent_buffer(path->nodes[*level]); in walk_up_log_tree()
2869 path->nodes[*level] = NULL; in walk_up_log_tree()
2884 struct btrfs_fs_info *fs_info = log->fs_info; in walk_log_tree()
2893 return -ENOMEM; in walk_log_tree()
2895 level = btrfs_header_level(log->node); in walk_log_tree()
2897 path->nodes[level] = log->node; in walk_log_tree()
2898 atomic_inc(&log->node->refs); in walk_log_tree()
2899 path->slots[level] = 0; in walk_log_tree()
2920 if (path->nodes[orig_level]) { in walk_log_tree()
2921 ret = wc->process_func(log, path->nodes[orig_level], wc, in walk_log_tree()
2922 btrfs_header_generation(path->nodes[orig_level]), in walk_log_tree()
2926 if (wc->free) { in walk_log_tree()
2929 next = path->nodes[orig_level]; in walk_log_tree()
2938 next->start, next->len); in walk_log_tree()
2942 if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) in walk_log_tree()
2944 unaccount_log_buffer(fs_info, next->start); in walk_log_tree()
2962 struct btrfs_fs_info *fs_info = log->fs_info; in update_log_root()
2965 if (log->log_transid == 1) { in update_log_root()
2966 /* insert root item on the first sync */ in update_log_root()
2967 ret = btrfs_insert_root(trans, fs_info->log_root_tree, in update_log_root()
2968 &log->root_key, root_item); in update_log_root()
2970 ret = btrfs_update_root(trans, fs_info->log_root_tree, in update_log_root()
2971 &log->root_key, root_item); in update_log_root()
2987 prepare_to_wait(&root->log_commit_wait[index], in wait_log_commit()
2990 if (!(root->log_transid_committed < transid && in wait_log_commit()
2991 atomic_read(&root->log_commit[index]))) in wait_log_commit()
2994 mutex_unlock(&root->log_mutex); in wait_log_commit()
2996 mutex_lock(&root->log_mutex); in wait_log_commit()
2998 finish_wait(&root->log_commit_wait[index], &wait); in wait_log_commit()
3006 prepare_to_wait(&root->log_writer_wait, &wait, in wait_for_writer()
3008 if (!atomic_read(&root->log_writers)) in wait_for_writer()
3011 mutex_unlock(&root->log_mutex); in wait_for_writer()
3013 mutex_lock(&root->log_mutex); in wait_for_writer()
3015 finish_wait(&root->log_writer_wait, &wait); in wait_for_writer()
3024 mutex_lock(&root->log_mutex); in btrfs_remove_log_ctx()
3025 list_del_init(&ctx->list); in btrfs_remove_log_ctx()
3026 mutex_unlock(&root->log_mutex); in btrfs_remove_log_ctx()
3039 list_for_each_entry_safe(ctx, safe, &root->log_ctxs[index], list) { in btrfs_remove_all_log_ctxs()
3040 list_del_init(&ctx->list); in btrfs_remove_all_log_ctxs()
3041 ctx->log_ret = error; in btrfs_remove_all_log_ctxs()
3044 INIT_LIST_HEAD(&root->log_ctxs[index]); in btrfs_remove_all_log_ctxs()
3056 * fsync is to commit the whole FS. When btrfs_sync_log returns -EAGAIN,
3066 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_sync_log()
3067 struct btrfs_root *log = root->log_root; in btrfs_sync_log()
3068 struct btrfs_root *log_root_tree = fs_info->log_root_tree; in btrfs_sync_log()
3074 mutex_lock(&root->log_mutex); in btrfs_sync_log()
3075 log_transid = ctx->log_transid; in btrfs_sync_log()
3076 if (root->log_transid_committed >= log_transid) { in btrfs_sync_log()
3077 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3078 return ctx->log_ret; in btrfs_sync_log()
3082 if (atomic_read(&root->log_commit[index1])) { in btrfs_sync_log()
3084 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3085 return ctx->log_ret; in btrfs_sync_log()
3087 ASSERT(log_transid == root->log_transid); in btrfs_sync_log()
3088 atomic_set(&root->log_commit[index1], 1); in btrfs_sync_log()
3090 /* wait for previous tree log sync to complete */ in btrfs_sync_log()
3091 if (atomic_read(&root->log_commit[(index1 + 1) % 2])) in btrfs_sync_log()
3092 wait_log_commit(root, log_transid - 1); in btrfs_sync_log()
3095 int batch = atomic_read(&root->log_batch); in btrfs_sync_log()
3098 test_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state)) { in btrfs_sync_log()
3099 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3101 mutex_lock(&root->log_mutex); in btrfs_sync_log()
3104 if (batch == atomic_read(&root->log_batch)) in btrfs_sync_log()
3110 ret = -EAGAIN; in btrfs_sync_log()
3111 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3124 ret = btrfs_write_marked_extents(fs_info, &log->dirty_log_pages, mark); in btrfs_sync_log()
3129 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3134 * We _must_ update under the root->log_mutex in order to make sure we in btrfs_sync_log()
3139 * log_root_tree->log_mutex yet. This is important because when we in btrfs_sync_log()
3146 btrfs_set_root_node(&log->root_item, log->node); in btrfs_sync_log()
3147 memcpy(&new_root_item, &log->root_item, sizeof(new_root_item)); in btrfs_sync_log()
3149 root->log_transid++; in btrfs_sync_log()
3150 log->log_transid = root->log_transid; in btrfs_sync_log()
3151 root->log_start_pid = 0; in btrfs_sync_log()
3157 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3161 mutex_lock(&log_root_tree->log_mutex); in btrfs_sync_log()
3163 index2 = log_root_tree->log_transid % 2; in btrfs_sync_log()
3164 list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); in btrfs_sync_log()
3165 root_log_ctx.log_transid = log_root_tree->log_transid; in btrfs_sync_log()
3180 if (ret != -ENOSPC) { in btrfs_sync_log()
3182 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3186 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3187 ret = -EAGAIN; in btrfs_sync_log()
3191 if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { in btrfs_sync_log()
3194 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3200 if (atomic_read(&log_root_tree->log_commit[index2])) { in btrfs_sync_log()
3205 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3210 ASSERT(root_log_ctx.log_transid == log_root_tree->log_transid); in btrfs_sync_log()
3211 atomic_set(&log_root_tree->log_commit[index2], 1); in btrfs_sync_log()
3213 if (atomic_read(&log_root_tree->log_commit[(index2 + 1) % 2])) { in btrfs_sync_log()
3215 root_log_ctx.log_transid - 1); in btrfs_sync_log()
3225 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3226 ret = -EAGAIN; in btrfs_sync_log()
3231 &log_root_tree->dirty_log_pages, in btrfs_sync_log()
3237 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3246 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3250 btrfs_set_super_log_root(fs_info->super_for_commit, in btrfs_sync_log()
3251 log_root_tree->node->start); in btrfs_sync_log()
3252 btrfs_set_super_log_root_level(fs_info->super_for_commit, in btrfs_sync_log()
3253 btrfs_header_level(log_root_tree->node)); in btrfs_sync_log()
3255 log_root_tree->log_transid++; in btrfs_sync_log()
3256 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3272 mutex_lock(&root->log_mutex); in btrfs_sync_log()
3273 if (root->last_log_commit < log_transid) in btrfs_sync_log()
3274 root->last_log_commit = log_transid; in btrfs_sync_log()
3275 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3278 mutex_lock(&log_root_tree->log_mutex); in btrfs_sync_log()
3281 log_root_tree->log_transid_committed++; in btrfs_sync_log()
3282 atomic_set(&log_root_tree->log_commit[index2], 0); in btrfs_sync_log()
3283 mutex_unlock(&log_root_tree->log_mutex); in btrfs_sync_log()
3290 cond_wake_up(&log_root_tree->log_commit_wait[index2]); in btrfs_sync_log()
3292 mutex_lock(&root->log_mutex); in btrfs_sync_log()
3294 root->log_transid_committed++; in btrfs_sync_log()
3295 atomic_set(&root->log_commit[index1], 0); in btrfs_sync_log()
3296 mutex_unlock(&root->log_mutex); in btrfs_sync_log()
3303 cond_wake_up(&root->log_commit_wait[index1]); in btrfs_sync_log()
3321 btrfs_handle_fs_error(log->fs_info, ret, NULL); in free_log_tree()
3324 clear_extent_bits(&log->dirty_log_pages, 0, (u64)-1, in free_log_tree()
3326 extent_io_tree_release(&log->log_csum_range); in free_log_tree()
3336 if (root->log_root) { in btrfs_free_log()
3337 free_log_tree(trans, root->log_root); in btrfs_free_log()
3338 root->log_root = NULL; in btrfs_free_log()
3339 clear_bit(BTRFS_ROOT_HAS_LOG_TREE, &root->state); in btrfs_free_log()
3347 if (fs_info->log_root_tree) { in btrfs_free_log_root_tree()
3348 free_log_tree(trans, fs_info->log_root_tree); in btrfs_free_log_root_tree()
3349 fs_info->log_root_tree = NULL; in btrfs_free_log_root_tree()
3356 * on an inode's logged_trans value, because it's an in-memory only field and
3367 if (inode->logged_trans == trans->transid) in inode_logged()
3370 if (inode->last_trans == trans->transid && in inode_logged()
3371 test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags) && in inode_logged()
3372 !test_bit(BTRFS_FS_LOG_RECOVERING, &trans->fs_info->flags)) in inode_logged()
3419 mutex_lock(&dir->log_mutex); in btrfs_del_dir_entries_in_log()
3421 log = root->log_root; in btrfs_del_dir_entries_in_log()
3424 err = -ENOMEM; in btrfs_del_dir_entries_in_log()
3429 name, name_len, -1); in btrfs_del_dir_entries_in_log()
3444 index, name, name_len, -1); in btrfs_del_dir_entries_in_log()
3478 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in btrfs_del_dir_entries_in_log()
3480 i_size = btrfs_inode_size(path->nodes[0], item); in btrfs_del_dir_entries_in_log()
3482 i_size -= bytes_del; in btrfs_del_dir_entries_in_log()
3485 btrfs_set_inode_size(path->nodes[0], item, i_size); in btrfs_del_dir_entries_in_log()
3486 btrfs_mark_buffer_dirty(path->nodes[0]); in btrfs_del_dir_entries_in_log()
3494 mutex_unlock(&dir->log_mutex); in btrfs_del_dir_entries_in_log()
3495 if (err == -ENOSPC) { in btrfs_del_dir_entries_in_log()
3498 } else if (err < 0 && err != -ENOENT) { in btrfs_del_dir_entries_in_log()
3524 log = root->log_root; in btrfs_del_inode_ref_in_log()
3525 mutex_lock(&inode->log_mutex); in btrfs_del_inode_ref_in_log()
3529 mutex_unlock(&inode->log_mutex); in btrfs_del_inode_ref_in_log()
3530 if (ret == -ENOSPC) { in btrfs_del_inode_ref_in_log()
3533 } else if (ret < 0 && ret != -ENOENT) in btrfs_del_inode_ref_in_log()
3565 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in insert_dir_log_key()
3567 btrfs_set_dir_log_end(path->nodes[0], item, last_offset); in insert_dir_log_key()
3568 btrfs_mark_buffer_dirty(path->nodes[0]); in insert_dir_log_key()
3586 struct btrfs_root *log = root->log_root; in log_dir_items()
3593 u64 last_offset = (u64)-1; in log_dir_items()
3596 log = root->log_root; in log_dir_items()
3602 ret = btrfs_search_forward(root, &min_key, path, trans->transid); in log_dir_items()
3611 min_key.offset = (u64)-1; in log_dir_items()
3627 btrfs_item_key_to_cpu(path->nodes[0], &tmp, in log_dir_items()
3628 path->slots[0]); in log_dir_items()
3639 btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); in log_dir_items()
3643 path->nodes[0], path->slots[0], in log_dir_items()
3672 src = path->nodes[0]; in log_dir_items()
3674 for (i = path->slots[0]; i < nritems; i++) { in log_dir_items()
3702 * sync in log_dir_items()
3704 * xfs_io -c "fsync" mydir in log_dir_items()
3716 * BTRFS_EMPTY_DIR_SIZE, resulting in -ENOTEMPTY errors. in log_dir_items()
3721 (btrfs_dir_transid(src, di) == trans->transid || in log_dir_items()
3724 ctx->log_new_dentries = true; in log_dir_items()
3726 path->slots[0] = nritems; in log_dir_items()
3735 last_offset = (u64)-1; in log_dir_items()
3740 btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); in log_dir_items()
3742 last_offset = (u64)-1; in log_dir_items()
3745 if (btrfs_header_generation(path->nodes[0]) != trans->transid) { in log_dir_items()
3747 path->nodes[0], path->slots[0], in log_dir_items()
3805 if (max_key == (u64)-1) in log_directory_changes()
3835 key.offset = (u64)-1; in drop_objectid_items()
3838 ret = btrfs_search_slot(trans, log, &key, path, -1, 1); in drop_objectid_items()
3843 if (path->slots[0] == 0) in drop_objectid_items()
3846 path->slots[0]--; in drop_objectid_items()
3847 btrfs_item_key_to_cpu(path->nodes[0], &found_key, in drop_objectid_items()
3848 path->slots[0]); in drop_objectid_items()
3855 ret = btrfs_bin_search(path->nodes[0], &found_key, &start_slot); in drop_objectid_items()
3860 path->slots[0] - start_slot + 1); in drop_objectid_items()
3862 * If start slot isn't 0 then we don't need to re-search, we've in drop_objectid_items()
3881 struct btrfs_map_token token; in fill_inode_item() local
3883 btrfs_init_map_token(&token, leaf); in fill_inode_item()
3891 btrfs_set_token_inode_generation(&token, item, 0); in fill_inode_item()
3892 btrfs_set_token_inode_size(&token, item, logged_isize); in fill_inode_item()
3894 btrfs_set_token_inode_generation(&token, item, in fill_inode_item()
3895 BTRFS_I(inode)->generation); in fill_inode_item()
3896 btrfs_set_token_inode_size(&token, item, inode->i_size); in fill_inode_item()
3899 btrfs_set_token_inode_uid(&token, item, i_uid_read(inode)); in fill_inode_item()
3900 btrfs_set_token_inode_gid(&token, item, i_gid_read(inode)); in fill_inode_item()
3901 btrfs_set_token_inode_mode(&token, item, inode->i_mode); in fill_inode_item()
3902 btrfs_set_token_inode_nlink(&token, item, inode->i_nlink); in fill_inode_item()
3904 btrfs_set_token_timespec_sec(&token, &item->atime, in fill_inode_item()
3905 inode->i_atime.tv_sec); in fill_inode_item()
3906 btrfs_set_token_timespec_nsec(&token, &item->atime, in fill_inode_item()
3907 inode->i_atime.tv_nsec); in fill_inode_item()
3909 btrfs_set_token_timespec_sec(&token, &item->mtime, in fill_inode_item()
3910 inode->i_mtime.tv_sec); in fill_inode_item()
3911 btrfs_set_token_timespec_nsec(&token, &item->mtime, in fill_inode_item()
3912 inode->i_mtime.tv_nsec); in fill_inode_item()
3914 btrfs_set_token_timespec_sec(&token, &item->ctime, in fill_inode_item()
3915 inode->i_ctime.tv_sec); in fill_inode_item()
3916 btrfs_set_token_timespec_nsec(&token, &item->ctime, in fill_inode_item()
3917 inode->i_ctime.tv_nsec); in fill_inode_item()
3919 btrfs_set_token_inode_nbytes(&token, item, inode_get_bytes(inode)); in fill_inode_item()
3921 btrfs_set_token_inode_sequence(&token, item, inode_peek_iversion(inode)); in fill_inode_item()
3922 btrfs_set_token_inode_transid(&token, item, trans->transid); in fill_inode_item()
3923 btrfs_set_token_inode_rdev(&token, item, inode->i_rdev); in fill_inode_item()
3924 btrfs_set_token_inode_flags(&token, item, BTRFS_I(inode)->flags); in fill_inode_item()
3925 btrfs_set_token_inode_block_group(&token, item, 0); in fill_inode_item()
3936 &inode->location, sizeof(*inode_item)); in log_inode_item()
3937 if (ret && ret != -EEXIST) in log_inode_item()
3939 inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], in log_inode_item()
3941 fill_inode_item(trans, path->nodes[0], inode_item, &inode->vfs_inode, in log_inode_item()
3952 const u64 lock_end = sums->bytenr + sums->len - 1; in log_csums()
3961 if (inode->last_reflink_trans < trans->transid) in log_csums()
3970 ret = lock_extent_bits(&log_root->log_csum_range, sums->bytenr, in log_csums()
3983 ret = btrfs_del_csums(trans, log_root, sums->bytenr, sums->len); in log_csums()
3987 unlock_extent_cached(&log_root->log_csum_range, sums->bytenr, lock_end, in log_csums()
4000 struct btrfs_fs_info *fs_info = trans->fs_info; in copy_items()
4003 struct btrfs_root *log = inode->root->log_root; in copy_items()
4006 struct extent_buffer *src = src_path->nodes[0]; in copy_items()
4013 int skip_csum = inode->flags & BTRFS_INODE_NODATASUM; in copy_items()
4020 return -ENOMEM; in copy_items()
4036 for (i = 0; i < nr; i++, dst_path->slots[0]++) { in copy_items()
4037 dst_offset = btrfs_item_ptr_offset(dst_path->nodes[0], in copy_items()
4038 dst_path->slots[0]); in copy_items()
4043 inode_item = btrfs_item_ptr(dst_path->nodes[0], in copy_items()
4044 dst_path->slots[0], in copy_items()
4046 fill_inode_item(trans, dst_path->nodes[0], inode_item, in copy_items()
4047 &inode->vfs_inode, in copy_items()
4051 copy_extent_buffer(dst_path->nodes[0], src, dst_offset, in copy_items()
4065 if (btrfs_file_extent_generation(src, extent) < trans->transid) in copy_items()
4089 fs_info->csum_root, in copy_items()
4090 ds + cs, ds + cs + cl - 1, in copy_items()
4098 btrfs_mark_buffer_dirty(dst_path->nodes[0]); in copy_items()
4112 list_del(&sums->list); in copy_items()
4127 if (em1->start < em2->start) in extent_cmp()
4128 return -1; in extent_cmp()
4129 else if (em1->start > em2->start) in extent_cmp()
4143 u64 mod_start = em->mod_start; in log_extent_csums()
4144 u64 mod_len = em->mod_len; in log_extent_csums()
4148 if (inode->flags & BTRFS_INODE_NODATASUM || in log_extent_csums()
4149 test_bit(EXTENT_FLAG_PREALLOC, &em->flags) || in log_extent_csums()
4150 em->block_start == EXTENT_MAP_HOLE) in log_extent_csums()
4153 list_for_each_entry(ordered, &ctx->ordered_extents, log_list) { in log_extent_csums()
4154 const u64 ordered_end = ordered->file_offset + ordered->num_bytes; in log_extent_csums()
4163 if (mod_end <= ordered->file_offset) in log_extent_csums()
4171 if (ordered->file_offset > mod_start) { in log_extent_csums()
4173 mod_len = ordered->file_offset - mod_start; in log_extent_csums()
4177 * |--------- logged extent ---------| in log_extent_csums()
4178 * |----- ordered extent ----| in log_extent_csums()
4186 mod_len = mod_end - ordered_end; in log_extent_csums()
4197 if (test_and_set_bit(BTRFS_ORDERED_LOGGED_CSUM, &ordered->flags)) in log_extent_csums()
4200 list_for_each_entry(sums, &ordered->list, list) { in log_extent_csums()
4212 if (em->compress_type) { in log_extent_csums()
4214 csum_len = max(em->block_len, em->orig_block_len); in log_extent_csums()
4216 csum_offset = mod_start - em->start; in log_extent_csums()
4221 ret = btrfs_lookup_csums_range(trans->fs_info->csum_root, in log_extent_csums()
4222 em->block_start + csum_offset, in log_extent_csums()
4223 em->block_start + csum_offset + in log_extent_csums()
4224 csum_len - 1, &ordered_sums, 0); in log_extent_csums()
4234 list_del(&sums->list); in log_extent_csums()
4247 struct btrfs_root *log = root->log_root; in log_one_extent()
4250 struct btrfs_map_token token; in log_one_extent() local
4252 u64 extent_offset = em->start - em->orig_start; in log_one_extent()
4261 ret = __btrfs_drop_extents(trans, log, inode, path, em->start, in log_one_extent()
4262 em->start + em->len, NULL, 0, 1, in log_one_extent()
4270 key.offset = em->start; in log_one_extent()
4277 leaf = path->nodes[0]; in log_one_extent()
4278 btrfs_init_map_token(&token, leaf); in log_one_extent()
4279 fi = btrfs_item_ptr(leaf, path->slots[0], in log_one_extent()
4282 btrfs_set_token_file_extent_generation(&token, fi, trans->transid); in log_one_extent()
4283 if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) in log_one_extent()
4284 btrfs_set_token_file_extent_type(&token, fi, in log_one_extent()
4287 btrfs_set_token_file_extent_type(&token, fi, in log_one_extent()
4290 block_len = max(em->block_len, em->orig_block_len); in log_one_extent()
4291 if (em->compress_type != BTRFS_COMPRESS_NONE) { in log_one_extent()
4292 btrfs_set_token_file_extent_disk_bytenr(&token, fi, in log_one_extent()
4293 em->block_start); in log_one_extent()
4294 btrfs_set_token_file_extent_disk_num_bytes(&token, fi, block_len); in log_one_extent()
4295 } else if (em->block_start < EXTENT_MAP_LAST_BYTE) { in log_one_extent()
4296 btrfs_set_token_file_extent_disk_bytenr(&token, fi, in log_one_extent()
4297 em->block_start - in log_one_extent()
4299 btrfs_set_token_file_extent_disk_num_bytes(&token, fi, block_len); in log_one_extent()
4301 btrfs_set_token_file_extent_disk_bytenr(&token, fi, 0); in log_one_extent()
4302 btrfs_set_token_file_extent_disk_num_bytes(&token, fi, 0); in log_one_extent()
4305 btrfs_set_token_file_extent_offset(&token, fi, extent_offset); in log_one_extent()
4306 btrfs_set_token_file_extent_num_bytes(&token, fi, em->len); in log_one_extent()
4307 btrfs_set_token_file_extent_ram_bytes(&token, fi, em->ram_bytes); in log_one_extent()
4308 btrfs_set_token_file_extent_compression(&token, fi, em->compress_type); in log_one_extent()
4309 btrfs_set_token_file_extent_encryption(&token, fi, 0); in log_one_extent()
4310 btrfs_set_token_file_extent_other_encoding(&token, fi, 0); in log_one_extent()
4330 struct btrfs_root *root = inode->root; in btrfs_log_prealloc_extents()
4332 const u64 i_size = i_size_read(&inode->vfs_inode); in btrfs_log_prealloc_extents()
4343 if (!(inode->flags & BTRFS_INODE_PREALLOC)) in btrfs_log_prealloc_extents()
4368 leaf = path->nodes[0]; in btrfs_log_prealloc_extents()
4369 slot = path->slots[0]; in btrfs_log_prealloc_extents()
4388 leaf = path->nodes[0]; in btrfs_log_prealloc_extents()
4389 slot = path->slots[0]; in btrfs_log_prealloc_extents()
4415 path->slots[0]++; in btrfs_log_prealloc_extents()
4425 root->log_root, in btrfs_log_prealloc_extents()
4426 &inode->vfs_inode, in btrfs_log_prealloc_extents()
4429 } while (ret == -EAGAIN); in btrfs_log_prealloc_extents()
4437 path->slots[0]++; in btrfs_log_prealloc_extents()
4441 ret = -ENOMEM; in btrfs_log_prealloc_extents()
4465 struct extent_map_tree *tree = &inode->extent_tree; in btrfs_log_changed_extents()
4472 write_lock(&tree->lock); in btrfs_log_changed_extents()
4473 test_gen = root->fs_info->last_trans_committed; in btrfs_log_changed_extents()
4475 list_for_each_entry_safe(em, n, &tree->modified_extents, list) { in btrfs_log_changed_extents()
4476 list_del_init(&em->list); in btrfs_log_changed_extents()
4484 list_del_init(&tree->modified_extents); in btrfs_log_changed_extents()
4485 ret = -EFBIG; in btrfs_log_changed_extents()
4489 if (em->generation <= test_gen) in btrfs_log_changed_extents()
4493 if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags) && in btrfs_log_changed_extents()
4494 em->start >= i_size_read(&inode->vfs_inode)) in btrfs_log_changed_extents()
4498 refcount_inc(&em->refs); in btrfs_log_changed_extents()
4499 set_bit(EXTENT_FLAG_LOGGING, &em->flags); in btrfs_log_changed_extents()
4500 list_add_tail(&em->list, &extents); in btrfs_log_changed_extents()
4509 list_del_init(&em->list); in btrfs_log_changed_extents()
4521 write_unlock(&tree->lock); in btrfs_log_changed_extents()
4524 write_lock(&tree->lock); in btrfs_log_changed_extents()
4529 write_unlock(&tree->lock); in btrfs_log_changed_extents()
4544 list_for_each_entry_safe(ordered, tmp, &ctx->ordered_extents, log_list) { in btrfs_log_changed_extents()
4545 list_del_init(&ordered->log_list); in btrfs_log_changed_extents()
4546 set_bit(BTRFS_ORDERED_LOGGED, &ordered->flags); in btrfs_log_changed_extents()
4548 if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) { in btrfs_log_changed_extents()
4549 spin_lock_irq(&inode->ordered_tree.lock); in btrfs_log_changed_extents()
4550 if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) { in btrfs_log_changed_extents()
4551 set_bit(BTRFS_ORDERED_PENDING, &ordered->flags); in btrfs_log_changed_extents()
4552 atomic_inc(&trans->transaction->pending_ordered); in btrfs_log_changed_extents()
4554 spin_unlock_irq(&inode->ordered_tree.lock); in btrfs_log_changed_extents()
4580 item = btrfs_item_ptr(path->nodes[0], path->slots[0], in logged_inode_size()
4582 *size_ret = btrfs_inode_size(path->nodes[0], item); in logged_inode_size()
4584 * If the in-memory inode's i_size is smaller then the inode in logged_inode_size()
4594 if (*size_ret > inode->vfs_inode.i_size) in logged_inode_size()
4595 *size_ret = inode->vfs_inode.i_size; in logged_inode_size()
4624 if (test_bit(BTRFS_INODE_NO_XATTRS, &inode->runtime_flags)) in btrfs_log_all_xattrs()
4636 int slot = path->slots[0]; in btrfs_log_all_xattrs()
4637 struct extent_buffer *leaf = path->nodes[0]; in btrfs_log_all_xattrs()
4663 path->slots[0]++; in btrfs_log_all_xattrs()
4675 set_bit(BTRFS_INODE_NO_XATTRS, &inode->runtime_flags); in btrfs_log_all_xattrs()
4694 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_log_holes()
4697 const u64 i_size = i_size_read(&inode->vfs_inode); in btrfs_log_holes()
4713 struct extent_buffer *leaf = path->nodes[0]; in btrfs_log_holes()
4715 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { in btrfs_log_holes()
4723 leaf = path->nodes[0]; in btrfs_log_holes()
4726 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in btrfs_log_holes()
4732 const u64 hole_len = key.offset - prev_extent_end; in btrfs_log_holes()
4740 ret = btrfs_insert_file_extent(trans, root->log_root, in btrfs_log_holes()
4758 return -ENOENT; in btrfs_log_holes()
4759 leaf = path->nodes[0]; in btrfs_log_holes()
4763 path->slots[0]++; in btrfs_log_holes()
4771 hole_len = ALIGN(i_size - prev_extent_end, fs_info->sectorsize); in btrfs_log_holes()
4772 ret = btrfs_insert_file_extent(trans, root->log_root, in btrfs_log_holes()
4791 * sync
4794 * xfs_io -c fsync /mnt/x
4803 * sync
4806 * xfs_io -c fsync /mnt/foo
4841 return -ENOMEM; in btrfs_check_ref_name_override()
4842 search_path->search_commit_root = 1; in btrfs_check_ref_name_override()
4843 search_path->skip_locking = 1; in btrfs_check_ref_name_override()
4852 if (key->type == BTRFS_INODE_REF_KEY) { in btrfs_check_ref_name_override()
4856 parent = key->offset; in btrfs_check_ref_name_override()
4867 name_ptr = (unsigned long)&extref->name; in btrfs_check_ref_name_override()
4876 ret = -ENOMEM; in btrfs_check_ref_name_override()
4884 di = btrfs_lookup_dir_item(NULL, inode->root, search_path, in btrfs_check_ref_name_override()
4889 btrfs_dir_item_key_to_cpu(search_path->nodes[0], in btrfs_check_ref_name_override()
4892 if (di_key.objectid != key->objectid) { in btrfs_check_ref_name_override()
4900 ret = -EAGAIN; in btrfs_check_ref_name_override()
4936 return -ENOMEM; in log_conflicting_inodes()
4937 ino_elem->ino = ino; in log_conflicting_inodes()
4938 ino_elem->parent = parent; in log_conflicting_inodes()
4939 list_add_tail(&ino_elem->list, &inode_list); in log_conflicting_inodes()
4942 struct btrfs_fs_info *fs_info = root->fs_info; in log_conflicting_inodes()
4948 ino = ino_elem->ino; in log_conflicting_inodes()
4949 parent = ino_elem->parent; in log_conflicting_inodes()
4950 list_del(&ino_elem->list); in log_conflicting_inodes()
4957 inode = btrfs_iget(fs_info->sb, ino, root); in log_conflicting_inodes()
4965 if (ret == -ENOENT) { in log_conflicting_inodes()
4966 inode = btrfs_iget(fs_info->sb, parent, root); in log_conflicting_inodes()
4980 * If the inode was already logged skip it - otherwise we can in log_conflicting_inodes()
5000 * - we detect inode 258 as a conflicting inode, with inode 261 in log_conflicting_inodes()
5003 * - we detect inode 259 as a conflicting inode, with inode 258 in log_conflicting_inodes()
5006 * - we detect inode 258 as a conflicting inode, with inode 259 in log_conflicting_inodes()
5007 * on reference "zz_link", and log it - again! After this we in log_conflicting_inodes()
5010 spin_lock(&BTRFS_I(inode)->lock); in log_conflicting_inodes()
5015 * it has the full sync bit set (see btrfs_log_inode()). in log_conflicting_inodes()
5017 if (BTRFS_I(inode)->logged_trans == trans->transid) { in log_conflicting_inodes()
5018 spin_unlock(&BTRFS_I(inode)->lock); in log_conflicting_inodes()
5022 spin_unlock(&BTRFS_I(inode)->lock); in log_conflicting_inodes()
5047 struct extent_buffer *leaf = path->nodes[0]; in log_conflicting_inodes()
5048 int slot = path->slots[0]; in log_conflicting_inodes()
5079 ret = -ENOMEM; in log_conflicting_inodes()
5082 ino_elem->ino = other_ino; in log_conflicting_inodes()
5083 ino_elem->parent = other_parent; in log_conflicting_inodes()
5084 list_add_tail(&ino_elem->list, &inode_list); in log_conflicting_inodes()
5087 path->slots[0]++; in log_conflicting_inodes()
5107 const u64 i_size = i_size_read(&inode->vfs_inode); in copy_inode_items_to_log()
5108 struct btrfs_root *root = inode->root; in copy_inode_items_to_log()
5114 ret = btrfs_search_forward(root, min_key, path, trans->transid); in copy_inode_items_to_log()
5123 if (min_key->objectid != max_key->objectid) in copy_inode_items_to_log()
5125 if (min_key->type > max_key->type) in copy_inode_items_to_log()
5128 if (min_key->type == BTRFS_INODE_ITEM_KEY) { in copy_inode_items_to_log()
5130 } else if (min_key->type == BTRFS_EXTENT_DATA_KEY && in copy_inode_items_to_log()
5131 min_key->offset >= i_size) { in copy_inode_items_to_log()
5139 } else if ((min_key->type == BTRFS_INODE_REF_KEY || in copy_inode_items_to_log()
5140 min_key->type == BTRFS_INODE_EXTREF_KEY) && in copy_inode_items_to_log()
5141 inode->generation == trans->transid && in copy_inode_items_to_log()
5146 ret = btrfs_check_ref_name_override(path->nodes[0], in copy_inode_items_to_log()
5147 path->slots[0], min_key, inode, in copy_inode_items_to_log()
5152 other_ino != btrfs_ino(BTRFS_I(ctx->inode))) { in copy_inode_items_to_log()
5157 ins_start_slot = path->slots[0]; in copy_inode_items_to_log()
5173 } else if (min_key->type == BTRFS_XATTR_ITEM_KEY) { in copy_inode_items_to_log()
5186 if (ins_nr && ins_start_slot + ins_nr == path->slots[0]) { in copy_inode_items_to_log()
5190 ins_start_slot = path->slots[0]; in copy_inode_items_to_log()
5200 ins_start_slot = path->slots[0]; in copy_inode_items_to_log()
5202 path->slots[0]++; in copy_inode_items_to_log()
5203 if (path->slots[0] < btrfs_header_nritems(path->nodes[0])) { in copy_inode_items_to_log()
5204 btrfs_item_key_to_cpu(path->nodes[0], min_key, in copy_inode_items_to_log()
5205 path->slots[0]); in copy_inode_items_to_log()
5218 if (min_key->offset < (u64)-1) { in copy_inode_items_to_log()
5219 min_key->offset++; in copy_inode_items_to_log()
5220 } else if (min_key->type < max_key->type) { in copy_inode_items_to_log()
5221 min_key->type++; in copy_inode_items_to_log()
5222 min_key->offset = 0; in copy_inode_items_to_log()
5234 if (inode_only == LOG_INODE_ALL && S_ISREG(inode->vfs_inode.i_mode)) { in copy_inode_items_to_log()
5269 struct btrfs_root *log = root->log_root; in btrfs_log_inode()
5274 struct extent_map_tree *em_tree = &inode->extent_tree; in btrfs_log_inode()
5282 return -ENOMEM; in btrfs_log_inode()
5286 return -ENOMEM; in btrfs_log_inode()
5297 if (S_ISDIR(inode->vfs_inode.i_mode) || in btrfs_log_inode()
5299 &inode->runtime_flags) && in btrfs_log_inode()
5303 max_key.type = (u8)-1; in btrfs_log_inode()
5304 max_key.offset = (u64)-1; in btrfs_log_inode()
5311 * Otherwise commit the delayed inode only if the full sync flag is set, in btrfs_log_inode()
5314 * it to the log tree. For a non full sync, we always log the inode item in btrfs_log_inode()
5315 * based on the in-memory struct btrfs_inode which is always up to date. in btrfs_log_inode()
5317 if (S_ISDIR(inode->vfs_inode.i_mode)) in btrfs_log_inode()
5319 else if (test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags)) in btrfs_log_inode()
5334 mutex_lock_nested(&inode->log_mutex, SINGLE_DEPTH_NESTING); in btrfs_log_inode()
5336 mutex_lock(&inode->log_mutex); in btrfs_log_inode()
5342 * log replay, which is invalid on linux (symlink(2) returns -ENOENT if in btrfs_log_inode()
5348 if (S_ISLNK(inode->vfs_inode.i_mode)) in btrfs_log_inode()
5355 if (S_ISDIR(inode->vfs_inode.i_mode)) { in btrfs_log_inode()
5368 * truncate - for e.g. create file, write 4K into offset in btrfs_log_inode()
5370 * fsync some other file (to sync log), power fail - if in btrfs_log_inode()
5381 &inode->runtime_flags)) { in btrfs_log_inode()
5388 &inode->runtime_flags); in btrfs_log_inode()
5390 &inode->runtime_flags); in btrfs_log_inode()
5393 log, &inode->vfs_inode, 0, 0); in btrfs_log_inode()
5394 if (ret != -EAGAIN) in btrfs_log_inode()
5399 &inode->runtime_flags) || in btrfs_log_inode()
5461 write_lock(&em_tree->lock); in btrfs_log_inode()
5462 list_for_each_entry_safe(em, n, &em_tree->modified_extents, list) in btrfs_log_inode()
5463 list_del_init(&em->list); in btrfs_log_inode()
5464 write_unlock(&em_tree->lock); in btrfs_log_inode()
5467 if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->vfs_inode.i_mode)) { in btrfs_log_inode()
5479 * logged - otherwise if an explicit fsync is made against an ancestor, in btrfs_log_inode()
5480 * the fsync considers the inode in the log and doesn't sync the log, in btrfs_log_inode()
5487 !(S_ISDIR(inode->vfs_inode.i_mode) && ctx->logging_new_name && in btrfs_log_inode()
5488 &inode->vfs_inode != ctx->inode)) { in btrfs_log_inode()
5489 spin_lock(&inode->lock); in btrfs_log_inode()
5490 inode->logged_trans = trans->transid; in btrfs_log_inode()
5501 !test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags)) in btrfs_log_inode()
5502 inode->last_log_commit = inode->last_sub_trans; in btrfs_log_inode()
5503 spin_unlock(&inode->lock); in btrfs_log_inode()
5506 mutex_unlock(&inode->log_mutex); in btrfs_log_inode()
5516 * when fsyncing an inode requires the need to log some other inode - in which
5521 * its last_unlink_trans value - this is safe because any task setting
5532 struct btrfs_fs_info *fs_info = inode->root->fs_info; in btrfs_must_commit_transaction()
5535 mutex_lock(&inode->log_mutex); in btrfs_must_commit_transaction()
5536 if (inode->last_unlink_trans > fs_info->last_trans_committed) { in btrfs_must_commit_transaction()
5544 mutex_unlock(&inode->log_mutex); in btrfs_must_commit_transaction()
5570 if (S_ISREG(inode->vfs_inode.i_mode) && in check_parent_dirs_for_sync()
5571 inode->generation <= last_committed && in check_parent_dirs_for_sync()
5572 inode->last_unlink_trans <= last_committed) in check_parent_dirs_for_sync()
5575 if (!S_ISDIR(inode->vfs_inode.i_mode)) { in check_parent_dirs_for_sync()
5576 if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) in check_parent_dirs_for_sync()
5587 if (!parent || d_really_is_negative(parent) || sb != parent->d_sb) in check_parent_dirs_for_sync()
5616 * This is a recursive operation - if an existing dentry corresponds to a
5623 * ---- ----
5624 * lock(&type->i_mutex_dir_key#3/2);
5626 * lock(&type->i_mutex_dir_key#3/2);
5627 * lock(&sb->s_type->i_mutex_key#14);
5660 struct btrfs_fs_info *fs_info = root->fs_info; in log_new_dir_dentries()
5661 struct btrfs_root *log = root->log_root; in log_new_dir_dentries()
5669 return -ENOMEM; in log_new_dir_dentries()
5674 return -ENOMEM; in log_new_dir_dentries()
5676 dir_elem->ino = btrfs_ino(start_inode); in log_new_dir_dentries()
5677 list_add_tail(&dir_elem->list, &dir_list); in log_new_dir_dentries()
5690 min_key.objectid = dir_elem->ino; in log_new_dir_dentries()
5695 ret = btrfs_search_forward(log, &min_key, path, trans->transid); in log_new_dir_dentries()
5704 leaf = path->nodes[0]; in log_new_dir_dentries()
5706 for (i = path->slots[0]; i < nritems; i++) { in log_new_dir_dentries()
5715 if (min_key.objectid != dir_elem->ino || in log_new_dir_dentries()
5721 if (btrfs_dir_transid(leaf, di) < trans->transid && in log_new_dir_dentries()
5729 di_inode = btrfs_iget(fs_info->sb, di_key.objectid, root); in log_new_dir_dentries()
5735 if (btrfs_inode_in_log(BTRFS_I(di_inode), trans->transid)) { in log_new_dir_dentries()
5740 ctx->log_new_dentries = false; in log_new_dir_dentries()
5751 if (ctx->log_new_dentries) { in log_new_dir_dentries()
5755 ret = -ENOMEM; in log_new_dir_dentries()
5758 new_dir_elem->ino = di_key.objectid; in log_new_dir_dentries()
5759 list_add_tail(&new_dir_elem->list, &dir_list); in log_new_dir_dentries()
5773 if (min_key.offset < (u64)-1) { in log_new_dir_dentries()
5778 list_del(&dir_elem->list); in log_new_dir_dentries()
5790 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_log_all_parents()
5794 struct btrfs_root *root = inode->root; in btrfs_log_all_parents()
5799 return -ENOMEM; in btrfs_log_all_parents()
5800 path->skip_locking = 1; in btrfs_log_all_parents()
5801 path->search_commit_root = 1; in btrfs_log_all_parents()
5811 struct extent_buffer *leaf = path->nodes[0]; in btrfs_log_all_parents()
5812 int slot = path->slots[0]; in btrfs_log_all_parents()
5855 dir_inode = btrfs_iget(fs_info->sb, inode_key.objectid, in btrfs_log_all_parents()
5869 * sync in btrfs_log_all_parents()
5871 * mv -T /mnt/A /mnt/B in btrfs_log_all_parents()
5886 ctx->log_new_dentries = false; in btrfs_log_all_parents()
5892 if (!ret && ctx && ctx->log_new_dentries) in btrfs_log_all_parents()
5899 path->slots[0]++; in btrfs_log_all_parents()
5914 btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]); in log_new_ancestors()
5917 struct btrfs_fs_info *fs_info = root->fs_info; in log_new_ancestors()
5918 const u64 last_committed = fs_info->last_trans_committed; in log_new_ancestors()
5919 struct extent_buffer *leaf = path->nodes[0]; in log_new_ancestors()
5920 int slot = path->slots[0]; in log_new_ancestors()
5933 inode = btrfs_iget(fs_info->sb, ino, root); in log_new_ancestors()
5937 if (BTRFS_I(inode)->generation > last_committed) in log_new_ancestors()
5952 leaf = path->nodes[0]; in log_new_ancestors()
5953 slot = path->slots[0]; in log_new_ancestors()
5959 return -ENOENT; in log_new_ancestors()
5960 leaf = path->nodes[0]; in log_new_ancestors()
5961 slot = path->slots[0]; in log_new_ancestors()
5967 return -ENOENT; in log_new_ancestors()
5977 struct btrfs_root *root = inode->root; in log_new_ancestors_fast()
5978 struct btrfs_fs_info *fs_info = root->fs_info; in log_new_ancestors_fast()
5980 struct super_block *sb = inode->vfs_inode.i_sb; in log_new_ancestors_fast()
5985 sb != parent->d_sb) in log_new_ancestors_fast()
5989 if (root != inode->root) in log_new_ancestors_fast()
5992 if (inode->generation > fs_info->last_trans_committed) { in log_new_ancestors_fast()
6015 struct btrfs_root *root = inode->root; in log_all_new_ancestors()
6025 if (inode->vfs_inode.i_nlink < 2) in log_all_new_ancestors()
6030 return -ENOMEM; in log_all_new_ancestors()
6040 path->slots[0]++; in log_all_new_ancestors()
6043 struct extent_buffer *leaf = path->nodes[0]; in log_all_new_ancestors()
6044 int slot = path->slots[0]; in log_all_new_ancestors()
6069 ret = -EMLINK; in log_all_new_ancestors()
6105 struct btrfs_root *root = inode->root; in btrfs_log_inode_parent()
6106 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_log_inode_parent()
6109 u64 last_committed = fs_info->last_trans_committed; in btrfs_log_inode_parent()
6112 sb = inode->vfs_inode.i_sb; in btrfs_log_inode_parent()
6123 if (fs_info->last_trans_log_full_commit > in btrfs_log_inode_parent()
6124 fs_info->last_trans_committed) { in btrfs_log_inode_parent()
6129 if (btrfs_root_refs(&root->root_item) == 0) { in btrfs_log_inode_parent()
6144 if ((btrfs_inode_in_log(inode, trans->transid) && in btrfs_log_inode_parent()
6145 list_empty(&ctx->ordered_extents)) || in btrfs_log_inode_parent()
6146 inode->vfs_inode.i_nlink == 0) { in btrfs_log_inode_parent()
6165 if (S_ISREG(inode->vfs_inode.i_mode) && in btrfs_log_inode_parent()
6166 inode->generation <= last_committed && in btrfs_log_inode_parent()
6167 inode->last_unlink_trans <= last_committed) { in btrfs_log_inode_parent()
6172 if (S_ISDIR(inode->vfs_inode.i_mode) && ctx && ctx->log_new_dentries) in btrfs_log_inode_parent()
6181 * error -ENOTEMPTY). in btrfs_log_inode_parent()
6188 * sync in btrfs_log_inode_parent()
6190 * xfs_io -c fsync testdir/foo in btrfs_log_inode_parent()
6205 * sync in btrfs_log_inode_parent()
6207 * xfs_io -c fsync foo in btrfs_log_inode_parent()
6216 if (inode->last_unlink_trans > last_committed) { in btrfs_log_inode_parent()
6275 struct btrfs_fs_info *fs_info = log_root_tree->fs_info; in btrfs_recover_log_trees()
6283 return -ENOMEM; in btrfs_recover_log_trees()
6285 set_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); in btrfs_recover_log_trees()
6287 trans = btrfs_start_transaction(fs_info->tree_root, 0); in btrfs_recover_log_trees()
6305 key.offset = (u64)-1; in btrfs_recover_log_trees()
6317 if (path->slots[0] == 0) in btrfs_recover_log_trees()
6319 path->slots[0]--; in btrfs_recover_log_trees()
6321 btrfs_item_key_to_cpu(path->nodes[0], &found_key, in btrfs_recover_log_trees()
6322 path->slots[0]); in btrfs_recover_log_trees()
6351 if (ret == -ENOENT) in btrfs_recover_log_trees()
6353 log->node->start, in btrfs_recover_log_trees()
6354 log->node->len); in btrfs_recover_log_trees()
6364 wc.replay_dest->log_root = log; in btrfs_recover_log_trees()
6383 * root->objectid_mutex is not acquired as log replay in btrfs_recover_log_trees()
6387 &root->highest_objectid); in btrfs_recover_log_trees()
6390 wc.replay_dest->log_root = NULL; in btrfs_recover_log_trees()
6399 key.offset = found_key.offset - 1; in btrfs_recover_log_trees()
6423 log_root_tree->log_root = NULL; in btrfs_recover_log_trees()
6424 clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); in btrfs_recover_log_trees()
6431 clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); in btrfs_recover_log_trees()
6461 mutex_lock(&inode->log_mutex); in btrfs_record_unlink_dir()
6462 inode->last_unlink_trans = trans->transid; in btrfs_record_unlink_dir()
6463 mutex_unlock(&inode->log_mutex); in btrfs_record_unlink_dir()
6469 if (dir->logged_trans == trans->transid) in btrfs_record_unlink_dir()
6476 if (inode->logged_trans == trans->transid) in btrfs_record_unlink_dir()
6493 mutex_lock(&dir->log_mutex); in btrfs_record_unlink_dir()
6494 dir->last_unlink_trans = trans->transid; in btrfs_record_unlink_dir()
6495 mutex_unlock(&dir->log_mutex); in btrfs_record_unlink_dir()
6513 mutex_lock(&dir->log_mutex); in btrfs_record_snapshot_destroy()
6514 dir->last_unlink_trans = trans->transid; in btrfs_record_snapshot_destroy()
6515 mutex_unlock(&dir->log_mutex); in btrfs_record_snapshot_destroy()
6532 if (!S_ISDIR(inode->vfs_inode.i_mode)) in btrfs_log_new_name()
6533 inode->last_unlink_trans = trans->transid; in btrfs_log_new_name()
6543 btrfs_init_log_ctx(&ctx, &inode->vfs_inode); in btrfs_log_new_name()
6547 * then we know the next attempt to sync the log will fallback to a full in btrfs_log_new_name()