* [PATCH] btrfs: volumes: Cleanup stripe size calculation
@ 2018-01-31 6:16 Qu Wenruo
2018-01-31 7:36 ` Nikolay Borisov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2018-01-31 6:16 UTC (permalink / raw)
To: linux-btrfs, dsterba
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 <wqu@suse.com>
---
fs/btrfs/volumes.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index cb0a8d27661b..90ad716d2b50 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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);
--
2.16.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: volumes: Cleanup stripe size calculation
2018-01-31 6:16 [PATCH] btrfs: volumes: Cleanup stripe size calculation Qu Wenruo
@ 2018-01-31 7:36 ` Nikolay Borisov
2018-01-31 8:34 ` Gu, Jinxiang
2018-01-31 15:07 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2018-01-31 7:36 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs, dsterba
On 31.01.2018 08:16, Qu Wenruo wrote:
> 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 <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index cb0a8d27661b..90ad716d2b50 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] btrfs: volumes: Cleanup stripe size calculation
2018-01-31 6:16 [PATCH] btrfs: volumes: Cleanup stripe size calculation Qu Wenruo
2018-01-31 7:36 ` Nikolay Borisov
@ 2018-01-31 8:34 ` Gu, Jinxiang
2018-01-31 15:07 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Gu, Jinxiang @ 2018-01-31 8:34 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs@vger.kernel.org, dsterba@suse.cz
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2014 bytes --]
> -----Original Message-----
> From: linux-btrfs-owner@vger.kernel.org [mailto:linux-btrfs-owner@vger.kernel.org]
> On Behalf Of Qu Wenruo
> Sent: Wednesday, January 31, 2018 2:17 PM
> To: linux-btrfs@vger.kernel.org; dsterba@suse.cz
> Subject: [PATCH] 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 <wqu@suse.com>
> ---
> fs/btrfs/volumes.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index
> cb0a8d27661b..90ad716d2b50 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -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);
> --
Reviewed-by: Gu Jinxiang <gujx@cn.fujitsu.com>
> 2.16.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a
> message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±ý»k~ÏâØ^nr¡ö¦zË\x1aëh¨èÚ&£ûàz¿äz¹Þú+Ê+zf£¢·h§~Ûiÿÿïêÿêçz_è®\x0fæj:+v¨þ)ߣøm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: volumes: Cleanup stripe size calculation
2018-01-31 6:16 [PATCH] btrfs: volumes: Cleanup stripe size calculation Qu Wenruo
2018-01-31 7:36 ` Nikolay Borisov
2018-01-31 8:34 ` Gu, Jinxiang
@ 2018-01-31 15:07 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-01-31 15:07 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs, dsterba
On Wed, Jan 31, 2018 at 02:16:34PM +0800, Qu Wenruo wrote:
> 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 <wqu@suse.com>
Added to next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-31 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-31 6:16 [PATCH] btrfs: volumes: Cleanup stripe size calculation Qu Wenruo
2018-01-31 7:36 ` Nikolay Borisov
2018-01-31 8:34 ` Gu, Jinxiang
2018-01-31 15:07 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).