Assemble/Incremental: don't hold O_EXCL on mddev after assembly.
As soon as the array is assembled, udev or systemd might run fsck and mount it. So we need to drop O_EXCL promptly. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
5dd29dafa2
commit
8832342d3a
|
@ -1037,6 +1037,7 @@ static int start_array(int mdfd,
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
rv = ioctl(mdfd, RUN_ARRAY, NULL);
|
rv = ioctl(mdfd, RUN_ARRAY, NULL);
|
||||||
|
reopen_mddev(mdfd); /* drop O_EXCL */
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
if (c->verbose >= 0) {
|
if (c->verbose >= 0) {
|
||||||
pr_err("%s has been started with %d drive%s",
|
pr_err("%s has been started with %d drive%s",
|
||||||
|
|
|
@ -588,10 +588,14 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
|
||||||
else
|
else
|
||||||
rv = sysfs_set_str(sra, NULL,
|
rv = sysfs_set_str(sra, NULL,
|
||||||
"array_state", "read-auto");
|
"array_state", "read-auto");
|
||||||
|
/* Array might be O_EXCL which will interfere with
|
||||||
|
* fsck and mount. So re-open without O_EXCL.
|
||||||
|
*/
|
||||||
|
reopen_mddev(mdfd);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
if (c->export) {
|
if (c->export) {
|
||||||
printf("MD_STARTED=yes\n");
|
printf("MD_STARTED=yes\n");
|
||||||
} else if (c->verbose >= 0)
|
} else if (c->verbose >= 0)
|
||||||
pr_err("%s attached to %s, which has been started.\n",
|
pr_err("%s attached to %s, which has been started.\n",
|
||||||
devname, chosen_name);
|
devname, chosen_name);
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
1
mdadm.h
1
mdadm.h
|
@ -1272,6 +1272,7 @@ extern int check_partitions(int fd, char *dname,
|
||||||
extern int get_mdp_major(void);
|
extern int get_mdp_major(void);
|
||||||
extern int dev_open(char *dev, int flags);
|
extern int dev_open(char *dev, int flags);
|
||||||
extern int open_dev(char *devnm);
|
extern int open_dev(char *devnm);
|
||||||
|
extern void reopen_mddev(int mdfd);
|
||||||
extern int open_dev_flags(char *devnm, int flags);
|
extern int open_dev_flags(char *devnm, int flags);
|
||||||
extern int open_dev_excl(char *devnm);
|
extern int open_dev_excl(char *devnm);
|
||||||
extern int is_standard(char *dev, int *nump);
|
extern int is_standard(char *dev, int *nump);
|
||||||
|
|
14
util.c
14
util.c
|
@ -1950,3 +1950,17 @@ int in_initrd(void)
|
||||||
((unsigned long)s.f_type == TMPFS_MAGIC ||
|
((unsigned long)s.f_type == TMPFS_MAGIC ||
|
||||||
(unsigned long)s.f_type == RAMFS_MAGIC);
|
(unsigned long)s.f_type == RAMFS_MAGIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reopen_mddev(int mdfd)
|
||||||
|
{
|
||||||
|
/* Re-open without any O_EXCL, but keep
|
||||||
|
* the same fd
|
||||||
|
*/
|
||||||
|
char *devnm;
|
||||||
|
int fd;
|
||||||
|
devnm = fd2devnm(mdfd);
|
||||||
|
close(mdfd);
|
||||||
|
fd = open_dev(devnm);
|
||||||
|
if (fd >= 0 && fd != mdfd)
|
||||||
|
dup2(fd, mdfd);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue