From 04f903b21ad4d68aa8630433dc2b07edfbc0ad0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Wed, 21 May 2014 12:45:19 -0400 Subject: mdadm: Do not reimplment offsetof Proper implementations have offsetof in stddef.h Signed-off-by: NeilBrown --- super1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'super1.c') diff --git a/super1.c b/super1.c index 1bc5216f..7cf9b518 100644 --- a/super1.c +++ b/super1.c @@ -22,6 +22,7 @@ * Email: */ +#include #include "mdadm.h" /* * The version-1 superblock : @@ -133,9 +134,6 @@ struct misc_dev_info { |MD_FEATURE_NEW_OFFSET \ ) -#ifndef offsetof -#define offsetof(t,f) ((size_t)&(((t*)0)->f)) -#endif static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb) { unsigned int disk_csum, csum; -- cgit v1.2.3 From f4dc5e9b7f4226217b534023c8ede3fd50c673b5 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Aug 2014 11:34:50 +1000 Subject: super: make sure to ignore disk state flags that we don't understand. This make it easier to add new flags that some super-types don't understand. Signed-off-by: NeilBrown --- super1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'super1.c') diff --git a/super1.c b/super1.c index 7cf9b518..7fba9be0 100644 --- a/super1.c +++ b/super1.c @@ -1557,7 +1557,7 @@ static int write_init_super1(struct supertype *st) unsigned long long data_offset; for (di = st->info; di; di = di->next) { - if (di->disk.state == 1) + if (di->disk.state & (1 << MD_DISK_FAULTY)) continue; if (di->fd < 0) continue; -- cgit v1.2.3 From e2efe9e7bc73307f74a4c2e2197d6d4498dd46f0 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 7 Aug 2014 12:23:45 +1000 Subject: config: new option to suppress adding bad block lists. CREATE bbl=no in mdadm.conf will cause any devices added to an array to not have a bad block list. By default they do for 1.x metadata. This is useful if you are suspicious of the bad-block-list implementation. Reported-by: Ethan Wilson Signed-off-by: NeilBrown --- super1.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'super1.c') diff --git a/super1.c b/super1.c index 7fba9be0..9834594c 100644 --- a/super1.c +++ b/super1.c @@ -1688,6 +1688,10 @@ static int write_init_super1(struct supertype *st) rv = -EINVAL; goto out; } + if (conf_get_create_info()->bblist == 0) { + sb->bblog_size = 0; + sb->bblog_offset = 0; + } sb->sb_csum = calc_sb_1_csum(sb); rv = store_super1(st, di->fd); -- cgit v1.2.3 From 268cccac2e44e8e9166c9727e740d5d1f537b6a4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 15 Aug 2014 15:45:54 +1000 Subject: super1: don't allow adding a bitmap if there is no space. If the data is too close to the superblock there may be no space for a bitmap. If that happens, fail the adding of the bitmap rather than corrupt data. Reported-by: Lars Wijtemans Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=922944 --- super1.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'super1.c') diff --git a/super1.c b/super1.c index 9834594c..02d6c7a1 100644 --- a/super1.c +++ b/super1.c @@ -2105,6 +2105,10 @@ add_internal_bitmap1(struct supertype *st, /* Limit to 128K of bitmap when chunk size not requested */ room = 128*2; + if (room <= 1) + /* No room for a bitmap */ + return 0; + max_bits = (room * 512 - sizeof(bitmap_super_t)) * 8; min_chunk = 4096; /* sub-page chunks don't work yet.. */ -- cgit v1.2.3 From 6ac17e734b35ebfb1b158f902b26ee717bab43b8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 21 Aug 2014 10:57:55 +1000 Subject: super1: make sure 'room' includes 'bbl_size' when creating array. Because we then go ahead and subtrace bbl_size from room. Signed-off-by: NeilBrown --- super1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'super1.c') diff --git a/super1.c b/super1.c index 02d6c7a1..727a08a1 100644 --- a/super1.c +++ b/super1.c @@ -2048,8 +2048,8 @@ add_internal_bitmap1(struct supertype *st, * been left. */ offset = 0; - room = choose_bm_space(__le64_to_cpu(sb->size)); bbl_size = 8; + room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size; } else { room = __le64_to_cpu(sb->super_offset) - __le64_to_cpu(sb->data_offset) @@ -2075,8 +2075,8 @@ add_internal_bitmap1(struct supertype *st, case 2: /* between superblock and data */ if (creating) { offset = 4*2; - room = choose_bm_space(__le64_to_cpu(sb->size)); bbl_size = 8; + room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size; } else { room = __le64_to_cpu(sb->data_offset) - __le64_to_cpu(sb->super_offset); -- cgit v1.2.3