1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-09 02:26:27 +00:00

Provide the mutual exclusion between the nfs export list modifications

and nfs requests processing. Lockmgr lock provides the shared locking for
nfs requests, while exclusive mode is used for modifications. The writer
starvation is handled by lockmgr too.

Reported by:	kris, pho, many
Based on the submission by:	mohan
Tested by:	pho
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2008-06-09 10:31:38 +00:00
parent e911e766b1
commit a70537835f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179670
3 changed files with 7 additions and 0 deletions

View File

@ -255,6 +255,7 @@ vfs_export(struct mount *mp, struct export_args *argp)
nep = mp->mnt_export;
error = 0;
lockmgr(&mp->mnt_explock, LK_EXCLUSIVE, NULL);
if (argp->ex_flags & MNT_DELEXPORT) {
if (nep == NULL) {
error = ENOENT;
@ -294,6 +295,7 @@ vfs_export(struct mount *mp, struct export_args *argp)
}
out:
lockmgr(&mp->mnt_explock, LK_RELEASE, NULL);
/*
* Once we have executed the vfs_export() command, we do
* not want to keep the "export" option around in the
@ -443,7 +445,9 @@ vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp,
{
struct netcred *np;
lockmgr(&mp->mnt_explock, LK_SHARED, NULL);
np = vfs_export_lookup(mp, nam);
lockmgr(&mp->mnt_explock, LK_RELEASE, NULL);
if (np == NULL)
return (EACCES);
*extflagsp = np->netc_exflags;

View File

@ -452,6 +452,7 @@ mount_init(void *mem, int size, int flags)
mp = (struct mount *)mem;
mtx_init(&mp->mnt_mtx, "struct mount mtx", NULL, MTX_DEF);
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, 0);
lockinit(&mp->mnt_explock, PVFS, "explock", 0, 0);
return (0);
}
@ -461,6 +462,7 @@ mount_fini(void *mem, int size)
struct mount *mp;
mp = (struct mount *)mem;
lockdestroy(&mp->mnt_explock);
lockdestroy(&mp->mnt_lock);
mtx_destroy(&mp->mnt_mtx);
}

View File

@ -182,6 +182,7 @@ struct mount {
int mnt_secondary_accwrites;/* (i) secondary wr. starts */
#define mnt_endzero mnt_gjprovider
char *mnt_gjprovider; /* gjournal provider name */
struct lock mnt_explock; /* vfs_export walkers lock */
};
struct vnode *__mnt_vnode_next(struct vnode **mvp, struct mount *mp);