Subject: Re: unmounting filesystem but already underlying device is gone.
To: None <tech-kern@netbsd.org>
From: enami tsugutomo <enami@but-b.or.jp>
List: tech-kern
Date: 09/26/1999 19:13:08
Jason Thorpe <thorpej@nas.nasa.gov> writes:
> > So, what is the right way to avoid this? If I check vnode type and
> > make sure it is not VBAD before touching v_specflags prevent me from
> > crash, but I wonder if it is right way or not...
>
> That's probably a reasonable solution...
Hm, then, I'll commit following patches in a few days. Thanks!
BTW, in ntfs_mountfs, we are also clearing SI_MOUNTEDON on failure
exit. Since we checked that it isn't set when entering this function
(by vfs_mountedon), if we really need to clear it, it means that we
are clearing the flag someone else set.
enami.
Index: adosfs/advfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/adosfs/advfsops.c,v
retrieving revision 1.36
diff -u -r1.36 advfsops.c
--- advfsops.c 1999/06/02 22:04:30 1.36
+++ advfsops.c 1999/09/26 06:35:09
@@ -298,7 +298,8 @@
if ((error = vflush(mp, NULLVP, flags)) != 0)
return (error);
amp = VFSTOADOSFS(mp);
- amp->devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (amp->devvp->v_type != VBAD)
+ amp->devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(amp->devvp, FREAD, NOCRED, p);
vrele(amp->devvp);
if (amp->bitmap)
Index: filecorefs/filecore_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/filecorefs/filecore_vfsops.c,v
retrieving revision 1.7
diff -u -r1.7 filecore_vfsops.c
--- filecore_vfsops.c 1999/07/08 01:06:00 1.7
+++ filecore_vfsops.c 1999/09/26 06:35:09
@@ -391,7 +391,8 @@
fcmp = VFSTOFILECORE(mp);
- fcmp->fc_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (fcmp->fc_devvp->v_type != VBAD)
+ fcmp->fc_devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(fcmp->fc_devvp, FREAD, NOCRED, p);
vrele(fcmp->fc_devvp);
free((caddr_t)fcmp, M_FILECOREMNT);
Index: isofs/cd9660/cd9660_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/isofs/cd9660/cd9660_vfsops.c,v
retrieving revision 1.39
diff -u -r1.39 cd9660_vfsops.c
--- cd9660_vfsops.c 1999/07/17 01:08:28 1.39
+++ cd9660_vfsops.c 1999/09/26 06:35:10
@@ -510,7 +510,8 @@
iso_dunmap(isomp->im_dev);
#endif
- isomp->im_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (isomp->im_devvp->v_type != VBAD)
+ isomp->im_devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p);
vrele(isomp->im_devvp);
free((caddr_t)isomp, M_ISOFSMNT);
Index: msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.62
diff -u -r1.62 msdosfs_vfsops.c
--- msdosfs_vfsops.c 1999/07/17 01:08:29 1.62
+++ msdosfs_vfsops.c 1999/09/26 06:35:10
@@ -754,7 +754,8 @@
if ((error = vflush(mp, NULLVP, flags)) != 0)
return (error);
pmp = VFSTOMSDOSFS(mp);
- pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (pmp->pm_devvp->v_type != VBAD)
+ pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON;
#ifdef MSDOSFS_DEBUG
{
struct vnode *vp = pmp->pm_devvp;
Index: ntfs/ntfs_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ntfs/ntfs_vfsops.c,v
retrieving revision 1.12
diff -u -r1.12 ntfs_vfsops.c
--- ntfs_vfsops.c 1999/09/13 20:21:45 1.12
+++ ntfs_vfsops.c 1999/09/26 06:35:10
@@ -658,7 +658,8 @@
#if defined(__FreeBSD__)
ntmp->ntm_devvp->v_specmountpoint = NULL;
#else
- ntmp->ntm_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (ntmp->ntm_devvp->v_type != VBAD)
+ ntmp->ntm_devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
#ifndef __NetBSD__
Index: ufs/ext2fs/ext2fs_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/ext2fs/ext2fs_vfsops.c,v
retrieving revision 1.27
diff -u -r1.27 ext2fs_vfsops.c
--- ext2fs_vfsops.c 1999/07/17 01:08:29 1.27
+++ ext2fs_vfsops.c 1999/09/26 06:35:11
@@ -647,7 +647,8 @@
fs->e2fs.e2fs_state = E2FS_ISCLEAN;
(void) ext2fs_sbupdate(ump, MNT_WAIT);
}
- ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (ump->um_devvp->v_type != VBAD)
+ ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(ump->um_devvp, fs->e2fs_ronly ? FREAD : FREAD|FWRITE,
NOCRED, p);
vrele(ump->um_devvp);
Index: ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.52
diff -u -r1.52 ffs_vfsops.c
--- ffs_vfsops.c 1999/08/03 19:22:43 1.52
+++ ffs_vfsops.c 1999/09/26 06:35:11
@@ -690,7 +690,8 @@
fs->fs_clean = FS_ISCLEAN;
(void) ffs_sbupdate(ump, MNT_WAIT);
}
- ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (ump->um_devvp->v_type != VBAD)
+ ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(ump->um_devvp, fs->fs_ronly ? FREAD : FREAD|FWRITE,
NOCRED, p);
vrele(ump->um_devvp);
Index: ufs/lfs/lfs_vfsops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/lfs/lfs_vfsops.c,v
retrieving revision 1.38
diff -u -r1.38 lfs_vfsops.c
--- lfs_vfsops.c 1999/09/08 08:29:45 1.38
+++ lfs_vfsops.c 1999/09/26 06:35:12
@@ -525,7 +525,8 @@
vgone(fs->lfs_ivnode);
ronly = !fs->lfs_ronly;
- ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
+ if (ump->um_devvp->v_type != VBAD)
+ ump->um_devvp->v_specflags &= ~SI_MOUNTEDON;
error = VOP_CLOSE(ump->um_devvp,
ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
vrele(ump->um_devvp);