Skip to content

Commit 6803bff

Browse files
fdmananakdave
authored andcommitted
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>
1 parent ea77a1c commit 6803bff

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

fs/btrfs/tree-log.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,20 @@ void btrfs_end_log_trans(struct btrfs_root *root)
306306
* are state fields used for that specific part
307307
*/
308308
struct walk_control {
309-
/* should we free the extent on disk when done? This is used
310-
* at transaction commit time while freeing a log tree
309+
/*
310+
* Signal that we are freeing the metadata extents of a log tree.
311+
* This is used at transaction commit time while freeing a log tree.
311312
*/
312-
int free;
313+
bool free;
313314

314-
/* pin only walk, we record which extents on disk belong to the
315-
* log trees
315+
/*
316+
* Signal that we are pinning the metadata extents of a log tree and the
317+
* data extents its leaves point to (if using mixed block groups).
318+
* This happens in the first stage of log replay to ensure that during
319+
* replay, while we are modifying subvolume trees, we don't overwrite
320+
* the metadata extents of log trees.
316321
*/
317-
int pin;
322+
bool pin;
318323

319324
/* what stage of the replay code we're currently in */
320325
int stage;
@@ -3415,7 +3420,7 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
34153420
{
34163421
int ret;
34173422
struct walk_control wc = {
3418-
.free = 1,
3423+
.free = true,
34193424
.process_func = process_one_buffer
34203425
};
34213426

@@ -7433,7 +7438,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
74337438
}
74347439

74357440
wc.trans = trans;
7436-
wc.pin = 1;
7441+
wc.pin = true;
74377442

74387443
ret = walk_log_tree(trans, log_root_tree, &wc);
74397444
if (ret) {
@@ -7557,7 +7562,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
75577562

75587563
/* step one is to pin it all, step two is to replay just inodes */
75597564
if (wc.pin) {
7560-
wc.pin = 0;
7565+
wc.pin = false;
75617566
wc.process_func = replay_one_buffer;
75627567
wc.stage = LOG_WALK_REPLAY_INODES;
75637568
goto again;

0 commit comments

Comments
 (0)