* [PATCH] Btrfs: fix max chunk size check in chunk allocator
@ 2012-04-13 14:05 Ilya Dryomov
2012-04-13 14:09 ` Arne Jansen
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Dryomov @ 2012-04-13 14:05 UTC (permalink / raw)
To: linux-btrfs; +Cc: Chris Mason, idryomov, Arne Jansen
Fix a bug, where in case we need to adjust stripe_size so that the
length of the resulting chunk is less than or equal to max_chunk_size,
DUP chunks turn out to be only half as big as they could be.
Cc: Arne Jansen <sensille@gmx.net>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
fs/btrfs/volumes.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index a872b48..c462d84 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3324,12 +3324,14 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
stripe_size = devices_info[ndevs-1].max_avail;
num_stripes = ndevs * dev_stripes;
- if (stripe_size * num_stripes > max_chunk_size * ncopies) {
+ if (stripe_size * ndevs > max_chunk_size * ncopies) {
stripe_size = max_chunk_size * ncopies;
- do_div(stripe_size, num_stripes);
+ do_div(stripe_size, ndevs);
}
do_div(stripe_size, dev_stripes);
+
+ /* align to BTRFS_STRIPE_LEN */
do_div(stripe_size, BTRFS_STRIPE_LEN);
stripe_size *= BTRFS_STRIPE_LEN;
--
1.7.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: fix max chunk size check in chunk allocator
2012-04-13 14:05 [PATCH] Btrfs: fix max chunk size check in chunk allocator Ilya Dryomov
@ 2012-04-13 14:09 ` Arne Jansen
0 siblings, 0 replies; 2+ messages in thread
From: Arne Jansen @ 2012-04-13 14:09 UTC (permalink / raw)
To: Ilya Dryomov; +Cc: linux-btrfs, Chris Mason
On 13.04.2012 16:05, Ilya Dryomov wrote:
> Fix a bug, where in case we need to adjust stripe_size so that the
> length of the resulting chunk is less than or equal to max_chunk_size,
> DUP chunks turn out to be only half as big as they could be.
>
> Cc: Arne Jansen <sensille@gmx.net>
> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> ---
> fs/btrfs/volumes.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index a872b48..c462d84 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -3324,12 +3324,14 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
> stripe_size = devices_info[ndevs-1].max_avail;
> num_stripes = ndevs * dev_stripes;
>
> - if (stripe_size * num_stripes > max_chunk_size * ncopies) {
> + if (stripe_size * ndevs > max_chunk_size * ncopies) {
> stripe_size = max_chunk_size * ncopies;
> - do_div(stripe_size, num_stripes);
> + do_div(stripe_size, ndevs);
> }
>
> do_div(stripe_size, dev_stripes);
> +
> + /* align to BTRFS_STRIPE_LEN */
> do_div(stripe_size, BTRFS_STRIPE_LEN);
> stripe_size *= BTRFS_STRIPE_LEN;
>
Reviewed-by: Arne Jansen <sensille@gmx.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-13 14:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-13 14:05 [PATCH] Btrfs: fix max chunk size check in chunk allocator Ilya Dryomov
2012-04-13 14:09 ` Arne Jansen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.