SHA256
1
0
forked from pool/mdadm
mdadm/super0-Do-all-metadata-IO-with-4096byte-alignment.patch

87 lines
3.0 KiB
Diff

From 24303a80dfff51654595b3605fa8b1b9b1c4b578 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Tue, 3 Mar 2009 14:25:59 +1100
Subject: [PATCH 1/2] super0: Do all metadata IO with 4096byte alignment
.. because some devices (dasd) has 4096 byte sector size.
As the superblock is 4096 bytes and the bitmap is in a
60K region, this is safe from any possible corruption.
Signed-off-by: NeilBrown <neilb@suse.de>
---
super0.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
Index: mdadm-3.0-devel2/super0.c
===================================================================
--- mdadm-3.0-devel2.orig/super0.c
+++ mdadm-3.0-devel2/super0.c
@@ -545,7 +545,8 @@ static int init_super0(struct supertype
mdp_super_t *sb;
int spares;
- if (posix_memalign((void**)&sb, 512, MD_SB_BYTES + sizeof(bitmap_super_t)) != 0) {
+ if (posix_memalign((void**)&sb, 4096,
+ MD_SB_BYTES + ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
return 0;
}
@@ -680,8 +681,8 @@ static int store_super0(struct supertype
if (super->state & (1<<MD_SB_BITMAP_PRESENT)) {
struct bitmap_super_s * bm = (struct bitmap_super_s*)(super+1);
if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC)
- if (write(fd, bm, ROUND_UP(sizeof(*bm),512)) !=
- ROUND_UP(sizeof(*bm),512))
+ if (write(fd, bm, ROUND_UP(sizeof(*bm),4096)) !=
+ ROUND_UP(sizeof(*bm),4096))
return 5;
}
@@ -741,8 +742,9 @@ static int compare_super0(struct superty
if (second->md_magic != MD_SB_MAGIC)
return 1;
if (!first) {
- if (posix_memalign((void**)&first, 512,
- MD_SB_BYTES + sizeof(struct bitmap_super_s)) != 0) {
+ if (posix_memalign((void**)&first, 4096,
+ MD_SB_BYTES +
+ ROUND_UP(sizeof(struct bitmap_super_s), 4096)) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
return 1;
@@ -815,8 +817,9 @@ static int load_super0(struct supertype
return 1;
}
- if (posix_memalign((void**)&super, 512,
- MD_SB_BYTES + sizeof(bitmap_super_t)+512) != 0) {
+ if (posix_memalign((void**)&super, 4096,
+ MD_SB_BYTES +
+ ROUND_UP(sizeof(bitmap_super_t), 4096)) != 0) {
fprintf(stderr, Name
": %s could not allocate superblock\n", __func__);
return 1;
@@ -864,8 +867,8 @@ static int load_super0(struct supertype
* valid. If it doesn't clear the bit. An --assemble --force
* should get that written out.
*/
- if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),512))
- != ROUND_UP(sizeof(struct bitmap_super_s),512))
+ if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),4096))
+ != ROUND_UP(sizeof(struct bitmap_super_s),4096))
goto no_bitmap;
uuid_from_super0(st, uuid);
@@ -996,8 +999,8 @@ static int write_bitmap0(struct supertyp
int rv = 0;
int towrite, n;
- char abuf[4096+512];
- char *buf = (char*)(((long)(abuf+512))&~511UL);
+ char abuf[4096+4096];
+ char *buf = (char*)(((long)(abuf+4096))&~4095L);
if (!get_dev_size(fd, NULL, &dsize))
return 1;