aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2025-08-26 16:12:53 +0100
committerDavid Sterba <dsterba@suse.com>2025-09-23 08:49:17 +0200
commit6803bff896ef96c9b2ee436d9e4f17ba7357d601 (patch)
tree6f573429a8832fc0053badcaca065dca5f6c2d52 /fs/btrfs/tree-log.c
parentbtrfs: cache max and min order inside btrfs_fs_info (diff)
downloadwireguard-linux-6803bff896ef96c9b2ee436d9e4f17ba7357d601.tar.xz
wireguard-linux-6803bff896ef96c9b2ee436d9e4f17ba7357d601.zip
btrfs: use booleans in walk control structure for log replay
The 'free' and 'pin' member of struct walk_control, used during log replay and when freeing a log tree, are defined as integers but in practice are used as booleans. Change their type to bool and while at it update their comments to be more detailed and comply with the preferred comment style (first word in a sentence is capitalized, sentences end with punctuation and the comment opening (/*) is on a line of its own). Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 861f96ef28cf..c5c5fc05eabb 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -306,15 +306,20 @@ void btrfs_end_log_trans(struct btrfs_root *root)
* are state fields used for that specific part
*/
struct walk_control {
- /* should we free the extent on disk when done? This is used
- * at transaction commit time while freeing a log tree
+ /*
+ * Signal that we are freeing the metadata extents of a log tree.
+ * This is used at transaction commit time while freeing a log tree.
*/
- int free;
+ bool free;
- /* pin only walk, we record which extents on disk belong to the
- * log trees
+ /*
+ * Signal that we are pinning the metadata extents of a log tree and the
+ * data extents its leaves point to (if using mixed block groups).
+ * This happens in the first stage of log replay to ensure that during
+ * replay, while we are modifying subvolume trees, we don't overwrite
+ * the metadata extents of log trees.
*/
- int pin;
+ bool pin;
/* what stage of the replay code we're currently in */
int stage;
@@ -3415,7 +3420,7 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
{
int ret;
struct walk_control wc = {
- .free = 1,
+ .free = true,
.process_func = process_one_buffer
};
@@ -7433,7 +7438,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
}
wc.trans = trans;
- wc.pin = 1;
+ wc.pin = true;
ret = walk_log_tree(trans, log_root_tree, &wc);
if (ret) {
@@ -7557,7 +7562,7 @@ next:
/* step one is to pin it all, step two is to replay just inodes */
if (wc.pin) {
- wc.pin = 0;
+ wc.pin = false;
wc.process_func = replay_one_buffer;
wc.stage = LOG_WALK_REPLAY_INODES;
goto again;