Add a lock flags argument to the VFS_FHTOVP() file system

method, so that callers can indicate the minimum vnode
locking requirement. This will allow some file systems to choose
to return a LK_SHARED locked vnode when LK_SHARED is specified
for the flags argument. This patch only adds the flag. It
does not change any file system to use it and all callers
specify LK_EXCLUSIVE, so file system semantics are not changed.

Reviewed by:	kib
This commit is contained in:
Rick Macklem 2011-05-22 01:07:54 +00:00
parent 05a447d0b9
commit 694a586a43
22 changed files with 43 additions and 29 deletions

View File

@ -93,7 +93,7 @@ static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp);
static int zfs_sync(vfs_t *vfsp, int waitfor);
static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp,
struct ucred **credanonp, int *numsecflavors, int **secflavors);
static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp);
static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp);
static void zfs_objset_close(zfsvfs_t *zfsvfs);
static void zfs_freevfs(vfs_t *vfsp);
@ -2007,7 +2007,7 @@ CTASSERT(SHORT_FID_LEN <= sizeof(struct fid));
CTASSERT(LONG_FID_LEN <= sizeof(struct fid));
static int
zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp)
zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp)
{
zfsvfs_t *zfsvfs = vfsp->vfs_data;
znode_t *zp;

View File

@ -586,9 +586,10 @@ cd9660_statfs(mp, sbp)
/* ARGSUSED */
static int
cd9660_fhtovp(mp, fhp, vpp)
cd9660_fhtovp(mp, fhp, flags, vpp)
struct mount *mp;
struct fid *fhp;
int flags;
struct vnode **vpp;
{
struct ifid ifh;

View File

@ -973,7 +973,7 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
* those rights via. exflagsp and credanonp
*/
static int
ext2_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
ext2_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
{
struct inode *ip;
struct ufid *ufhp;

View File

@ -417,6 +417,7 @@ static int
hpfs_fhtovp(
struct mount *mp,
struct fid *fhp,
int flags,
struct vnode **vpp)
{
struct vnode *nvp;

View File

@ -963,7 +963,7 @@ msdosfs_sync(struct mount *mp, int waitfor)
}
static int
msdosfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
{
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
struct defid *defhp = (struct defid *) fhp;

View File

@ -2551,7 +2551,7 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct sockaddr *nam,
if (VFS_NEEDSGIANT(mp))
error = ESTALE;
else
error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp);
if (error != 0)
/* Make sure the server replies ESTALE to the client. */
error = ESTALE;
@ -2834,7 +2834,7 @@ nfsvno_getvp(fhandle_t *fhp)
mp = vfs_busyfs(&fhp->fh_fsid);
if (mp == NULL)
return (NULL);
error = VFS_FHTOVP(mp, &fhp->fh_fid, &vp);
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, &vp);
vfs_unbusy(mp);
if (error)
return (NULL);

View File

@ -616,6 +616,7 @@ static int
ntfs_fhtovp(
struct mount *mp,
struct fid *fhp,
int flags,
struct vnode **vpp)
{
struct vnode *nvp;

View File

@ -321,13 +321,15 @@ nullfs_vget(mp, ino, flags, vpp)
}
static int
nullfs_fhtovp(mp, fidp, vpp)
nullfs_fhtovp(mp, fidp, flags, vpp)
struct mount *mp;
struct fid *fidp;
int flags;
struct vnode **vpp;
{
int error;
error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, vpp);
error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, LK_EXCLUSIVE,
vpp);
if (error)
return (error);

View File

@ -71,7 +71,8 @@ MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names");
static int tmpfs_mount(struct mount *);
static int tmpfs_unmount(struct mount *, int);
static int tmpfs_root(struct mount *, int flags, struct vnode **);
static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **);
static int tmpfs_fhtovp(struct mount *, struct fid *, int,
struct vnode **);
static int tmpfs_statfs(struct mount *, struct statfs *);
/* --------------------------------------------------------------------- */
@ -341,7 +342,8 @@ tmpfs_root(struct mount *mp, int flags, struct vnode **vpp)
/* --------------------------------------------------------------------- */
static int
tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags,
struct vnode **vpp)
{
boolean_t found;
struct tmpfs_fid *tfhp;

View File

@ -722,7 +722,7 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
}
static int
udf_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
udf_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
{
struct ifid *ifhp;
struct vnode *nvp;

View File

@ -454,7 +454,8 @@ unionfs_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
}
static int
unionfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp)
unionfs_fhtovp(struct mount *mp, struct fid *fidp, int flags,
struct vnode **vpp)
{
return (EOPNOTSUPP);
}

View File

