diff options
author | Jes Sorensen <Jes.Sorensen@redhat.com> | 2012-02-14 11:52:13 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-02-16 14:16:03 +1100 |
commit | d669228f295e4c695475f0c1f7dc52f514a177c4 (patch) | |
tree | 740080c82807bcd4dd22403f3e67a52e312f374c /super1.c | |
parent | 9f1b0f0f1ed0dd4752be65348a24971335cd50e8 (diff) |
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 'super1.c')
-rw-r--r-- | super1.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; } |