From: Jes.Sorensen@redhat.com
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org
Subject: [PATCH 02/11] Define and use SUPER1_SIZE for allocations
Date: Tue, 20 Mar 2012 17:54:07 +0100 [thread overview]
Message-ID: <1332262456-5109-3-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1332262456-5109-1-git-send-email-Jes.Sorensen@redhat.com>
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Use a #define rather than calculate the size of the superblock buffer
on every allocation.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
super1.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/super1.c b/super1.c
index 4e3bf7b..4c75f21 100644
--- a/super1.c
+++ b/super1.c
@@ -102,6 +102,8 @@ struct misc_dev_info {
#define MD_FEATURE_ALL (1|2|4)
+#define SUPER1_SIZE (1024 + 512 + sizeof(struct misc_dev_info))
+
#ifndef offsetof
#define offsetof(t,f) ((size_t)&(((t*)0)->f))
#endif
@@ -835,8 +837,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
int rfd;
char defname[10];
- if (posix_memalign((void**)&sb, 512, (1024 + 512 +
- sizeof(struct misc_dev_info))) != 0) {
+ if (posix_memalign((void**)&sb, 512, SUPER1_SIZE) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
return 0;
@@ -1221,15 +1222,12 @@ static int compare_super1(struct supertype *st, struct supertype *tst)
return 1;
if (!first) {
- if (posix_memalign((void**)&first, 512,
- 1024 + 512 +
- sizeof(struct misc_dev_info)) != 0) {
+ if (posix_memalign((void**)&first, 512, SUPER1_SIZE) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
return 1;
}
- memcpy(first, second, 1024 + 512 +
- sizeof(struct misc_dev_info));
+ memcpy(first, second, SUPER1_SIZE);
st->sb = first;
return 0;
}
@@ -1336,9 +1334,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
return 1;
}
- if (posix_memalign((void**)&super, 512,
- 1024 + 512 +
- sizeof(struct misc_dev_info)) != 0) {
+ if (posix_memalign((void**)&super, 512, SUPER1_SIZE) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n",
__func__);
return 1;
--
1.7.7.6
next prev parent reply other threads:[~2012-03-20 16:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 16:54 [PATCH 00/11] Various cleanups and minor fixes Jes.Sorensen
2012-03-20 16:54 ` [PATCH 01/11] super1.c don't keep recalculating bitmap pointer Jes.Sorensen
2012-03-20 16:54 ` Jes.Sorensen [this message]
2012-03-20 16:54 ` [PATCH 03/11] init_super1() memset full buffer allocated for superblock Jes.Sorensen
2012-03-20 16:54 ` [PATCH 04/11] match_metadata_desc1(): Use calloc instead of malloc+memset Jes.Sorensen
2012-03-20 16:54 ` [PATCH 05/11] Use 4K buffer alignment for superblock allocations Jes.Sorensen
2012-03-20 16:54 ` [PATCH 06/11] Use struct align_fd to cache fd's block size for aligned reads/writes Jes.Sorensen
2012-03-20 16:54 ` [PATCH 07/11] match_metadata_desc0(): Use calloc instead of malloc+memset Jes.Sorensen
2012-03-20 16:54 ` [PATCH 08/11] Generalize ROUND_UP() macro and introduce matching ROUND_UP_PTR() Jes.Sorensen
2012-03-20 16:54 ` [PATCH 09/11] super1.c: use ROUND_UP/ROUND_UP_PTR Jes.Sorensen
2012-03-20 16:54 ` [PATCH 10/11] super-intel.c: Use ROUND_UP() instead of manually coding it Jes.Sorensen
2012-03-20 16:54 ` [PATCH 11/11] __write_init_super_ddf(): Use posix_memalign() instead of static aligned buffer Jes.Sorensen
2012-03-20 21:11 ` [PATCH 00/11] Various cleanups and minor fixes NeilBrown
2012-03-21 7:58 ` Jes Sorensen
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=1332262456-5109-3-git-send-email-Jes.Sorensen@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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).