Skip to content

Commit 793ff2c

Browse files
adam900710kdave
authored andcommitted
btrfs: volumes: Cleanup stripe size calculation
Cleanup the following things: 1) open coded SZ_16M round up 2) use min() to replace open-coded size comparison 3) code style Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Gu Jinxiang <[email protected]> [ reformat comment ] Signed-off-by: David Sterba <[email protected]>
1 parent da07d4a commit 793ff2c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fs/btrfs/volumes.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4874,18 +4874,17 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
48744874
* and compare that answer with the max chunk size
48754875
*/
48764876
if (stripe_size * data_stripes > max_chunk_size) {
4877-
u64 mask = (1ULL << 24) - 1;
4878-
48794877
stripe_size = div_u64(max_chunk_size, data_stripes);
48804878

48814879
/* bump the answer up to a 16MB boundary */
4882-
stripe_size = (stripe_size + mask) & ~mask;
4880+
stripe_size = round_up(stripe_size, SZ_16M);
48834881

4884-
/* but don't go higher than the limits we found
4885-
* while searching for free extents
4882+
/*
4883+
* But don't go higher than the limits we found while searching
4884+
* for free extents
48864885
*/
4887-
if (stripe_size > devices_info[ndevs-1].max_avail)
4888-
stripe_size = devices_info[ndevs-1].max_avail;
4886+
stripe_size = min(devices_info[ndevs - 1].max_avail,
4887+
stripe_size);
48894888
}
48904889

48914890
/* align to BTRFS_STRIPE_LEN */

0 commit comments

Comments
 (0)