* [mdadm PATCH 0/2] Some fixes for mdadm @ 2020-09-14 5:38 Xiao Ni 2020-09-14 5:38 ` [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device Xiao Ni 2020-09-14 5:38 ` [mdadm PATCH 2/2] Don't create bitmap for raid5 with journal disk Xiao Ni 0 siblings, 2 replies; 5+ messages in thread From: Xiao Ni @ 2020-09-14 5:38 UTC (permalink / raw) To: jes, linux-raid; +Cc: colyli, ncroxon Hi all These two patches fix some mdadm problems. The first is to avoid one raid being not active after boot. The second patch is to check journal device when creating bitmap. Xiao Ni (2): Check hostname file empty or not when creating raid device Don't create bitmap for raid5 with journal disk Create.c | 1 + mdadm.c | 3 +++ mdadm.h | 1 + util.c | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+) -- 2.7.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device 2020-09-14 5:38 [mdadm PATCH 0/2] Some fixes for mdadm Xiao Ni @ 2020-09-14 5:38 ` Xiao Ni 2020-09-14 8:28 ` anthony 2020-09-14 5:38 ` [mdadm PATCH 2/2] Don't create bitmap for raid5 with journal disk Xiao Ni 1 sibling, 1 reply; 5+ messages in thread From: Xiao Ni @ 2020-09-14 5:38 UTC (permalink / raw) To: jes, linux-raid; +Cc: colyli, ncroxon If /etc/hostname is empty and the hostname is decided by DHCP. There is a risk that the raid device can't be active after boot. Maybe the network starts after storage. The system can detect disk first and udev rules are triggered. It wants to assemble the raid device. But the network hasn't started successfully. So the hostname is not specified. The raid will be treat as a foreign raid. So give a warning message if /etc/hostname is empty when creating a raid device. Signed-off-by: Xiao Ni <xni@redhat.com> --- mdadm.c | 3 +++ mdadm.h | 1 + util.c | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/mdadm.c b/mdadm.c index 1b3467f..e551958 100644 --- a/mdadm.c +++ b/mdadm.c @@ -1408,6 +1408,9 @@ int main(int argc, char *argv[]) if (c.homehost == NULL && c.require_homehost) c.homehost = conf_get_homehost(&c.require_homehost); if (c.homehost == NULL || strcasecmp(c.homehost, "<system>") == 0) { + if (check_hostname()) + pr_err("Note: The file /etc/hostname is empty. There is a risk the raid\n" + " can't be active after boot\n"); if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) { sys_hostname[sizeof(sys_hostname)-1] = 0; c.homehost = sys_hostname; diff --git a/mdadm.h b/mdadm.h index 399478b..3ef1209 100644 --- a/mdadm.h +++ b/mdadm.h @@ -1480,6 +1480,7 @@ extern int parse_cluster_confirm_arg(char *inp, char **devname, int *slot); extern int check_ext2(int fd, char *name); extern int check_reiser(int fd, char *name); extern int check_raid(int fd, char *name); +extern int check_hostname(void); extern int check_partitions(int fd, char *dname, unsigned long long freesize, unsigned long long size); diff --git a/util.c b/util.c index 579dd42..de5bad0 100644 --- a/util.c +++ b/util.c @@ -694,6 +694,25 @@ int check_raid(int fd, char *name) return 1; } +/* It checks /etc/hostname has value or not */ +int check_hostname() +{ + int fd, ret = 0; + char buf[256]; + + fd = open("/etc/hostname", O_RDONLY); + if (fd < 0) { + ret = 1; + goto out; + } + + if (read(fd, buf, sizeof(buf)) == 0) + ret = 1; +out: + close(fd); + return ret; +} + int fstat_is_blkdev(int fd, char *devname, dev_t *rdev) { struct stat stb; -- 2.7.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device 2020-09-14 5:38 ` [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device Xiao Ni @ 2020-09-14 8:28 ` anthony 2020-09-14 11:36 ` Xiao Ni 0 siblings, 1 reply; 5+ messages in thread From: anthony @ 2020-09-14 8:28 UTC (permalink / raw) To: Xiao Ni, jes, linux-raid; +Cc: colyli, ncroxon On 14/09/2020 06:38, Xiao Ni wrote: > If /etc/hostname is empty and the hostname is decided by DHCP. There is a risk that the raid > device can't be active after boot. Maybe the network starts after storage. The system can ^^^^^ I think you mean "won't" - "the raid device will not be active after boot". This is a nasty corner case in English Grammar - one verb is "I can, you will, he will", the other is "I will, you can, he can" !?!?!? If you mean it is possible that the array will not be there after boot, but that the user can just start it manually (ie there's no real problem with it), then it's "the raid device won't be active ..." Cheers, Wol ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device 2020-09-14 8:28 ` anthony @ 2020-09-14 11:36 ` Xiao Ni 0 siblings, 0 replies; 5+ messages in thread From: Xiao Ni @ 2020-09-14 11:36 UTC (permalink / raw) To: anthony, jes, linux-raid; +Cc: colyli, ncroxon On 09/14/2020 04:28 PM, anthony wrote: > On 14/09/2020 06:38, Xiao Ni wrote: >> If /etc/hostname is empty and the hostname is decided by DHCP. There >> is a risk that the raid >> device can't be active after boot. Maybe the network starts after >> storage. The system can > ^^^^^ > > I think you mean "won't" - "the raid device will not be active after > boot". > > This is a nasty corner case in English Grammar - one verb is "I can, > you will, he will", the other is "I will, you can, he can" !?!?!? > > If you mean it is possible that the array will not be there after > boot, but that the user can just start it manually (ie there's no real > problem with it), then it's "the raid device won't be active ..." > > Cheers, > Wol > Hi Wol Thanks for pointing about this. I need to explain more exactly. The raid will not be in active state for boot. It'll be auto-read-only state. I'll send the patch again. Thanks Xiao ^ permalink raw reply [flat|nested] 5+ messages in thread
* [mdadm PATCH 2/2] Don't create bitmap for raid5 with journal disk 2020-09-14 5:38 [mdadm PATCH 0/2] Some fixes for mdadm Xiao Ni 2020-09-14 5:38 ` [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device Xiao Ni @ 2020-09-14 5:38 ` Xiao Ni 1 sibling, 0 replies; 5+ messages in thread From: Xiao Ni @ 2020-09-14 5:38 UTC (permalink / raw) To: jes, linux-raid; +Cc: colyli, ncroxon Journal disk and bitmap can't exist at the same time. It needs to check if the raid has a journal disk when creating bitmap. Signed-off-by: Xiao Ni <xni@redhat.com> --- Create.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Create.c b/Create.c index 6f84e5b..0efa19c 100644 --- a/Create.c +++ b/Create.c @@ -542,6 +542,7 @@ int Create(struct supertype *st, char *mddev, if (!s->bitmap_file && s->level >= 1 && st->ss->add_internal_bitmap && + s->journaldisks == 0 && (s->consistency_policy != CONSISTENCY_POLICY_RESYNC && s->consistency_policy != CONSISTENCY_POLICY_PPL) && (s->write_behind || s->size > 100*1024*1024ULL)) { -- 2.7.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-14 11:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-09-14 5:38 [mdadm PATCH 0/2] Some fixes for mdadm Xiao Ni 2020-09-14 5:38 ` [mdadm PATCH 1/2] Check hostname file empty or not when creating raid device Xiao Ni 2020-09-14 8:28 ` anthony 2020-09-14 11:36 ` Xiao Ni 2020-09-14 5:38 ` [mdadm PATCH 2/2] Don't create bitmap for raid5 with journal disk Xiao Ni
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).