From: "Thomas Schmidt" <Schmidt-T@gmx.de>
To: Arne Jansen <sensille@gmx.net>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [RFC] improve space utilization on off-sized raid devices
Date: Tue, 24 Jan 2012 22:01:31 +0100 [thread overview]
Message-ID: <20120124210131.213130@gmx.net> (raw)
In-Reply-To: <4ED740FF.1010304@gmx.net>
On Thursday 01 December 2011 09:55:27 Arne Jansen wrote:
> As RAID0 is already not a strict 'all disks or none', I like the idea=
to
> have it even more dynamic to reach full optimization. But I'd like to=
see
> some properties conserved:
> a) In case of even size disks, the stripes should always be full siz=
e, not
> n - 1
> b) Minor variations in the used space per disk due to metadata chunk=
s
> should not lead to deviation from a)
> c) The algorithms should not give weird results under unconventional
> setups. Some theoretical background would be nice=20
Resent because it did not appear on the ML for about 4h.
KMail's acting up.
Sorry to only get back to you now, I must have missed your mail somehow=
=2E
The problem is the shrinking stripe width with unmatched devices. Once =
it hits devs_min-1 it's over. My solution is to try to keep the stripe =
width constant.
The sorting then takes care of selecting the right devices.
It's simply: space / min-hight =3D max-width
a) is dictated by math
Since circumstances change (add, rm devs, rounding, ...) it is calculat=
ed again at every allocation. The result is then rounded to the nearest=
multiple of devs_increment. This takes care of b).
The code may look wiered but should be identical to the mathematical
floor(Space / min-hight + increment/2) if considered together with the =
round down already present in the line after my patch.
The two ifs should safeguard against weird stuff by limiting the result=
to sane values.
I include an updated patch below. It's again written for and tested wit=
h 3.0.0 but diff3 worked nicely for applying it to 3.3-rc1.
--- volumes.c.orig 2012-01-20 16:59:31.000000000 +0100
+++ volumes.c 2012-01-24 11:24:07.261401805 +0100
@@ -2329,6 +2329,8 @@
u64 stripe_size;
u64 num_bytes;
int ndevs;
+ u64 fs_total_avail;
+ int opt_ndevs;
int i;
int j;
=20
@@ -2448,6 +2450,7 @@
devices_info[ndevs].total_avail =3D total_avail;
devices_info[ndevs].dev =3D device;
++ndevs;
+ fs_total_avail +=3D total_avail;
}
=20
/*
@@ -2456,6 +2459,16 @@
sort(devices_info, ndevs, sizeof(struct btrfs_device_info),
btrfs_cmp_device_info, NULL);
=20
+ /*
+ * do not allocate space on all devices
+ * instead balance free space to maximise space utilization
+ */
+ opt_ndevs =3D (fs_total_avail*2 + devs_increment*devices_info[0=
].total_avail) / (devices_info[0].total_avail*2);
+ if (opt_ndevs < devs_min)
+ opt_ndevs =3D devs_min;
+ if (ndevs > opt_ndevs)
+ ndevs =3D opt_ndevs;
+
/* round down to number of usable stripes */
ndevs -=3D ndevs % devs_increment;
--=20
Ihr GMX Postfach immer dabei: die kostenlose GMX Mail App f=C3=BCr Andr=
oid.
Komfortabel, sicher und schnell: www.gmx.de/android
--
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
next prev parent reply other threads:[~2012-01-24 21:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-17 0:27 [RFC] improve space utilization on off-sized raid devices Thomas Schmidt
2011-11-17 7:42 ` Arne Jansen
2011-11-17 11:53 ` Thomas Schmidt
2011-11-17 12:59 ` Arne Jansen
2011-11-17 14:06 ` Thomas Schmidt
2011-12-01 8:55 ` Arne Jansen
2012-01-24 17:15 ` THomas Schmidt
2012-01-24 21:01 ` Thomas Schmidt [this message]
2011-11-17 18:27 ` Phillip Susi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120124210131.213130@gmx.net \
--to=schmidt-t@gmx.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=sensille@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).