From: Nikolay Borisov <nborisov@suse.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/6] btrfs: use raid_attr for minimum stripe count in btrfs_calc_avail_data_space
Date: Wed, 19 Jun 2019 10:51:14 +0300 [thread overview]
Message-ID: <7adb54d3-38c9-738b-caf0-c6926ab19dbb@suse.com> (raw)
In-Reply-To: <ffdc7e77015c2f5ad45de7acc2336fe2901bb605.1560880630.git.dsterba@suse.com>
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
On 18.06.19 г. 21:00 ч., David Sterba wrote:
> Minimum stripe count matches the minimum devices required for a given
> profile. The open coded assignments match the raid_attr table.
>
> What's changed here is the meaning for RAID5/6. Previously their
> min_stripes would be 1, while newly it's devs_min. This however shold be
> the same as before because it's not possible to create filesystem on
> fewer devices than the raid_attr table allows.
>
> There's no adjustment regarding the parity stripes (like
> calc_data_stripes does), because we're interested in overall space that
> would fit on the devices.
>
> Missing devices make no difference for the whole calculation, we have
> the size stored in the structures.
I think the clean up in this function should include more here's list of
things which I think will make it more readable. Something like the
attached diff on top of your patch:
[-- Attachment #2: calc-avail-space.diff --]
[-- Type: text/x-patch, Size: 1987 bytes --]
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6e196b8a0820..230aef8314da 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1898,11 +1898,10 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
struct btrfs_device_info *devices_info;
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
struct btrfs_device *device;
- u64 skip_space;
u64 type;
u64 avail_space;
u64 min_stripe_size;
- int min_stripes = 1, num_stripes = 1;
+ int num_stripes = 1;
int i = 0, nr_devices;
/*
@@ -1957,28 +1956,21 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
avail_space = device->total_bytes - device->bytes_used;
/* align with stripe_len */
- avail_space = div_u64(avail_space, BTRFS_STRIPE_LEN);
- avail_space *= BTRFS_STRIPE_LEN;
+ avail_space = rounddown(avail_space, BTRFS_STRIPE_LEN);
/*
* In order to avoid overwriting the superblock on the drive,
* btrfs starts at an offset of at least 1MB when doing chunk
* allocation.
+ *
+ * This ensures we have at least min_stripe_size free space
+ * after excluding 1mb.
*/
- skip_space = SZ_1M;
-
- /*
- * we can use the free space in [0, skip_space - 1], subtract
- * it from the total.
- */
- if (avail_space && avail_space >= skip_space)
- avail_space -= skip_space;
- else
- avail_space = 0;
-
- if (avail_space < min_stripe_size)
+ if (avail_space <= SZ_1M + min_stripe_size)
continue;
+ avail_space -= SZ_1M;
+
devices_info[i].dev = device;
devices_info[i].max_avail = avail_space;
@@ -1992,9 +1984,8 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
i = nr_devices - 1;
avail_space = 0;
- while (nr_devices >= min_stripes) {
- if (num_stripes > nr_devices)
- num_stripes = nr_devices;
+ while (nr_devices >= rattr->devs_min) {
+ num_stripes = min(num_stripes, nr_devices);
if (devices_info[i].max_avail >= min_stripe_size) {
int j;
next prev parent reply other threads:[~2019-06-19 7:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 18:00 [PATCH 0/6] Minor cleanups David Sterba
2019-06-18 18:00 ` [PATCH 1/6] btrfs: use common helpers for eb leak messages David Sterba
2019-06-18 18:00 ` [PATCH 2/6] btrfs: use common helpers for extent IO state insertion messages David Sterba
2019-06-19 6:54 ` Nikolay Borisov
2019-06-19 11:50 ` David Sterba
2019-06-18 18:00 ` [PATCH 3/6] btrfs: drop default value assignments in enums David Sterba
2019-06-18 18:00 ` [PATCH 4/6] btrfs: use raid_attr to adjust minimal stripe size in btrfs_calc_avail_data_space David Sterba
2019-06-19 6:57 ` Nikolay Borisov
2019-06-18 18:00 ` [PATCH 5/6] btrfs: use raid_attr for minimum stripe count " David Sterba
2019-06-19 7:51 ` Nikolay Borisov [this message]
2019-06-19 12:09 ` David Sterba
2019-06-18 18:00 ` [PATCH 6/6] btrfs: lift bio_set_dev from bio allocation helpers David Sterba
2019-06-19 7:02 ` Nikolay Borisov
2019-06-19 12:03 ` David Sterba
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=7adb54d3-38c9-738b-caf0-c6926ab19dbb@suse.com \
--to=nborisov@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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).