From: NeilBrown <neilb@suse.de>
To: Jes.Sorensen@redhat.com
Cc: alexandermurashkin@msn.com, linux-raid@vger.kernel.org
Subject: Re: [PATCH] Use posix_memalign() for memory used to write bitmaps
Date: Thu, 16 Feb 2012 14:17:35 +1100 [thread overview]
Message-ID: <20120216141735.4065bf8a@notabene.brown> (raw)
In-Reply-To: <1329216733-7081-1-git-send-email-Jes.Sorensen@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2522 bytes --]
On Tue, 14 Feb 2012 11:52:13 +0100 Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> This makes super[01].c properly align buffers used for the bitmap
> using posix_memalign() to make sure the writes don't fail in case the
> bitmap is opened using O_DIRECT.
>
> This is based on https://bugzilla.redhat.com/show_bug.cgi?id=789898
> and an initial patch by Alexander Murashkin.
hi Jes,
I suspect that
http://neil.brown.name/git?p=mdadm;a=commitdiff;h=6ef89052d85b8137b8a7100f761d896ae6f61001
is the fix you want. But I'll probably apply yours as well.
Thanks,
NeilBrown
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
> super0.c | 8 +++++---
> super1.c | 7 +++++--
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/super0.c b/super0.c
> index dab85db..d53f025 100644
> --- a/super0.c
> +++ b/super0.c
> @@ -1065,13 +1065,11 @@ static int write_bitmap0(struct supertype *st, int fd)
> int rv = 0;
>
> int towrite, n;
> - char abuf[4096+4096];
> - char *buf = (char*)(((long)(abuf+4096))&~4095L);
> + void *buf;
>
> if (!get_dev_size(fd, NULL, &dsize))
> return 1;
>
> -
> if (dsize < MD_RESERVED_SECTORS*512)
> return -1;
>
> @@ -1082,6 +1080,9 @@ static int write_bitmap0(struct supertype *st, int fd)
> if (lseek64(fd, offset + 4096, 0)< 0LL)
> return 3;
>
> + if (posix_memalign(&buf, 4096, 4096))
> + return -ENOMEM;
> +
> memset(buf, 0xff, 4096);
> memcpy(buf, ((char*)sb)+MD_SB_BYTES, sizeof(bitmap_super_t));
> towrite = 60*1024;
> @@ -1100,6 +1101,7 @@ static int write_bitmap0(struct supertype *st, int fd)
> if (towrite)
> rv = -2;
>
> + free(buf);
> return rv;
> }
>
> diff --git a/super1.c b/super1.c
> index cfa237a..a18952a 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1641,12 +1641,14 @@ static int write_bitmap1(struct supertype *st, int fd)
> struct mdp_superblock_1 *sb = st->sb;
> bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb)+1024);
> int rv = 0;
> -
> + void *buf;
> int towrite, n;
> - char buf[4096];
>
> locate_bitmap1(st, fd);
>
> + if (posix_memalign(&buf, 4096, 4096))
> + return -ENOMEM;
> +
> memset(buf, 0xff, 4096);
> memcpy(buf, ((char*)sb)+1024, sizeof(bitmap_super_t));
>
> @@ -1669,6 +1671,7 @@ static int write_bitmap1(struct supertype *st, int fd)
> if (towrite)
> rv = -2;
>
> + free(buf);
> return rv;
> }
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2012-02-16 3:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 10:52 [PATCH] Use posix_memalign() for memory used to write bitmaps Jes.Sorensen
2012-02-16 3:17 ` NeilBrown [this message]
2012-02-16 8:01 ` 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=20120216141735.4065bf8a@notabene.brown \
--to=neilb@suse.de \
--cc=Jes.Sorensen@redhat.com \
--cc=alexandermurashkin@msn.com \
--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.