btrfs: volumes: Cleanup stripe size calculation
PATCH 1/1 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
--- fs/btrfs/volumes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/btrfs/volumes.c +5 -6
@@ -4761,18 +4761,17 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,* and compare that answer with the max chunk size */ if (stripe_size * data_stripes > max_chunk_size) { -u64 mask = (1ULL <<24 ) -1 ; - stripe_size =div_u64 (max_chunk_size, data_stripes);/* bump the answer up to a 16MB boundary */ - stripe_size = (stripe_size + mask) & ~mask; + stripe_size =round_up (stripe_size,SZ_16M ); -/* but don't go higher than the limits we found +/* +* but don't go higher than the limits we found * while searching for free extents */ -if (stripe_size > devices_info[ndevs-1 ].max_avail) - stripe_size = devices_info[ndevs-1 ].max_avail; + stripe_size =min (devices_info[ndevs -1 ].max_avail, + stripe_size); } stripe_size =div_u64 (stripe_size, dev_stripes);
Signature · 1 line
2.16.1
Quoted 6 lines · Qu Wenruo
Cleanup the following things:
1) open codedSZ_16Mround up
2) usemin()to replace open-coded size comparison
3) code styleSigned-off-by Qu Wenruo <[email protected]>
Quoted 33 lines
--- fs/btrfs/volumes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)fs/btrfs/volumes.c +5
-6@@ -4761,18 +4761,17 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,* and compare that answer with the max chunk size */ if (stripe_size * data_stripes > max_chunk_size) { -u64 mask = (1ULL <<24 ) -1 ; - stripe_size =div_u64 (max_chunk_size, data_stripes);/* bump the answer up to a 16MB boundary */ - stripe_size = (stripe_size + mask) & ~mask; + stripe_size =round_up (stripe_size,SZ_16M ); -/* but don't go higher than the limits we found +/* +* but don't go higher than the limits we found * while searching for free extents */ -if (stripe_size > devices_info[ndevs-1 ].max_avail) - stripe_size = devices_info[ndevs-1 ].max_avail; + stripe_size =min (devices_info[ndevs -1 ].max_avail, + stripe_size); } stripe_size =div_u64 (stripe_size, dev_stripes);
Quoted 47 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Qu Wenruo
Sent: Wednesday, January 31, 2018 2:17 PM
To: [email protected]; [email protected]
Subject: [PATCH] btrfs: volumes: Cleanup stripe size calculationCleanup the following things:
1) open codedSZ_16Mround up
2) usemin()to replace open-coded size comparison
3) code styleSigned-off-by Qu Wenruo <[email protected]>--- fs/btrfs/volumes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)fs/btrfs/volumes.c index renamed from fs/btrfs/volumes.c +0
-0
cb0a8d27661b..90ad716d2b50100644fs/btrfs/volumes.c +5
-6@@ -4761,18 +4761,17 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle*trans, * and compare that answer with the max chunk size */ if (stripe_size * data_stripes > max_chunk_size) { -u64 mask = (1ULL <<24 ) -1 ; - stripe_size =div_u64 (max_chunk_size, data_stripes);/* bump the answer up to a 16MB boundary */ - stripe_size = (stripe_size + mask) & ~mask; + stripe_size =round_up (stripe_size,SZ_16M ); -/* but don't go higher than the limits we found +/* +* but don't go higher than the limits we found * while searching for free extents */ -if (stripe_size > devices_info[ndevs-1 ].max_avail) - stripe_size = devices_info[ndevs-1 ].max_avail; + stripe_size =min (devices_info[ndevs -1 ].max_avail, + stripe_size); }
Quoted 2 lines
stripe_size=div_u64(stripe_size, dev_stripes);
--
Quoted 7 lines
2.16.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
�翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{饼籯~镶炟^n噐■�侂h櫒璀�&{鄗夸z罐楘+€�+zf"穐殘啳嗃i��飦�戧鐉_璁鎗:+v墾�)撸鴐
Quoted 6 lines · Qu Wenruo
Cleanup the following things:
1) open codedSZ_16Mround up
2) usemin()to replace open-coded size comparison
3) code styleSigned-off-by Qu Wenruo <[email protected]>
Added to next, thanks.