Lines Matching full:log

13 #include "tree-log.h"
38 * LOG_INODE_ALL means to log everything
39 * LOG_INODE_EXISTS means to log just enough to recreate the inode
40 * during log replay
51 * log, we must force a full commit before doing an fsync of the directory
65 * 2) we must log any new names for any file or dir that is in the fsync
66 * log. ---> check inode while renaming/linking.
68 * 2a) we must log any new names for any file or dir during rename
94 * we find in the log are created in the subvolume.
108 * the log tree. The stage field tells us which part of the log tree processing
113 * Signal that we are freeing the metadata extents of a log tree.
114 * This is used at transaction commit time while freeing a log tree.
119 * Signal that we are pinning the metadata extents of a log tree and the
121 * This happens in the first stage of log replay to ensure that during
123 * the metadata extents of log trees.
142 /* The log tree we are currently processing (not NULL for any stage). */
143 struct btrfs_root *log; member
145 /* The transaction handle used for replaying all log trees. */
161 /* The current log leaf being processed. */
163 /* The key being processed of the current log leaf. */
165 /* The slot being processed of the current log leaf. */
183 * BTRFS_FS_STATE_TRANS_ABORTED because log replay calls functions that in do_abort_log_replay()
184 * are outside of tree-log.c that can abort transactions (such as in do_abort_log_replay()
186 * dump all log replay specific information below. in do_abort_log_replay()
202 "log tree (for root %llu) leaf currently being processed (slot %d key " BTRFS_KEY_FMT "):", in do_abort_log_replay()
213 "log replay failed in %s:%u for root %llu, stage %d, with error %d: %pV", in do_abort_log_replay()
220 * Use this for aborting a transaction during log replay while we are down the
238 * tree logging is a special write ahead log used to make sure that
251 * After a crash, items are copied out of the log-tree back into the
253 * allocation tree, and the log-tree freed.
255 * The log tree is read three times, once to pin down all the extents it is
265 /* Only meant to be called for subvolume roots and not for log roots. */ in btrfs_iget_logging()
270 * replaying a log tree, so we must make sure NOFS semantics apply in btrfs_iget_logging()
283 * start a sub transaction and setup the log tree
284 * this increments the log tree writer count to make the people
298 * First check if the log root tree was already created. If not, create in start_log_trans()
341 * nodes from multiple log transactions to do sequential in start_log_trans()
371 * returns 0 if there was a log transaction running and we were able
400 * This either makes the current running log transaction wait
402 * log transactions wait until you call btrfs_end_log_trans()
410 * indicate we're done making changes to the log tree
427 struct btrfs_root *log = wc->log; in process_one_buffer() local
429 struct btrfs_fs_info *fs_info = log->fs_info; in process_one_buffer()
470 * Item overwrite used by log replay. The given log tree leaf, slot and key
499 * This is only used during log replay, so the root is always from a in overwrite_item()
500 * fs/subvolume tree. In case we ever need to support a log root, then in overwrite_item()
502 * the leaf before writing into the log tree. See the comments at in overwrite_item()
537 "failed to allocate memory for log leaf item"); in overwrite_item()
576 * the rest of the items in this log. in overwrite_item()
596 * the items in this log. in overwrite_item()
633 * log replay inserts and removes directory items based on the in overwrite_item()
709 * extents in the log tree have not been allocated out of the extent
862 * as the owner of the file extent changed from log tree (doesn't affect in replay_one_extent()
945 * each other. For example, imagine our log has the two following file in replay_one_extent()
957 * disk byte 12845056, and the log tree has a single csum item that in replay_one_extent()
1061 * that future checks for a name during log replay see that the name in unlink_inode_for_log_replay()
1076 * subvolume, directory names in the log and directory names in the
1172 * helper function to check a log tree for a named back reference in
1174 * found in the subvolume conflicts with what we find in the log.
1179 * link is also in the log.
1181 static noinline int backref_in_log(struct btrfs_root *log, in backref_in_log() argument
1193 ret = btrfs_search_slot(NULL, log, key, path, 0, 0); in backref_in_log()
1220 * log. If so, we allow them to stay otherwise they must be unlinked as in unlink_refs_not_in_log()
1242 ret = backref_in_log(wc->log, search_key, btrfs_ino(dir), &victim_name); in unlink_refs_not_in_log()
1246 "failed to check if backref is in log tree for inode %llu parent dir %llu name %.*s root %llu", in unlink_refs_not_in_log()
1282 struct btrfs_root *log_root = wc->log; in unlink_extrefs_not_in_log()
1312 "failed to check if backref is in log tree for inode %llu parent dir %llu name %.*s root %llu", in unlink_extrefs_not_in_log()
1470 * Take an inode reference item from the log tree and iterate all names from the
1472 * For any name that is not in the inode reference item from the log tree, do a
1570 * Replay one inode back reference item found in the log tree.
1605 * it is possible that we didn't log all the parent directories in add_inode_ref()
1748 * with the item from the log tree, we must unlink all names from the in add_inode_ref()
1872 * lots of complexity to the log code, we just scan the backrefs
2038 * when replaying the log for a directory, we only insert names
2099 * take a single entry in a log directory item and replay it into
2106 * If a name from the log points to a file or directory that does
2219 * Check if the inode reference exists in the log for the given name, in replay_one_name()
2291 /* We only log dir index keys, which only contain a single dir item. */ in replay_one_dir_item()
2319 * mount fs, log replay happens in replay_one_dir_item()
2338 * items in the log copied from the subvolume, and range items
2339 * created in the log while the subvolume was logged.
2341 * The range items tell us which parts of the key space the log
2343 * directory is in a logged range item, but not actually in the log
2419 * this looks for a given directory item in the log. If the directory
2420 * item is not in the log, the item is removed and the inode it points
2440 * Currently we only log dir index keys. Even if we replay a log created in check_item_in_log()
2462 log_di = btrfs_lookup_dir_index_item(trans, wc->log, log_path, in check_item_in_log()
2474 /* The dentry exists in the log, we have nothing to do. */ in check_item_in_log()
2517 struct btrfs_root *log = wc->log; in replay_xattr_deletes() local
2576 log_di = btrfs_lookup_xattr(NULL, log, log_path, ino, in replay_xattr_deletes()
2580 /* Doesn't exist in log tree, so delete it. */ in replay_xattr_deletes()
2612 "failed to lookup xattr in log tree with name %.*s for inode %llu root %llu", in replay_xattr_deletes()
2640 * out of the log or out of backreferences from inodes. It
2641 * scans the log to find ranges of keys that log is authoritative for,
2643 * not present in the log.
2645 * Anything we don't find in the log is unlinked and removed from the
2652 struct btrfs_root *log = (del_all ? NULL : wc->log); in replay_dir_deletes() local
2672 * we replay the deletes before we copy in the inode item from the log. in replay_dir_deletes()
2691 ret = find_dir_range(log, wc->subvol_path, dirid, in replay_dir_deletes()
2695 "failed to find range for dir %llu in log tree root %llu", in replay_dir_deletes()
2759 * the process_func used to replay items from the log tree. This
2763 * The second stage copies all the other item types from the log into
2766 * only in the log (references come from either directory items or inode
2785 * Set to NULL since it was not yet read and in case we abort log replay in replay_one_buffer()
2786 * on error, we have no valid log tree leaf to dump. in replay_one_buffer()
2792 "failed to read log tree leaf %llu for root %llu", in replay_one_buffer()
2822 * we are replaying a log created with a kernel that in replay_one_buffer()
2823 * used to log tmpfiles; in replay_one_buffer()
2827 * fsynced through that fd. We always log the in replay_one_buffer()
2862 * size. We need to do it now and not after log replay in replay_one_buffer()
2945 * We don't log BTRFS_DIR_ITEM_KEY keys anymore, only the in replay_one_buffer()
2947 * BTRFS_DIR_ITEM_KEY items. If we are replaying a log from an in replay_one_buffer()
2999 struct btrfs_fs_info *fs_info = wc->log->fs_info; in walk_down_log_tree()
3128 struct btrfs_root *log = wc->log; in walk_log_tree() local
3139 level = btrfs_header_level(log->node); in walk_log_tree()
3141 path->nodes[level] = log->node; in walk_log_tree()
3142 refcount_inc(&log->node->refs); in walk_log_tree()
3174 * helper function to update the item for a given subvolumes log root
3175 * in the tree of log roots
3178 struct btrfs_root *log, in update_log_root() argument
3181 struct btrfs_fs_info *fs_info = log->fs_info; in update_log_root()
3184 if (log->log_transid == 1) { in update_log_root()
3187 &log->root_key, root_item); in update_log_root()
3190 &log->root_key, root_item); in update_log_root()
3201 * we only allow two pending log transactions at a time, in wait_log_commit()
3292 * Invoked in log mutex context, or be sure there is no other task which
3308 * Sends a given tree log down to the disk and updates the super blocks to
3326 struct btrfs_root *log = root->log_root; in btrfs_sync_log() local
3352 /* wait for previous tree log sync to complete */ in btrfs_sync_log()
3358 /* when we're on an ssd, just kick the log commit out */ in btrfs_sync_log()
3386 ret = btrfs_write_marked_extents(fs_info, &log->dirty_log_pages, mark); in btrfs_sync_log()
3389 * commit, writes a dirty extent in this tree-log commit. This in btrfs_sync_log()
3407 * have a consistent view of the log root we are trying to commit at in btrfs_sync_log()
3418 btrfs_set_root_node(&log->root_item, log->node); in btrfs_sync_log()
3419 memcpy(&new_root_item, &log->root_item, sizeof(new_root_item)); in btrfs_sync_log()
3422 log->log_transid = root->log_transid; in btrfs_sync_log()
3425 * IO has been started, blocks of the log tree have WRITTEN flag set in btrfs_sync_log()
3426 * in their headers. new modifications of the log will be written to in btrfs_sync_log()
3427 * new positions. so it's safe to allow log writers to go in. in btrfs_sync_log()
3457 ret = update_log_root(trans, log, &new_root_item); in btrfs_sync_log()
3464 "failed to update log for root %llu ret %d", in btrfs_sync_log()
3466 btrfs_wait_tree_log_extents(log, mark); in btrfs_sync_log()
3481 ret = btrfs_wait_tree_log_extents(log, mark); in btrfs_sync_log()
3500 * now that we've moved on to the tree of log tree roots, in btrfs_sync_log()
3505 btrfs_wait_tree_log_extents(log, mark); in btrfs_sync_log()
3522 btrfs_wait_tree_log_extents(log, mark); in btrfs_sync_log()
3530 ret = btrfs_wait_tree_log_extents(log, mark); in btrfs_sync_log()
3590 * log must wait for the previous log transaction to commit if it's in btrfs_sync_log()
3591 * still in progress or wait for the current log transaction commit if in btrfs_sync_log()
3593 * first log transaction has an ID of 0. in btrfs_sync_log()
3631 struct btrfs_root *log) in free_log_tree() argument
3637 .log = log, in free_log_tree()
3641 if (log->node) { in free_log_tree()
3645 * We weren't able to traverse the entire log tree, the in free_log_tree()
3651 &log->fs_info->fs_state); in free_log_tree()
3654 * Some extent buffers of the log tree may still be dirty in free_log_tree()
3656 * have updates to a log tree without syncing a log tree, in free_log_tree()
3661 btrfs_write_marked_extents(log->fs_info, in free_log_tree()
3662 &log->dirty_log_pages, in free_log_tree()
3664 btrfs_wait_tree_log_extents(log, in free_log_tree()
3670 btrfs_handle_fs_error(log->fs_info, ret, NULL); in free_log_tree()
3674 btrfs_extent_io_tree_release(&log->dirty_log_pages); in free_log_tree()
3675 btrfs_extent_io_tree_release(&log->log_csum_range); in free_log_tree()
3677 btrfs_put_root(log); in free_log_tree()
3681 * free all the extents used by the tree log. This should be called
3711 * not find it in the log tree and we end up setting ->logged_trans to a in mark_inode_as_not_logged()
3715 * names from the log. in mark_inode_as_not_logged()
3772 * If no log tree was created for this root in this transaction, then in inode_logged()
3776 * a log tree gets created after this. in inode_logged()
3782 * We have a log tree and the inode's logged_trans is 0. We can't tell in inode_logged()
3786 * operations, and then further updating the log in followup rename and in inode_logged()
3802 * case 3) and return true. So we do a search in the log root for the inode in inode_logged()
3849 * Delete a directory entry from the log if it exists.
3856 struct btrfs_root *log, in del_logged_dentry() argument
3865 * We only log dir index items of a directory, so we don't need to look in del_logged_dentry()
3868 di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino, in del_logged_dentry()
3877 * inode item because on log replay we update the field to reflect in del_logged_dentry()
3880 return btrfs_del_item(trans, log, path); in del_logged_dentry()
3894 * didn't get fsync'd again so the log has back refs for X and X.link.
3897 * log when a file that was logged in the current transaction is
3898 * unlinked. Any later fsync will include the updated log entries, and
3973 * creates a range item in the log for 'dirid'. first_offset and
3974 * last_offset tell us which parts of the key space the log should
3978 struct btrfs_root *log, in insert_dir_log_key() argument
3990 ret = btrfs_insert_empty_item(trans, log, path, &key, sizeof(*item)); in insert_dir_log_key()
4026 struct btrfs_root *log = inode->root->log_root; in flush_dir_items_batch() local
4070 ret = btrfs_insert_empty_items(trans, log, dst_path, &batch); in flush_dir_items_batch()
4141 struct btrfs_root *log = inode->root->log_root; in process_dir_items_leaf() local
4152 * clone before modifying the log tree. See the comment at copy_items() in process_dir_items_leaf()
4176 * in past transactions. However if we find a gap, we must log a in process_dir_items_leaf()
4178 * gap are deleted during log replay. in process_dir_items_leaf()
4182 ret = insert_dir_log_key(trans, log, dst_path, in process_dir_items_leaf()
4198 * We must make sure that when we log a directory entry, the in process_dir_items_leaf()
4199 * corresponding inode, after log replay, has a matching link in process_dir_items_leaf()
4208 * <mount fs and log replay> in process_dir_items_leaf()
4210 * Would result in a fsync log that when replayed, our file inode in process_dir_items_leaf()
4243 * log all the items included in the current transaction for a given
4244 * directory. This also creates the range items in the log tree required
4256 struct btrfs_root *log = root->log_root; in log_dir_items() local
4314 * happened. So the key range item we log (key type in log_dir_items()
4331 * need to log the parent directory of an inode. This means a dir index in log_dir_items()
4335 * not log dir index keys that come after the one that was just deleted in log_dir_items()
4338 * entries we should not remove at log replay time. in log_dir_items()
4354 * we have a block from this transaction, log every item in it in log_dir_items()
4390 * that next key. So the key range item we log (key type in log_dir_items()
4414 * change in the current transaction), then we don't need to log in log_dir_items()
4421 ret = insert_dir_log_key(trans, log, path, ino, in log_dir_items()
4433 * is to avoid lookups in the log tree every time we try to insert a dir index
4496 * from the current transaction and write them to the log.
4499 * key in the range logged that is not present in the log tree, then it means
4537 * a helper function to drop items from the log before we relog an
4543 struct btrfs_root *log, in drop_inode_items() argument
4558 ret = btrfs_search_slot(trans, log, &key, path, -1, 1); in drop_inode_items()
4579 ret = btrfs_del_items(trans, log, path, start_slot, in drop_inode_items()
4664 * only waits for writeback to complete. During log replay as we find in fill_inode_item()
4678 struct btrfs_root *log, struct btrfs_path *path, in log_inode_item() argument
4689 * it exists in the log tree. For performance reasons, in this case use in log_inode_item()
4697 ret = btrfs_search_slot(trans, log, &key, path, 0, 1); in log_inode_item()
4704 * so the inode item is not in the log and we need to insert it. in log_inode_item()
4711 ret = btrfs_insert_empty_item(trans, log, path, &key, in log_inode_item()
4745 * can leave checksum items in the log with overlapping ranges. in log_csums()
4755 * This would leave csum items in the log tree that cover the same range in log_csums()
4756 * and break the searches for checksums in the log tree, resulting in in log_csums()
4758 * trim and adjust) any existing csum items in the log for this range. in log_csums()
4777 struct btrfs_root *log = inode->root->log_root; in copy_items() local
4791 * use the clone. This is because otherwise we would be changing the log in copy_items()
4794 * creates a nasty lock dependency when COWing log tree nodes/leaves: in copy_items()
4796 * 1) Modifying the log tree triggers an extent buffer allocation while in copy_items()
4797 * holding a write lock on a parent extent buffer from the log tree. in copy_items()
4803 * 2) Allocating a metadata extent for a log tree can trigger the async in copy_items()
4809 * on the parent extent buffer in the log tree. in copy_items()
4860 * log a lot more metadata for common cases like doing only a in copy_items()
4867 * generations copied into it. We also must always log prealloc in copy_items()
4869 * them on log replay. in copy_items()
4886 * no need to log them. in copy_items()
4924 ret = log_csums(trans, inode, log, sums); in copy_items()
4945 ret = btrfs_insert_empty_items(trans, log, dst_path, &batch); in copy_items()
5143 struct btrfs_root *log = inode->root->log_root; in log_one_extent() local
5174 ret = log_extent_csums(trans, inode, log, em, ctx); in log_one_extent()
5183 * but also adds significant contention in a log tree, since log trees in log_one_extent()
5193 ret = btrfs_drop_extents(trans, log, inode, &drop_args); in log_one_extent()
5203 ret = btrfs_insert_empty_item(trans, log, path, &key, in log_one_extent()
5219 * Log all prealloc extents beyond the inode's i_size to make sure we do not
5220 * lose them after doing a full/fast fsync and replaying the log. We scan the
5222 * otherwise we can log incorrect extent items based on extent map conversion.
5258 * otherwise we end up losing part of the prealloc extent after a log in btrfs_log_prealloc_extents()
5320 * Avoid overlapping items in the log tree. The first time we in btrfs_log_prealloc_extents()
5388 /* We log prealloc extents beyond eof later. */ in btrfs_log_changed_extents()
5435 * before it commits and wipes out the log trees, otherwise we would in btrfs_log_changed_extents()
5490 * its inode item must exist in the log root or in the commit root. in get_inode_size_to_log()
5505 * inode size after replaying the log when before a power failure we had in get_inode_size_to_log()
5508 * data loss when replaying a log due to previously doing a write that in get_inode_size_to_log()
5519 * At the moment we always log all xattrs. This is to figure out at log replay
5521 * in the log tree and exists in the fs/subvol tree, we delete it. This is
5523 * happens, causing the log to be replayed the next time the fs is mounted,
5603 * if any holes exist and then log them. We also need to log holes after any
5647 /* We have a hole, log it. */ in btrfs_log_holes()
5654 * leafs from the log root. in btrfs_log_holes()
5701 * log replay time we can lose inode Y (and all its files if it's a directory):
5710 * mount fs, trigger log replay
5712 * After the log replay procedure, we would lose the first directory and all its
5724 * entry (file or directory) otherwise we end up with an unreplayable log due to
5829 * Check if we need to log an inode. This is used in contexts where while
5830 * logging an inode we need to log another inode (either that it exists or in
5832 * requires the inode to be in the log and have the log transaction committed,
5833 * while here we do not care if the log transaction was already committed - our
5834 * caller will commit the log later - and we want to avoid logging an inode
5835 * multiple times when multiple tasks have joined the same log transaction.
5851 * the log by link/unlink/rename operations. in need_log_inode()
5853 * logged_trans will be 0, in which case we have to fully log it since in need_log_inode()
5869 * Log the inodes of the new dentries of a directory.
5888 * 1) For regular files we log with a mode of LOG_INODE_EXISTS. It's possible
5892 * at log replay time we compute the real number of links and correct the
5896 * 2) For directories we log with a mode of LOG_INODE_ALL. It's possible that
5900 * names - this is ok, not a problem, because at log replay time we set the
6106 * to avoid getting a directory with 2 hard links after log replay. in can_log_conflicting_inode()
6112 * and fsync again the new file. This results in a log tree where we in can_log_conflicting_inode()
6115 * that on log replay we add a new link for the new location but the in can_log_conflicting_inode()
6145 * 1) Log the parent directory (later after adding it to the list) if in add_conflicting_inode()
6150 * during log replay. So we just log the parent, which will result in in add_conflicting_inode()
6154 * 2) Do nothing if it's not a directory. During log replay we simply in add_conflicting_inode()
6172 /* Conflicting inode is a directory, so we'll log its parent. */ in add_conflicting_inode()
6206 * on reference "zz", and log it; in add_conflicting_inode()
6209 * on reference "a", and log it; in add_conflicting_inode()
6212 * on reference "zz_link", and log it - again! After this we in add_conflicting_inode()
6215 * Here we can use need_log_inode() because we only need to log the in add_conflicting_inode()
6216 * inode in LOG_INODE_EXISTS mode and rename operations update the log, in add_conflicting_inode()
6217 * so that the log ends up with the new name and without the old name. in add_conflicting_inode()
6280 * deleted in the current transaction, we need to log its parent in log_conflicting_inodes()
6301 * Always log the directory, we cannot make this in log_conflicting_inodes()
6320 * Here we can use need_log_inode() because we only need to log in log_conflicting_inodes()
6322 * update the log, so that the log ends up with the new name and in log_conflicting_inodes()
6336 * lock as long as we log with the LOG_INODE_EXISTS mode. We in log_conflicting_inodes()
6338 * well because during a rename we pin the log and update the in log_conflicting_inodes()
6339 * log with the new name before we unpin it. in log_conflicting_inodes()
6512 struct btrfs_root *log, in insert_delayed_items_batch() argument
6520 ret = btrfs_insert_empty_items(trans, log, path, batch); in insert_delayed_items_batch()
6549 struct btrfs_root *log = inode->root->log_root; in log_delayed_insertion_items() local
6563 /* We are adding dir index items to the log tree. */ in log_delayed_insertion_items()
6568 * to the log tree. However just after we collected them, they may have in log_delayed_insertion_items()
6570 * could have copied them from the subvolume tree to the log tree. in log_delayed_insertion_items()
6599 ret = insert_delayed_items_batch(trans, log, path, in log_delayed_insertion_items()
6622 ret = insert_delayed_items_batch(trans, log, path, &batch, first); in log_delayed_insertion_items()
6653 * this we log a single dir range item spanning several contiguous in log_delayed_deletions_full()
6719 struct btrfs_root *log = inode->root->log_root; in log_delayed_deletions_incremental() local
6738 ret = btrfs_search_slot(trans, log, &key, path, -1, 1); in log_delayed_deletions_incremental()
6755 * existing one. Otherwise we have to log a dir range item. in log_delayed_deletions_incremental()
6773 ret = insert_dir_log_key(trans, log, path, key.objectid, in log_delayed_deletions_incremental()
6794 * We are deleting dir index items from the log tree or adding range in log_delayed_deletion_items()
6824 * No need for the log mutex, plus to avoid potential deadlocks or in log_new_delayed_dentries()
6825 * lockdep annotations due to nesting of delayed inode mutexes and log in log_new_delayed_dentries()
6878 /* log a single inode in the tree log.
6883 * to the log tree. An extra reference is taken on any extents in this
6901 struct btrfs_root *log = inode->root->log_root; in btrfs_log_inode() local
6946 * items of this directory and not log the delayed items directly. This in btrfs_log_inode()
6955 * So in such a case we directly log the delayed items of the main in btrfs_log_inode()
6982 * For symlinks, we must always log their content, which is stored in an in btrfs_log_inode()
6984 * log replay, which is invalid on linux (symlink(2) returns -ENOENT if in btrfs_log_inode()
7006 * a file after replaying the log. For example, if we move a file from a in btrfs_log_inode()
7009 * result in losing the file after a log replay. in btrfs_log_inode()
7023 ret = drop_inode_items(trans, log, path, inode, in btrfs_log_inode()
7028 * Make sure the new inode item we write to the log has in btrfs_log_inode()
7030 * This is necessary to prevent data loss after log in btrfs_log_inode()
7034 * fsync some other file (to sync log), power fail - if in btrfs_log_inode()
7035 * we use the inode's current i_size, after log replay in btrfs_log_inode()
7049 ret = drop_inode_items(trans, log, path, in btrfs_log_inode()
7057 ret = truncate_inode_items(trans, log, in btrfs_log_inode()
7067 ret = drop_inode_items(trans, log, path, inode, in btrfs_log_inode()
7093 * subvolume tree and if we log it the file will still exist after a log in btrfs_log_inode()
7127 ret = log_inode_item(trans, log, dst_path, inode, inode_item_dropped); in btrfs_log_inode()
7132 * in this transaction, we don't need to log the xattrs because in btrfs_log_inode()
7180 * transaction, but we did not previously log the inode with in btrfs_log_inode()
7182 * it was loaded again and this LOG_INODE_EXISTS log operation in btrfs_log_inode()
7185 * updated inode item, etc, and syncs the log. The same logic in btrfs_log_inode()
7188 * 2) When we log the inode with LOG_INODE_EXISTS, its inode item in btrfs_log_inode()
7191 * truncate operation, the log is synced through an fsync of in btrfs_log_inode()
7195 * the new i_size, and syncs the log. in btrfs_log_inode()
7200 * against an ancestor, the fsync considers the inode in the log in btrfs_log_inode()
7201 * and doesn't sync the log, resulting in the ancestor missing after in btrfs_log_inode()
7202 * a power failure unless the log was synced as part of an fsync in btrfs_log_inode()
7310 * a log replay (and the old parent still existing). in btrfs_log_all_parents()
7323 * after a log replay we would have file bar linked in btrfs_log_all_parents()
7529 * parent directories also end up in the log. A minimal inode and backref
7584 * Track if we need to log dentries because ctx->log_new_dentries can in btrfs_log_inode_parent()
7594 * impossible to delete after log replay (rmdir will always fail with in btrfs_log_inode_parent()
7606 * mount fs, triggers log replay in btrfs_log_inode_parent()
7608 * If we don't log the parent directory (testdir), after log replay the in btrfs_log_inode_parent()
7623 * mount fs, triggers log replay in btrfs_log_inode_parent()
7625 * Similar as the first example, after log replay the parent directory in btrfs_log_inode_parent()
7656 * it is not safe to log dentry if the chunk root has added new
7676 * should be called during mount to recover any replay any log trees
7705 wc.log = log_root_tree; in btrfs_recover_log_trees()
7708 wc.log = NULL; in btrfs_recover_log_trees()
7739 wc.log = btrfs_read_tree_root(log_root_tree, &found_key); in btrfs_recover_log_trees()
7740 if (IS_ERR(wc.log)) { in btrfs_recover_log_trees()
7741 ret = PTR_ERR(wc.log); in btrfs_recover_log_trees()
7742 wc.log = NULL; in btrfs_recover_log_trees()
7758 * deleted. This is ok, simply skip this log and go to in btrfs_recover_log_trees()
7762 * other log replays overwriting this log as we'll read in btrfs_recover_log_trees()
7767 ret = btrfs_pin_extent_for_log_replay(trans, wc.log->node); in btrfs_recover_log_trees()
7775 wc.root->log_root = wc.log; in btrfs_recover_log_trees()
7803 * root->objectid_mutex is not acquired as log replay in btrfs_recover_log_trees()
7817 btrfs_put_root(wc.log); in btrfs_recover_log_trees()
7818 wc.log = NULL; in btrfs_recover_log_trees()
7854 btrfs_put_root(wc.log); in btrfs_recover_log_trees()
7879 * to log its parents. in btrfs_record_unlink_dir()
7883 * don't log the parents if the file is fully on disk. in btrfs_record_unlink_dir()
7894 * with btrfs_log_new_name() and old names will be deleted from the log in btrfs_record_unlink_dir()
7902 * If the inode we're about to unlink was logged before, the log will be in btrfs_record_unlink_dir()
7925 * that after replaying the log tree of the parent directory's root we will not
7926 * see the snapshot anymore and at log replay time we will not see any log tree
7928 * it after replaying the log tree of the parent directory (which would replay
7947 * create the subvolume, so make any attempt to log the directory to result in a
7948 * full log sync.
7949 * Also we don't need to worry with renames, since btrfs_rename() marks the log
7963 * Update the log after adding a new name for an inode.
7977 * rename operation, and it will properly update the log to reflect the new name.
7989 /* The inode has a new name (ref/extref), so make sure we log it. */ in btrfs_log_new_name()
8004 * from hasn't been logged, we don't need to log it in btrfs_log_new_name()
8026 * Now that we know we need to update the log, allocate the scratch eb in btrfs_log_new_name()
8027 * for the context before joining a log transaction below, as this can in btrfs_log_new_name()
8028 * take time and therefore we could delay log commits from other tasks. in btrfs_log_new_name()
8034 * was previously logged, make sure that on log replay we get the old in btrfs_log_new_name()
8035 * dir entry deleted. This is needed because we will also log the new in btrfs_log_new_name()
8036 * name of the renamed inode, so we need to make sure that after log in btrfs_log_new_name()
8040 struct btrfs_root *log = old_dir->root->log_root; in btrfs_log_new_name() local
8060 * We have two inodes to update in the log, the old directory and in btrfs_log_new_name()
8061 * the inode that got renamed, so we must pin the log to prevent in btrfs_log_new_name()
8062 * anyone from syncing the log until we have updated both inodes in btrfs_log_new_name()
8063 * in the log. in btrfs_log_new_name()
8069 * mark the log for a full commit. in btrfs_log_new_name()
8090 ret = del_logged_dentry(trans, log, path, btrfs_ino(old_dir), in btrfs_log_new_name()
8094 * The dentry does not exist in the log, so record its in btrfs_log_new_name()
8098 ret = insert_dir_log_key(trans, log, path, in btrfs_log_new_name()
8111 * We don't care about the return value. If we fail to log the new name in btrfs_log_new_name()
8112 * then we know the next attempt to sync the log will fallback to a full in btrfs_log_new_name()
8114 * we don't need to worry about getting a log committed that has an in btrfs_log_new_name()
8121 * If an error happened mark the log for a full commit because it's not in btrfs_log_new_name()
8124 * the log, to avoid any races with someone else trying to commit it. in btrfs_log_new_name()