Fix bug in mount_mfs whereby mount_mfs would sometimes return before
the mount is completely active, causing the next few commands attempting to manipulate data on the mount to fail. mount_mfs's parent now tries to wait for the mount point st_dev to change before returning, indicating that the mount has gone active.
This commit is contained in:
parent
e4715b9359
commit
cb84cdb1c4
@ -36,7 +36,7 @@
|
|||||||
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: mkfs.c,v 1.25 1998/08/12 06:07:43 charnier Exp $";
|
"$Id: mkfs.c,v 1.26 1998/08/27 07:38:33 dfr Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
@ -49,6 +49,7 @@ static const char rcsid[] =
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <ufs/ufs/dinode.h>
|
#include <ufs/ufs/dinode.h>
|
||||||
#include <ufs/ufs/dir.h>
|
#include <ufs/ufs/dir.h>
|
||||||
#include <ufs/ffs/fs.h>
|
#include <ufs/ffs/fs.h>
|
||||||
@ -90,6 +91,8 @@ extern void srandomdev __P((void));
|
|||||||
* variables set up by front end.
|
* variables set up by front end.
|
||||||
*/
|
*/
|
||||||
extern int mfs; /* run as the memory based filesystem */
|
extern int mfs; /* run as the memory based filesystem */
|
||||||
|
extern char *mfs_mtpt; /* mount point for mfs */
|
||||||
|
extern struct stat mfs_mtstat; /* stat prior to mount */
|
||||||
extern int Nflag; /* run mkfs without writing file system */
|
extern int Nflag; /* run mkfs without writing file system */
|
||||||
extern int Oflag; /* format as an 4.3BSD file system */
|
extern int Oflag; /* format as an 4.3BSD file system */
|
||||||
extern int fssize; /* file system size */
|
extern int fssize; /* file system size */
|
||||||
@ -161,6 +164,8 @@ caddr_t malloc __P((u_long));
|
|||||||
caddr_t realloc __P((char *, u_long));
|
caddr_t realloc __P((char *, u_long));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int mfs_ppid = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
mkfs(pp, fsys, fi, fo)
|
mkfs(pp, fsys, fi, fo)
|
||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
@ -173,7 +178,7 @@ mkfs(pp, fsys, fi, fo)
|
|||||||
off_t usedb;
|
off_t usedb;
|
||||||
long mapcramped, inodecramped;
|
long mapcramped, inodecramped;
|
||||||
long postblsize, rotblsize, totalsbsize;
|
long postblsize, rotblsize, totalsbsize;
|
||||||
int ppid = 0, status, fd;
|
int status, fd;
|
||||||
time_t utime;
|
time_t utime;
|
||||||
quad_t sizepb;
|
quad_t sizepb;
|
||||||
void started();
|
void started();
|
||||||
@ -190,7 +195,7 @@ mkfs(pp, fsys, fi, fo)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (mfs) {
|
if (mfs) {
|
||||||
ppid = getpid();
|
mfs_ppid = getpid();
|
||||||
(void) signal(SIGUSR1, started);
|
(void) signal(SIGUSR1, started);
|
||||||
if ((i = fork())) {
|
if ((i = fork())) {
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
@ -726,7 +731,7 @@ next:
|
|||||||
* Dissociate from session and tty.
|
* Dissociate from session and tty.
|
||||||
*/
|
*/
|
||||||
if (mfs) {
|
if (mfs) {
|
||||||
kill(ppid, SIGUSR1);
|
kill(mfs_ppid, SIGUSR1);
|
||||||
(void) setsid();
|
(void) setsid();
|
||||||
(void) close(0);
|
(void) close(0);
|
||||||
(void) close(1);
|
(void) close(1);
|
||||||
@ -1149,11 +1154,29 @@ iput(ip, ino)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Notify parent process that the filesystem has created itself successfully.
|
* Notify parent process that the filesystem has created itself successfully.
|
||||||
|
*
|
||||||
|
* We have to wait until the mount has actually completed!
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
started()
|
started()
|
||||||
{
|
{
|
||||||
|
int retry = 100; /* 10 seconds, 100ms */
|
||||||
|
|
||||||
|
while (mfs_ppid && retry) {
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (
|
||||||
|
stat(mfs_mtpt, &st) < 0 ||
|
||||||
|
st.st_dev != mfs_mtstat.st_dev
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usleep(100*1000);
|
||||||
|
--retry;
|
||||||
|
}
|
||||||
|
if (retry == 0) {
|
||||||
|
fatal("mfs mount failed waiting for mount to go active");
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
|
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: newfs.c,v 1.26 1998/10/17 04:19:29 jkh Exp $";
|
"$Id: newfs.c,v 1.27 1998/10/17 08:03:52 bde Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -168,6 +168,8 @@ void fatal();
|
|||||||
#define NSECTORS 4096 /* number of sectors */
|
#define NSECTORS 4096 /* number of sectors */
|
||||||
|
|
||||||
int mfs; /* run as the memory based filesystem */
|
int mfs; /* run as the memory based filesystem */
|
||||||
|
char *mfs_mtpt; /* mount point for mfs */
|
||||||
|
struct stat mfs_mtstat; /* stat prior to mount */
|
||||||
int Nflag; /* run without writing file system */
|
int Nflag; /* run without writing file system */
|
||||||
int Oflag; /* format as an 4.3BSD file system */
|
int Oflag; /* format as an 4.3BSD file system */
|
||||||
int fssize; /* file system size */
|
int fssize; /* file system size */
|
||||||
@ -593,6 +595,15 @@ havelabel:
|
|||||||
pp->p_size *= secperblk;
|
pp->p_size *= secperblk;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (mfs) {
|
||||||
|
mfs_mtpt = argv[1];
|
||||||
|
if (
|
||||||
|
stat(mfs_mtpt, &mfs_mtstat) < 0 ||
|
||||||
|
!S_ISDIR(mfs_mtstat.st_mode)
|
||||||
|
) {
|
||||||
|
fatal("mount point not dir: %s", mfs_mtpt);
|
||||||
|
}
|
||||||
|
}
|
||||||
mkfs(pp, special, fsi, fso);
|
mkfs(pp, special, fsi, fso);
|
||||||
#ifdef tahoe
|
#ifdef tahoe
|
||||||
if (realsectorsize != DEV_BSIZE)
|
if (realsectorsize != DEV_BSIZE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user