Skip to content

Commit 79bdd88

Browse files
kdavemorbidrsa
authored andcommitted
btrfs: switch local indicator variables to bools
For all local indicator variables do simple switch to bool, done on all files. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 18a8071 commit 79bdd88

18 files changed

Lines changed: 104 additions & 104 deletions

fs/btrfs/block-group.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,7 @@ static int check_chunk_block_group_mappings(struct btrfs_fs_info *fs_info)
24822482
static int read_one_block_group(struct btrfs_fs_info *info,
24832483
struct btrfs_block_group_item_v2 *bgi,
24842484
const struct btrfs_key *key,
2485-
int need_clear)
2485+
bool need_clear)
24862486
{
24872487
struct btrfs_block_group *cache;
24882488
const bool mixed = btrfs_fs_incompat(info, MIXED_GROUPS);
@@ -2663,7 +2663,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
26632663
struct btrfs_block_group *cache;
26642664
struct btrfs_space_info *space_info;
26652665
struct btrfs_key key;
2666-
int need_clear = 0;
2666+
bool need_clear = false;
26672667
u64 cache_gen;
26682668

26692669
/*
@@ -2688,9 +2688,9 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
26882688
cache_gen = btrfs_super_cache_generation(info->super_copy);
26892689
if (btrfs_test_opt(info, SPACE_CACHE) &&
26902690
btrfs_super_generation(info->super_copy) != cache_gen)
2691-
need_clear = 1;
2691+
need_clear = true;
26922692
if (btrfs_test_opt(info, CLEAR_CACHE))
2693-
need_clear = 1;
2693+
need_clear = true;
26942694

26952695
while (1) {
26962696
struct btrfs_block_group_item_v2 bgi;

fs/btrfs/ctree.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,10 @@ int btrfs_force_cow_block(struct btrfs_trans_handle *trans,
475475
struct extent_buffer *cow;
476476
int level, ret;
477477
int last_ref = 0;
478-
int unlock_orig = 0;
478+
const bool unlock_orig = (*cow_ret == buf);
479479
u64 parent_start = 0;
480480
u64 reloc_src_root = 0;
481481

482-
if (*cow_ret == buf)
483-
unlock_orig = 1;
484-
485482
btrfs_assert_tree_write_locked(buf);
486483

487484
WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
@@ -2069,7 +2066,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
20692066
}
20702067

20712068
while (b) {
2072-
int dec = 0;
2069+
bool dec = false;
20732070
int ret2;
20742071

20752072
level = btrfs_header_level(b);
@@ -2152,7 +2149,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
21522149
prev_cmp = ret;
21532150

21542151
if (ret && slot > 0) {
2155-
dec = 1;
2152+
dec = true;
21562153
slot--;
21572154
}
21582155
p->slots[level] = slot;
@@ -2282,7 +2279,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
22822279
p->locks[level] = BTRFS_READ_LOCK;
22832280

22842281
while (b) {
2285-
int dec = 0;
2282+
bool dec = false;
22862283
int ret2;
22872284

22882285
level = btrfs_header_level(b);
@@ -2307,7 +2304,7 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
23072304
}
23082305

23092306
if (ret && slot > 0) {
2310-
dec = 1;
2307+
dec = true;
23112308
slot--;
23122309
}
23132310
p->slots[level] = slot;
@@ -3668,7 +3665,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
36683665
int wret;
36693666
int split;
36703667
int num_doubles = 0;
3671-
int tried_avoid_double = 0;
3668+
bool tried_avoid_double = false;
36723669

36733670
l = path->nodes[0];
36743671
slot = path->slots[0];
@@ -3830,7 +3827,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
38303827

38313828
push_for_double:
38323829
push_for_double_split(trans, root, path, data_size);
3833-
tried_avoid_double = 1;
3830+
tried_avoid_double = true;
38343831
if (btrfs_leaf_free_space(path->nodes[0]) >= data_size)
38353832
return 0;
38363833
goto again;

fs/btrfs/disk-io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *eb,
215215
const struct btrfs_tree_parent_check *check)
216216
{
217217
struct btrfs_fs_info *fs_info = eb->fs_info;
218-
int failed = 0;
218+
bool failed = false;
219219
int ret;
220220
int num_copies = 0;
221221
int mirror_num = 0;
@@ -234,7 +234,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *eb,
234234
break;
235235

236236
if (!failed_mirror) {
237-
failed = 1;
237+
failed = true;
238238
failed_mirror = eb->read_mirror;
239239
}
240240

fs/btrfs/extent-io-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ u64 btrfs_count_range_bits(struct extent_io_tree *tree,
17631763
u64 cur_start = *start;
17641764
u64 total_bytes = 0;
17651765
u64 last = 0;
1766-
int found = 0;
1766+
bool found = false;
17671767

17681768
if (WARN_ON(search_end < cur_start))
17691769
return 0;
@@ -1817,7 +1817,7 @@ u64 btrfs_count_range_bits(struct extent_io_tree *tree,
18171817
break;
18181818
if (!found) {
18191819
*start = max(cur_start, state->start);
1820-
found = 1;
1820+
found = true;
18211821
}
18221822
last = state->end;
18231823
} else if (contig && found) {

fs/btrfs/extent-tree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,13 +1699,13 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16991699
struct extent_buffer *leaf;
17001700
u32 item_size;
17011701
int ret;
1702-
int metadata = 1;
1702+
bool metadata = true;
17031703

17041704
if (TRANS_ABORTED(trans))
17051705
return 0;
17061706

17071707
if (!btrfs_fs_incompat(fs_info, SKINNY_METADATA))
1708-
metadata = 0;
1708+
metadata = false;
17091709

17101710
path = btrfs_alloc_path();
17111711
if (!path)
@@ -1745,7 +1745,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
17451745
}
17461746
if (ret > 0) {
17471747
btrfs_release_path(path);
1748-
metadata = 0;
1748+
metadata = false;
17491749

17501750
key.objectid = head->bytenr;
17511751
key.type = BTRFS_EXTENT_ITEM_KEY;
@@ -3283,7 +3283,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
32833283
int ret;
32843284
int is_data;
32853285
int extent_slot = 0;
3286-
int found_extent = 0;
3286+
bool found_extent = false;
32873287
int num_to_del = 1;
32883288
int refs_to_drop = node->ref_mod;
32893289
u32 item_size;
@@ -3339,12 +3339,12 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
33393339
break;
33403340
if (key.type == BTRFS_EXTENT_ITEM_KEY &&
33413341
key.offset == num_bytes) {
3342-
found_extent = 1;
3342+
found_extent = true;
33433343
break;
33443344
}
33453345
if (key.type == BTRFS_METADATA_ITEM_KEY &&
33463346
key.offset == owner_objectid) {
3347-
found_extent = 1;
3347+
found_extent = true;
33483348
break;
33493349
}
33503350

fs/btrfs/extent_io.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
380380
bool found;
381381
struct extent_state *cached_state = NULL;
382382
int ret;
383-
int loops = 0;
383+
bool loops = false;
384384

385385
/* Caller should pass a valid @end to indicate the search range end */
386386
ASSERT(orig_end > orig_start);
@@ -437,7 +437,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
437437
cached_state = NULL;
438438
if (!loops) {
439439
max_bytes = fs_info->sectorsize;
440-
loops = 1;
440+
loops = true;
441441
goto again;
442442
} else {
443443
return false;
@@ -2359,13 +2359,13 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wb
23592359
struct btrfs_eb_write_context ctx = { .wbc = wbc };
23602360
struct btrfs_fs_info *fs_info = inode_to_fs_info(mapping->host);
23612361
int ret = 0;
2362-
int done = 0;
2362+
bool done = false;
23632363
int nr_to_write_done = 0;
23642364
struct eb_batch batch;
23652365
unsigned int nr_ebs;
23662366
unsigned long index;
23672367
unsigned long end;
2368-
int scanned = 0;
2368+
bool scanned = false;
23692369
xa_mark_t tag;
23702370

23712371
eb_batch_init(&batch);
@@ -2382,7 +2382,7 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wb
23822382
index = (wbc->range_start >> fs_info->nodesize_bits);
23832383
end = (wbc->range_end >> fs_info->nodesize_bits);
23842384

2385-
scanned = 1;
2385+
scanned = true;
23862386
}
23872387
if (wbc->sync_mode == WB_SYNC_ALL)
23882388
tag = PAGECACHE_TAG_TOWRITE;
@@ -2405,7 +2405,7 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wb
24052405
ret = 0;
24062406

24072407
if (ret) {
2408-
done = 1;
2408+
done = true;
24092409
break;
24102410
}
24112411
continue;
@@ -2431,7 +2431,7 @@ int btree_writepages(struct address_space *mapping, struct writeback_control *wb
24312431
* We hit the last page and there is more work to be done: wrap
24322432
* back to the start of the file
24332433
*/
2434-
scanned = 1;
2434+
scanned = true;
24352435
index = 0;
24362436
goto retry;
24372437
}
@@ -2471,15 +2471,15 @@ static int extent_write_cache_pages(struct address_space *mapping,
24712471
struct writeback_control *wbc = bio_ctrl->wbc;
24722472
struct inode *inode = mapping->host;
24732473
int ret = 0;
2474-
int done = 0;
2474+
bool done = false;
24752475
int nr_to_write_done = 0;
24762476
struct folio_batch fbatch;
24772477
unsigned int nr_folios;
24782478
pgoff_t index;
24792479
pgoff_t end; /* Inclusive */
24802480
pgoff_t done_index;
2481-
int range_whole = 0;
2482-
int scanned = 0;
2481+
bool range_whole = false;
2482+
bool scanned = false;
24832483
xa_mark_t tag;
24842484

24852485
/*
@@ -2507,8 +2507,8 @@ static int extent_write_cache_pages(struct address_space *mapping,
25072507
index = wbc->range_start >> PAGE_SHIFT;
25082508
end = wbc->range_end >> PAGE_SHIFT;
25092509
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
2510-
range_whole = 1;
2511-
scanned = 1;
2510+
range_whole = true;
2511+
scanned = true;
25122512
}
25132513

25142514
/*
@@ -2592,7 +2592,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
25922592

25932593
ret = extent_writepage(folio, bio_ctrl);
25942594
if (ret < 0) {
2595-
done = 1;
2595+
done = true;
25962596
break;
25972597
}
25982598

@@ -2612,7 +2612,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
26122612
* We hit the last page and there is more work to be done: wrap
26132613
* back to the start of the file
26142614
*/
2615-
scanned = 1;
2615+
scanned = true;
26162616
index = 0;
26172617

26182618
/*
@@ -3444,7 +3444,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
34443444
struct btrfs_folio_state *prealloc = NULL;
34453445
u64 lockdep_owner = owner_root;
34463446
bool page_contig = true;
3447-
int uptodate = 1;
3447+
bool uptodate = true;
34483448
int ret;
34493449

34503450
if (check_eb_alignment(fs_info, start))
@@ -3558,7 +3558,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
35583558
page_contig = false;
35593559

35603560
if (!btrfs_meta_folio_test_uptodate(folio, eb))
3561-
uptodate = 0;
3561+
uptodate = false;
35623562

35633563
/*
35643564
* We can't unlock the pages just yet since the extent buffer

fs/btrfs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
141141
int ret;
142142
int modify_tree = -1;
143143
int update_refs;
144-
int found = 0;
144+
bool found = false;
145145
struct btrfs_path *path = args->path;
146146

147147
args->bytes_found = 0;
@@ -249,7 +249,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
249249
goto next_slot;
250250
}
251251

252-
found = 1;
252+
found = true;
253253
search_start = max(key.offset, args->start);
254254
if (recow || !modify_tree) {
255255
modify_tree = -1;

fs/btrfs/free-space-cache.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
13731373
int entries = 0;
13741374
int bitmaps = 0;
13751375
int ret;
1376-
int must_iput = 0;
1376+
bool must_iput = false;
13771377
int i_size;
13781378

13791379
if (!i_size_read(inode))
@@ -1393,7 +1393,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
13931393
up_write(&block_group->data_rwsem);
13941394
BTRFS_I(inode)->generation = 0;
13951395
ret = 0;
1396-
must_iput = 1;
1396+
must_iput = true;
13971397
goto out;
13981398
}
13991399
spin_unlock(&block_group->lock);
@@ -2306,7 +2306,7 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
23062306
{
23072307
struct btrfs_free_space *bitmap_info;
23082308
struct btrfs_block_group *block_group = ctl->block_group;
2309-
int added = 0;
2309+
bool added = false;
23102310
u64 bytes, offset, bytes_added;
23112311
enum btrfs_trim_state trim_state;
23122312
int ret;
@@ -2365,15 +2365,15 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
23652365
bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
23662366
1, 0);
23672367
if (!bitmap_info) {
2368-
ASSERT(added == 0);
2368+
ASSERT(!added);
23692369
goto new_bitmap;
23702370
}
23712371

23722372
bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes,
23732373
trim_state);
23742374
bytes -= bytes_added;
23752375
offset += bytes_added;
2376-
added = 0;
2376+
added = false;
23772377

23782378
if (!bytes) {
23792379
ret = 1;
@@ -2384,7 +2384,7 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
23842384
new_bitmap:
23852385
if (info && info->bitmap) {
23862386
add_new_bitmap(ctl, info, offset);
2387-
added = 1;
2387+
added = true;
23882388
info = NULL;
23892389
goto again;
23902390
} else {

0 commit comments

Comments
 (0)