* [PATCH 1/4] mdadm: let cluster raid could also add disk within incremental mode
@ 2015-12-01 16:30 Guoqing Jiang
2015-12-01 16:30 ` [PATCH 2/4] mdadm: output info more precisely when change bitmap to none Guoqing Jiang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Guoqing Jiang @ 2015-12-01 16:30 UTC (permalink / raw)
To: neilb, linux-raid; +Cc: rgoldwyn, Guoqing Jiang
For cluster raid, the disc.state need to be changed accordingly under
incremental mode.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
Incremental.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Incremental.c b/Incremental.c
index 781d27d..7afa7d7 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -444,6 +444,10 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* add disk needs to know about containers */
if (st->ss->external)
sra->array.level = LEVEL_CONTAINER;
+
+ if (info.array.state & (1 << MD_SB_CLUSTERED))
+ info.disk.state |= (1 << MD_DISK_CLUSTER_ADD);
+
err = add_disk(mdfd, st, sra, &info);
if (err < 0 && errno == EBUSY) {
/* could be another device present with the same
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] mdadm: output info more precisely when change bitmap to none
2015-12-01 16:30 [PATCH 1/4] mdadm: let cluster raid could also add disk within incremental mode Guoqing Jiang
@ 2015-12-01 16:30 ` Guoqing Jiang
2015-12-01 16:30 ` [PATCH 3/4] mdadm: don't show cluster name once the bitmap is cleared Guoqing Jiang
2015-12-01 16:30 ` [PATCH 4/4] mdadm: do not display bitmap info if it " Guoqing Jiang
2 siblings, 0 replies; 5+ messages in thread
From: Guoqing Jiang @ 2015-12-01 16:30 UTC (permalink / raw)
To: neilb, linux-raid; +Cc: rgoldwyn, Guoqing Jiang
WHen change bitmap to none, the infos could be more accurate
based on existed bitmap type.
And s->bitmap_file is passed from cmd "--bitmap=TYPE", so
remove s->bitmap_file from err info since it should means
change the bitmap to one type failed rather than the type is
already presented.
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
Grow.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Grow.c b/Grow.c
index 80d7b22..30ff7f3 100644
--- a/Grow.c
+++ b/Grow.c
@@ -328,12 +328,15 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
if (strcmp(s->bitmap_file, "none")==0) {
array.state &= ~(1<<MD_SB_BITMAP_PRESENT);
if (ioctl(fd, SET_ARRAY_INFO, &array)!= 0) {
- pr_err("failed to remove internal bitmap.\n");
+ if (array.state & (1<<MD_SB_CLUSTERED))
+ pr_err("failed to remove clustered bitmap.\n");
+ else
+ pr_err("failed to remove internal bitmap.\n");
return 1;
}
return 0;
}
- pr_err("%s bitmap already present on %s\n", s->bitmap_file, devname);
+ pr_err("bitmap already present on %s\n", devname);
return 1;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] mdadm: don't show cluster name once the bitmap is cleared
2015-12-01 16:30 [PATCH 1/4] mdadm: let cluster raid could also add disk within incremental mode Guoqing Jiang
2015-12-01 16:30 ` [PATCH 2/4] mdadm: output info more precisely when change bitmap to none Guoqing Jiang
@ 2015-12-01 16:30 ` Guoqing Jiang
2015-12-01 16:30 ` [PATCH 4/4] mdadm: do not display bitmap info if it " Guoqing Jiang
2 siblings, 0 replies; 5+ messages in thread
From: Guoqing Jiang @ 2015-12-01 16:30 UTC (permalink / raw)
To: neilb, linux-raid; +Cc: rgoldwyn, Guoqing Jiang
Don't show cluster name if bitmap is cleared.
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
super1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/super1.c b/super1.c
index 1735c2d..062d9e7 100644
--- a/super1.c
+++ b/super1.c
@@ -324,7 +324,7 @@ static void examine_super1(struct supertype *st, char *homehost)
strncmp(sb->set_name, homehost, l) == 0)
printf(" (local to host %s)", homehost);
printf("\n");
- if (bms->nodes > 0)
+ if (bms->nodes > 0 && (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
printf(" Cluster Name : %-64s\n", bms->cluster_name);
atime = __le64_to_cpu(sb->ctime) & 0xFFFFFFFFFFULL;
printf(" Creation Time : %.24s\n", ctime(&atime));
@@ -780,7 +780,7 @@ static void detail_super1(struct supertype *st, char *homehost)
sb->set_name[l] == ':' &&
strncmp(sb->set_name, homehost, l) == 0)
printf(" (local to host %s)", homehost);
- if (bms->nodes > 0)
+ if (bms->nodes > 0 && (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
printf("\n Cluster Name : %-64s", bms->cluster_name);
printf("\n UUID : ");
for (i=0; i<16; i++) {
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] mdadm: do not display bitmap info if it is cleared
2015-12-01 16:30 [PATCH 1/4] mdadm: let cluster raid could also add disk within incremental mode Guoqing Jiang
2015-12-01 16:30 ` [PATCH 2/4] mdadm: output info more precisely when change bitmap to none Guoqing Jiang
2015-12-01 16:30 ` [PATCH 3/4] mdadm: don't show cluster name once the bitmap is cleared Guoqing Jiang
@ 2015-12-01 16:30 ` Guoqing Jiang
2015-12-16 2:24 ` NeilBrown
2 siblings, 1 reply; 5+ messages in thread
From: Guoqing Jiang @ 2015-12-01 16:30 UTC (permalink / raw)
To: neilb, linux-raid; +Cc: rgoldwyn, Guoqing Jiang
"mdadm -X DISK" is used to report information about a bitmap
file, it is better to not display all the related infos if
bitmap is cleared with "--bitmap=none" under grow mode.
To do that, the locate_bitmap is changed a little to have a
return value based on MD_FEATURE_BITMAP_OFFSET.
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
bitmap.c | 8 ++++++--
mdadm.h | 2 +-
super0.c | 7 ++++---
super1.c | 12 +++++++++---
4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/bitmap.c b/bitmap.c
index 803eda3..dab674b 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -221,8 +221,12 @@ int bitmap_file_open(char *filename, struct supertype **stp)
pr_err("No bitmap possible with %s metadata\n",
st->ss->name);
return -1;
- } else
- st->ss->locate_bitmap(st, fd);
+ } else {
+ if (st->ss->locate_bitmap(st, fd)) {
+ pr_err("%s doesn't have bitmap\n", filename);
+ fd = -1;
+ }
+ }
*stp = st;
} else {
diff --git a/mdadm.h b/mdadm.h
index 5d5e97f..aad0fa8 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -873,7 +873,7 @@ extern struct superswitch {
/* Seek 'fd' to start of write-intent-bitmap. Must be an
* md-native format bitmap
*/
- void (*locate_bitmap)(struct supertype *st, int fd);
+ int (*locate_bitmap)(struct supertype *st, int fd);
/* if add_internal_bitmap succeeded for existing array, this
* writes it out.
*/
diff --git a/super0.c b/super0.c
index 6ad9d39..7f80014 100644
--- a/super0.c
+++ b/super0.c
@@ -1155,16 +1155,16 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
return 1;
}
-static void locate_bitmap0(struct supertype *st, int fd)
+static int locate_bitmap0(struct supertype *st, int fd)
{
unsigned long long dsize;
unsigned long long offset;
if (!get_dev_size(fd, NULL, &dsize))
- return;
+ return -1;
if (dsize < MD_RESERVED_SECTORS*512)
- return;
+ return -1;
offset = MD_NEW_SIZE_SECTORS(dsize>>9);
@@ -1173,6 +1173,7 @@ static void locate_bitmap0(struct supertype *st, int fd)
offset += MD_SB_BYTES;
lseek64(fd, offset, 0);
+ return 0;
}
static int write_bitmap0(struct supertype *st, int fd, enum bitmap_update update)
diff --git a/super1.c b/super1.c
index 062d9e7..7a1156d 100644
--- a/super1.c
+++ b/super1.c
@@ -1520,7 +1520,7 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
}
#endif
-static void locate_bitmap1(struct supertype *st, int fd);
+static int locate_bitmap1(struct supertype *st, int fd);
static int store_super1(struct supertype *st, int fd)
{
@@ -2304,24 +2304,30 @@ add_internal_bitmap1(struct supertype *st,
return 1;
}
-static void locate_bitmap1(struct supertype *st, int fd)
+static int locate_bitmap1(struct supertype *st, int fd)
{
unsigned long long offset;
struct mdp_superblock_1 *sb;
int mustfree = 0;
+ int ret;
if (!st->sb) {
if (st->ss->load_super(st, fd, NULL))
- return; /* no error I hope... */
+ return -1; /* no error I hope... */
mustfree = 1;
}
sb = st->sb;
+ if ((__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
+ ret = 0;
+ else
+ ret = -1;
offset = __le64_to_cpu(sb->super_offset);
offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
if (mustfree)
free(sb);
lseek64(fd, offset<<9, 0);
+ return ret;
}
static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update)
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] mdadm: do not display bitmap info if it is cleared
2015-12-01 16:30 ` [PATCH 4/4] mdadm: do not display bitmap info if it " Guoqing Jiang
@ 2015-12-16 2:24 ` NeilBrown
0 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2015-12-16 2:24 UTC (permalink / raw)
To: linux-raid; +Cc: rgoldwyn, Guoqing Jiang
[-- Attachment #1: Type: text/plain, Size: 3833 bytes --]
On Wed, Dec 02 2015, Guoqing Jiang wrote:
> "mdadm -X DISK" is used to report information about a bitmap
> file, it is better to not display all the related infos if
> bitmap is cleared with "--bitmap=none" under grow mode.
>
> To do that, the locate_bitmap is changed a little to have a
> return value based on MD_FEATURE_BITMAP_OFFSET.
>
> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
> ---
> bitmap.c | 8 ++++++--
> mdadm.h | 2 +-
> super0.c | 7 ++++---
> super1.c | 12 +++++++++---
> 4 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/bitmap.c b/bitmap.c
> index 803eda3..dab674b 100644
> --- a/bitmap.c
> +++ b/bitmap.c
> @@ -221,8 +221,12 @@ int bitmap_file_open(char *filename, struct supertype **stp)
> pr_err("No bitmap possible with %s metadata\n",
> st->ss->name);
> return -1;
> - } else
> - st->ss->locate_bitmap(st, fd);
> + } else {
> + if (st->ss->locate_bitmap(st, fd)) {
> + pr_err("%s doesn't have bitmap\n", filename);
> + fd = -1;
> + }
> + }
>
> *stp = st;
> } else {
> diff --git a/mdadm.h b/mdadm.h
> index 5d5e97f..aad0fa8 100644
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -873,7 +873,7 @@ extern struct superswitch {
> /* Seek 'fd' to start of write-intent-bitmap. Must be an
> * md-native format bitmap
> */
> - void (*locate_bitmap)(struct supertype *st, int fd);
> + int (*locate_bitmap)(struct supertype *st, int fd);
> /* if add_internal_bitmap succeeded for existing array, this
> * writes it out.
> */
> diff --git a/super0.c b/super0.c
> index 6ad9d39..7f80014 100644
> --- a/super0.c
> +++ b/super0.c
> @@ -1155,16 +1155,16 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
> return 1;
> }
>
> -static void locate_bitmap0(struct supertype *st, int fd)
> +static int locate_bitmap0(struct supertype *st, int fd)
> {
> unsigned long long dsize;
> unsigned long long offset;
>
> if (!get_dev_size(fd, NULL, &dsize))
> - return;
> + return -1;
>
> if (dsize < MD_RESERVED_SECTORS*512)
> - return;
> + return -1;
>
> offset = MD_NEW_SIZE_SECTORS(dsize>>9);
>
> @@ -1173,6 +1173,7 @@ static void locate_bitmap0(struct supertype *st, int fd)
> offset += MD_SB_BYTES;
>
> lseek64(fd, offset, 0);
> + return 0;
> }
>
> static int write_bitmap0(struct supertype *st, int fd, enum bitmap_update update)
> diff --git a/super1.c b/super1.c
> index 062d9e7..7a1156d 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1520,7 +1520,7 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
> }
> #endif
>
> -static void locate_bitmap1(struct supertype *st, int fd);
> +static int locate_bitmap1(struct supertype *st, int fd);
>
> static int store_super1(struct supertype *st, int fd)
> {
> @@ -2304,24 +2304,30 @@ add_internal_bitmap1(struct supertype *st,
> return 1;
> }
>
> -static void locate_bitmap1(struct supertype *st, int fd)
> +static int locate_bitmap1(struct supertype *st, int fd)
> {
> unsigned long long offset;
> struct mdp_superblock_1 *sb;
> int mustfree = 0;
> + int ret;
>
> if (!st->sb) {
> if (st->ss->load_super(st, fd, NULL))
> - return; /* no error I hope... */
> + return -1; /* no error I hope... */
> mustfree = 1;
> }
> sb = st->sb;
>
> + if ((__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
> + ret = 0;
> + else
> + ret = -1;
> offset = __le64_to_cpu(sb->super_offset);
> offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
> if (mustfree)
> free(sb);
> lseek64(fd, offset<<9, 0);
> + return ret;
> }
>
> static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update)
> --
> 2.1.4
All 4 applied,
thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-16 2:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 16:30 [PATCH 1/4] mdadm: let cluster raid could also add disk within incremental mode Guoqing Jiang
2015-12-01 16:30 ` [PATCH 2/4] mdadm: output info more precisely when change bitmap to none Guoqing Jiang
2015-12-01 16:30 ` [PATCH 3/4] mdadm: don't show cluster name once the bitmap is cleared Guoqing Jiang
2015-12-01 16:30 ` [PATCH 4/4] mdadm: do not display bitmap info if it " Guoqing Jiang
2015-12-16 2:24 ` NeilBrown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).