1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

- Hold a reference from the time vfs_busy starts until vfs_unbusy is

called.
 - vfs_getvfs has to return a reference to prevent the returned mountpoint
   from changing identities.
 - Release references acquired via vfs_getvfs.

Discussed with:	tegge
Tested by:	kris
Sponsored by:	Isilon Systems, Inc.
This commit is contained in:
Jeff Roberson 2006-03-31 03:53:25 +00:00
parent c5fcce21c5
commit 94bc95db3c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157324

View File

@ -362,7 +362,6 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
lkflags = LK_SHARED | LK_INTERLOCK;
if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp), td))
panic("vfs_busy: unexpected lock failure");
vfs_rel(mp);
return (0);
}
@ -374,6 +373,7 @@ vfs_unbusy(struct mount *mp, struct thread *td)
{
lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td);
vfs_rel(mp);
}
/*
@ -388,6 +388,7 @@ vfs_getvfs(fsid_t *fsid)
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
vfs_ref(mp);
mtx_unlock(&mountlist_mtx);
return (mp);
}
@ -428,6 +429,7 @@ void
vfs_getnewfsid(struct mount *mp)
{
static u_int16_t mntid_base;
struct mount *nmp;
fsid_t tfsid;
int mtype;
@ -439,8 +441,9 @@ vfs_getnewfsid(struct mount *mp)
tfsid.val[0] = makedev(255,
mtype | ((mntid_base & 0xFF00) << 8) | (mntid_base & 0xFF));
mntid_base++;
if (vfs_getvfs(&tfsid) == NULL)
if ((nmp = vfs_getvfs(&tfsid)) == NULL)
break;
vfs_rel(nmp);
}
mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
@ -3686,10 +3689,13 @@ sysctl_vfs_ctl(SYSCTL_HANDLER_ARGS)
/* ensure that a specific sysctl goes to the right filesystem. */
if (strcmp(vc.vc_fstypename, "*") != 0 &&
strcmp(vc.vc_fstypename, mp->mnt_vfc->vfc_name) != 0) {
vfs_rel(mp);
return (EINVAL);
}
VCTLTOREQ(&vc, req);
return (VFS_SYSCTL(mp, vc.vc_op, req));
error = VFS_SYSCTL(mp, vc.vc_op, req);
vfs_rel(mp);
return (error);
}
SYSCTL_PROC(_vfs, OID_AUTO, ctl, CTLFLAG_WR,