@ -335,7 +335,8 @@ reiserfs_statfs(struct mount *mp, struct statfs *sbp)
* those rights via. exflagsp and credanonp
*/
static int
reiserfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
reiserfs_fhtovp(struct mount *mp, struct fid *fhp, int flags,
struct vnode **vpp)
{
int error;
struct rfid *rfhp;

View File

@ -370,9 +370,10 @@ _xfs_vget(mp, ino, flags, vpp)
}
static int
_xfs_fhtovp(mp, fidp, vpp)
_xfs_fhtovp(mp, fidp, flags, vpp)
struct mount *mp;
struct fid *fidp;
int flags;
struct vnode **vpp;
{
printf("xfs_fhtovp\n");

View File

@ -1081,9 +1081,10 @@ vfs_stdvget (mp, ino, flags, vpp)
}
int
vfs_stdfhtovp (mp, fhp, vpp)
vfs_stdfhtovp (mp, fhp, flags, vpp)
struct mount *mp;
struct fid *fhp;
int flags;
struct vnode **vpp;
{

View File

@ -4405,7 +4405,7 @@ fhopen(td, uap)
return (ESTALE);
vfslocked = VFS_LOCK_GIANT(mp);
/* now give me my vnode, it gets returned to me locked */
error = VFS_FHTOVP(mp, &fhp.fh_fid, &vp);
error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp);
vfs_unbusy(mp);
if (error)
goto out;
@ -4581,7 +4581,7 @@ fhstat(td, uap)
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
return (ESTALE);
vfslocked = VFS_LOCK_GIANT(mp);
error = VFS_FHTOVP(mp, &fh.fh_fid, &vp);
error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
vfs_unbusy(mp);
if (error) {
VFS_UNLOCK_GIANT(vfslocked);
@ -4641,7 +4641,7 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf)
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
return (ESTALE);
vfslocked = VFS_LOCK_GIANT(mp);
error = VFS_FHTOVP(mp, &fh.fh_fid, &vp);
error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
if (error) {
vfs_unbusy(mp);
VFS_UNLOCK_GIANT(vfslocked);

View File

@ -1128,7 +1128,7 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
goto out;
}
}
error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp);
if (error) {
/* Make sure the server replies ESTALE to the client. */
error = ESTALE;

View File

@ -1797,7 +1797,7 @@ nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp,
goto out;
}
error = VFS_FHTOVP(vs->vs_mp, &fhp->fh_fid, &vs->vs_vp);
error = VFS_FHTOVP(vs->vs_mp, &fhp->fh_fid, LK_EXCLUSIVE, &vs->vs_vp);
if (error)
goto out;
vs->vs_vnlocked = TRUE;

View File

@ -566,7 +566,8 @@ typedef int vfs_statfs_t(struct mount *mp, struct statfs *sbp);
typedef int vfs_sync_t(struct mount *mp, int waitfor);
typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags,
struct vnode **vpp);
typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp, struct vnode **vpp);
typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp,
int flags, struct vnode **vpp);
typedef int vfs_checkexp_t(struct mount *mp, struct sockaddr *nam,
int *extflagsp, struct ucred **credanonp,
int *numsecflavors, int **secflavors);
@ -610,8 +611,8 @@ vfs_statfs_t __vfs_statfs;
#define VFS_SYNC(MP, WAIT) (*(MP)->mnt_op->vfs_sync)(MP, WAIT)
#define VFS_VGET(MP, INO, FLAGS, VPP) \
(*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP)
#define VFS_FHTOVP(MP, FIDP, VPP) \
(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) \
(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP)
#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) \
(*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED, NUMSEC, SEC)
#define VFS_EXTATTRCTL(MP, C, FN, NS, N) \

View File

@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 900037 /* Master, propagated to newvers */
#define __FreeBSD_version 900038 /* Master, propagated to newvers */
#ifdef _KERNEL
#define P_OSREL_SIGSEGV 700004

View File

@ -1640,9 +1640,10 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
* those rights via. exflagsp and credanonp
*/
static int
ffs_fhtovp(mp, fhp, vpp)
ffs_fhtovp(mp, fhp, flags, vpp)
struct mount *mp;
struct fid *fhp;
int flags;
struct vnode **vpp;
{
struct ufid *ufhp;
@ -1653,7 +1654,7 @@ ffs_fhtovp(mp, fhp, vpp)
if (ufhp->ufid_ino < ROOTINO ||
ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
return (ESTALE);
return (ufs_fhtovp(mp, ufhp, vpp));
return (ufs_fhtovp(mp, ufhp, flags, vpp));
}
/*

View File

@ -56,7 +56,7 @@ extern struct vop_vector ufs_vnodeops;
int ufs_bmap(struct vop_bmap_args *);
int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *,
struct buf *, int *, int *);
int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **);
int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **);
int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);
void ufs_dirbad(struct inode *, doff_t, char *);
int ufs_dirbadentry(struct vnode *, struct direct *, int);

View File

@ -208,9 +208,10 @@ ufs_uninit(vfsp)
* Call the VFS_CHECKEXP beforehand to verify access.
*/
int
ufs_fhtovp(mp, ufhp, vpp)
ufs_fhtovp(mp, ufhp, flags, vpp)
struct mount *mp;
struct ufid *ufhp;
int flags;
struct vnode **vpp;
{
struct inode *ip;