From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: jes@trained-monkey.org
Cc: linux-raid@vger.kernel.org, colyli@suse.de
Subject: [PATCH 3/6] imsm: introduce round_member_size_to_mb()
Date: Wed, 31 May 2023 17:21:05 +0200 [thread overview]
Message-ID: <20230531152108.18103-4-mariusz.tkaczyk@linux.intel.com> (raw)
In-Reply-To: <20230531152108.18103-1-mariusz.tkaczyk@linux.intel.com>
Extract rounding logic to separate function.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
super-intel.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 3cbab545..2351ce20 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1599,17 +1599,29 @@ static int is_journal(struct imsm_disk *disk)
return (disk->status & JOURNAL_DISK) == JOURNAL_DISK;
}
-/* round array size down to closest MB and ensure it splits evenly
- * between members
+/**
+ * round_member_size_to_mb()- Round given size to closest MiB.
+ * @size: size to round in sectors.
*/
-static unsigned long long round_size_to_mb(unsigned long long size, unsigned int
- disk_count)
+static inline unsigned long long round_member_size_to_mb(unsigned long long size)
{
- size /= disk_count;
- size = (size >> SECT_PER_MB_SHIFT) << SECT_PER_MB_SHIFT;
- size *= disk_count;
+ return (size >> SECT_PER_MB_SHIFT) << SECT_PER_MB_SHIFT;
+}
- return size;
+/**
+ * round_size_to_mb()- Round given size.
+ * @array_size: size to round in sectors.
+ * @disk_count: count of data members.
+ *
+ * Get size per each data member and round it to closest MiB to ensure that data
+ * splits evenly between members.
+ *
+ * Return: Array size, rounded down.
+ */
+static inline unsigned long long round_size_to_mb(unsigned long long array_size,
+ unsigned int disk_count)
+{
+ return round_member_size_to_mb(array_size / disk_count) * disk_count;
}
static int able_to_resync(int raid_level, int missing_disks)
@@ -11749,8 +11761,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
} else {
/* round size due to metadata compatibility
*/
- geo->size = (geo->size >> SECT_PER_MB_SHIFT)
- << SECT_PER_MB_SHIFT;
+ geo->size = round_member_size_to_mb(geo->size);
dprintf("Prepare update for size change to %llu\n",
geo->size );
if (current_size >= geo->size) {
--
2.26.2
next prev parent reply other threads:[~2023-05-31 15:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 15:21 [PATCH 0/6] imsm: expand improvements Mariusz Tkaczyk
2023-05-31 15:21 ` [PATCH 1/6] imsm: move sum_extents calculations to merge_extents() Mariusz Tkaczyk
2023-05-31 15:21 ` [PATCH 2/6] imsm: imsm_get_free_size() refactor Mariusz Tkaczyk
2023-05-31 15:21 ` Mariusz Tkaczyk [this message]
2023-05-31 15:21 ` [PATCH 4/6] imsm: move expand verification code into new function Mariusz Tkaczyk
2023-05-31 15:21 ` [PATCH 5/6] imsm: return free space after volume for expand Mariusz Tkaczyk
2023-05-31 15:21 ` [PATCH 6/6] imsm: fix free space calculations Mariusz Tkaczyk
2023-05-31 15:30 ` [PATCH 0/6] imsm: expand improvements Mariusz Tkaczyk
-- strict thread matches above, loose matches on Subject: below --
2023-05-29 13:52 Mariusz Tkaczyk
2023-05-29 13:52 ` [PATCH 3/6] imsm: introduce round_member_size_to_mb() Mariusz Tkaczyk
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=20230531152108.18103-4-mariusz.tkaczyk@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=colyli@suse.de \
--cc=jes@trained-monkey.org \
--cc=linux-raid@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.