summaryrefslogtreecommitdiffstats
path: root/super0.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2012-02-14 11:52:13 +0100
committerNeilBrown <neilb@suse.de>2012-02-16 04:16:03 +0100
commitd669228f295e4c695475f0c1f7dc52f514a177c4 (patch)
tree740080c82807bcd4dd22403f3e67a52e312f374c /super0.c
parentconfig: conf_match should ignore devname when not set. (diff)
downloadmdadm-d669228f295e4c695475f0c1f7dc52f514a177c4.tar.xz
mdadm-d669228f295e4c695475f0c1f7dc52f514a177c4.zip
Use posix_memalign() for memory used to write bitmaps
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. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super0.c')
-rw-r--r--super0.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/super0.c b/super0.c
index dab85db8..d53f025e 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;
}