Skip to content

Commit a7a63ac

Browse files
josefbacikkdave
authored andcommitted
btrfs: fix force usage in inc_block_group_ro
For some reason we've translated the do_chunk_alloc that goes into btrfs_inc_block_group_ro to force in inc_block_group_ro, but these are two different things. force for inc_block_group_ro is used when we are forcing the block group read only no matter what, for example when the underlying chunk is marked read only. We need to not do the space check here as this block group needs to be read only. btrfs_inc_block_group_ro() has a do_chunk_alloc flag that indicates that we need to pre-allocate a chunk before marking the block group read only. This has nothing to do with forcing, and in fact we _always_ want to do the space check in this case, so unconditionally pass false for force in this case. Then fixup inc_block_group_ro to honor force as it's expected and documented to do. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 5750c37 commit a7a63ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/block-group.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ static int inc_block_group_ro(struct btrfs_block_group *cache, int force)
12131213
* Here we make sure if we mark this bg RO, we still have enough
12141214
* free space as buffer.
12151215
*/
1216-
if (sinfo_used + num_bytes <= sinfo->total_bytes) {
1216+
if (force || (sinfo_used + num_bytes <= sinfo->total_bytes)) {
12171217
sinfo->bytes_readonly += num_bytes;
12181218
cache->ro++;
12191219
list_add_tail(&cache->ro_list, &sinfo->ro_bgs);
@@ -2225,7 +2225,7 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,
22252225
}
22262226
}
22272227

2228-
ret = inc_block_group_ro(cache, !do_chunk_alloc);
2228+
ret = inc_block_group_ro(cache, 0);
22292229
if (!do_chunk_alloc)
22302230
goto unlock_out;
22312231
if (!ret)

0 commit comments

Comments
 (0)