All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 5/6] btrfs: use raid_attr for minimum stripe count in btrfs_calc_avail_data_space
Date: Tue, 18 Jun 2019 20:00:13 +0200	[thread overview]
Message-ID: <ffdc7e77015c2f5ad45de7acc2336fe2901bb605.1560880630.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1560880630.git.dsterba@suse.com>

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.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a813b582fa72..9286f9e49c0c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1902,7 +1902,7 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
 	u64 type;
 	u64 avail_space;
 	u64 min_stripe_size;
-	int min_stripes = 1, num_stripes = 1;
+	int min_stripes, num_stripes = 1;
 	int i = 0, nr_devices;
 	const struct btrfs_raid_attr *rattr;
 
@@ -1930,14 +1930,12 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
 	type = btrfs_data_alloc_profile(fs_info);
 	rattr = &btrfs_raid_array[btrfs_bg_flags_to_raid_index(type)];
 	ASSERT(rattr);
+	min_stripes = rattr->devs_min;
 	if (type & BTRFS_BLOCK_GROUP_RAID0) {
-		min_stripes = 2;
 		num_stripes = nr_devices;
 	} else if (type & BTRFS_BLOCK_GROUP_RAID1) {
-		min_stripes = 2;
 		num_stripes = 2;
 	} else if (type & BTRFS_BLOCK_GROUP_RAID10) {
-		min_stripes = 4;
 		num_stripes = 4;
 	}
 
-- 
2.21.0


  parent reply	other threads:[~2019-06-18 17:59 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 ` David Sterba [this message]
2019-06-19  7:51   ` [PATCH 5/6] btrfs: use raid_attr for minimum stripe count " Nikolay Borisov
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=ffdc7e77015c2f5ad45de7acc2336fe2901bb605.1560880630.git.dsterba@suse.com \
    --to=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 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.