]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: use booleans in walk control structure for log replay
authorFilipe Manana <fdmanana@suse.com>
Tue, 26 Aug 2025 15:12:53 +0000 (16:12 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:17 +0000 (08:49 +0200)
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>
fs/btrfs/tree-log.c

index 861f96ef28cf664a43eeff2cfaa8befe95c711cd..c5c5fc05eabb4eaf77fa76ed3c450a0d45c9d0b1 100644 (file)
@@ -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;