diff options
author | Neil Brown <neilb@suse.de> | 2008-07-12 20:28:33 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2008-07-12 20:28:33 +1000 |
commit | 6416d5275d65be25a6cd63583bb2b92e6fba95a5 (patch) | |
tree | 23757b31666774c05c405dfd720dc92b3bb03b90 /bitmap.c | |
parent | 908ef18519f7d5780ebf00b19b913f8282eb4175 (diff) | |
download | mdadm-6416d5275d65be25a6cd63583bb2b92e6fba95a5.tar.gz mdadm-6416d5275d65be25a6cd63583bb2b92e6fba95a5.tar.xz mdadm-6416d5275d65be25a6cd63583bb2b92e6fba95a5.zip |
Use O_DIRECT for all IO to devices.
Using buffered IO risks non-atomic updates to parts of the
device that we don't actually want to write to. This isn't in
general safe.
So switch to O_DIRECT for all that IO and make sure we have
properly aligned buffers.
Diffstat (limited to 'bitmap.c')
-rw-r--r-- | bitmap.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -122,11 +122,10 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief) */ unsigned long long total_bits = 0, read_bits = 0, dirty_bits = 0; bitmap_info_t *info; - char *buf, *unaligned; + void *buf; int n, skip; - unaligned = malloc(8192*2); - buf = (char*) ((unsigned long)unaligned | 8191)+1; + posix_memalign(&buf, 512, 8192); n = read(fd, buf, 8192); info = malloc(sizeof(*info)); @@ -145,7 +144,6 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief) fprintf(stderr, Name ": failed to read superblock of bitmap " "file: %s\n", strerror(errno)); free(info); - free(unaligned); return NULL; } memcpy(&info->sb, buf, sizeof(info->sb)); |