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:
parent
05a447d0b9
commit
694a586a43
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222167
@ -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_sync(vfs_t *vfsp, int waitfor);
|
||||||
static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp,
|
static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp,
|
||||||
struct ucred **credanonp, int *numsecflavors, int **secflavors);
|
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_objset_close(zfsvfs_t *zfsvfs);
|
||||||
static void zfs_freevfs(vfs_t *vfsp);
|
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));
|
CTASSERT(LONG_FID_LEN <= sizeof(struct fid));
|
||||||
|
|
||||||
static int
|
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;
|
zfsvfs_t *zfsvfs = vfsp->vfs_data;
|
||||||
znode_t *zp;
|
znode_t *zp;
|
||||||
|
@ -586,9 +586,10 @@ cd9660_statfs(mp, sbp)
|
|||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
static int
|
static int
|
||||||
cd9660_fhtovp(mp, fhp, vpp)
|
cd9660_fhtovp(mp, fhp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct fid *fhp;
|
struct fid *fhp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
struct ifid ifh;
|
struct ifid ifh;
|
||||||
|
@ -973,7 +973,7 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
|
|||||||
* those rights via. exflagsp and credanonp
|
* those rights via. exflagsp and credanonp
|
||||||
*/
|
*/
|
||||||
static int
|
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 inode *ip;
|
||||||
struct ufid *ufhp;
|
struct ufid *ufhp;
|
||||||
|
@ -417,6 +417,7 @@ static int
|
|||||||
hpfs_fhtovp(
|
hpfs_fhtovp(
|
||||||
struct mount *mp,
|
struct mount *mp,
|
||||||
struct fid *fhp,
|
struct fid *fhp,
|
||||||
|
int flags,
|
||||||
struct vnode **vpp)
|
struct vnode **vpp)
|
||||||
{
|
{
|
||||||
struct vnode *nvp;
|
struct vnode *nvp;
|
||||||
|
@ -963,7 +963,7 @@ msdosfs_sync(struct mount *mp, int waitfor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 msdosfsmount *pmp = VFSTOMSDOSFS(mp);
|
||||||
struct defid *defhp = (struct defid *) fhp;
|
struct defid *defhp = (struct defid *) fhp;
|
||||||
|
@ -2551,7 +2551,7 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct sockaddr *nam,
|
|||||||
if (VFS_NEEDSGIANT(mp))
|
if (VFS_NEEDSGIANT(mp))
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
else
|
else
|
||||||
error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
|
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
/* Make sure the server replies ESTALE to the client. */
|
/* Make sure the server replies ESTALE to the client. */
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
@ -2834,7 +2834,7 @@ nfsvno_getvp(fhandle_t *fhp)
|
|||||||
mp = vfs_busyfs(&fhp->fh_fsid);
|
mp = vfs_busyfs(&fhp->fh_fsid);
|
||||||
if (mp == NULL)
|
if (mp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
error = VFS_FHTOVP(mp, &fhp->fh_fid, &vp);
|
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, &vp);
|
||||||
vfs_unbusy(mp);
|
vfs_unbusy(mp);
|
||||||
if (error)
|
if (error)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -616,6 +616,7 @@ static int
|
|||||||
ntfs_fhtovp(
|
ntfs_fhtovp(
|
||||||
struct mount *mp,
|
struct mount *mp,
|
||||||
struct fid *fhp,
|
struct fid *fhp,
|
||||||
|
int flags,
|
||||||
struct vnode **vpp)
|
struct vnode **vpp)
|
||||||
{
|
{
|
||||||
struct vnode *nvp;
|
struct vnode *nvp;
|
||||||
|
@ -321,13 +321,15 @@ nullfs_vget(mp, ino, flags, vpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nullfs_fhtovp(mp, fidp, vpp)
|
nullfs_fhtovp(mp, fidp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct fid *fidp;
|
struct fid *fidp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, vpp);
|
error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, LK_EXCLUSIVE,
|
||||||
|
vpp);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names");
|
|||||||
static int tmpfs_mount(struct mount *);
|
static int tmpfs_mount(struct mount *);
|
||||||
static int tmpfs_unmount(struct mount *, int);
|
static int tmpfs_unmount(struct mount *, int);
|
||||||
static int tmpfs_root(struct mount *, int flags, struct vnode **);
|
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 *);
|
static int tmpfs_statfs(struct mount *, struct statfs *);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@ -341,7 +342,8 @@ tmpfs_root(struct mount *mp, int flags, struct vnode **vpp)
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
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;
|
boolean_t found;
|
||||||
struct tmpfs_fid *tfhp;
|
struct tmpfs_fid *tfhp;
|
||||||
|
@ -722,7 +722,7 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 ifid *ifhp;
|
||||||
struct vnode *nvp;
|
struct vnode *nvp;
|
||||||
|
@ -454,7 +454,8 @@ unionfs_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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);
|
return (EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,8 @@ reiserfs_statfs(struct mount *mp, struct statfs *sbp)
|
|||||||
* those rights via. exflagsp and credanonp
|
* those rights via. exflagsp and credanonp
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
int error;
|
||||||
struct rfid *rfhp;
|
struct rfid *rfhp;
|
||||||
|
@ -370,9 +370,10 @@ _xfs_vget(mp, ino, flags, vpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_xfs_fhtovp(mp, fidp, vpp)
|
_xfs_fhtovp(mp, fidp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct fid *fidp;
|
struct fid *fidp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
printf("xfs_fhtovp\n");
|
printf("xfs_fhtovp\n");
|
||||||
|
@ -1081,9 +1081,10 @@ vfs_stdvget (mp, ino, flags, vpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vfs_stdfhtovp (mp, fhp, vpp)
|
vfs_stdfhtovp (mp, fhp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct fid *fhp;
|
struct fid *fhp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -4405,7 +4405,7 @@ fhopen(td, uap)
|
|||||||
return (ESTALE);
|
return (ESTALE);
|
||||||
vfslocked = VFS_LOCK_GIANT(mp);
|
vfslocked = VFS_LOCK_GIANT(mp);
|
||||||
/* now give me my vnode, it gets returned to me locked */
|
/* 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);
|
vfs_unbusy(mp);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
@ -4581,7 +4581,7 @@ fhstat(td, uap)
|
|||||||
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
|
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
|
||||||
return (ESTALE);
|
return (ESTALE);
|
||||||
vfslocked = VFS_LOCK_GIANT(mp);
|
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);
|
vfs_unbusy(mp);
|
||||||
if (error) {
|
if (error) {
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
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)
|
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
|
||||||
return (ESTALE);
|
return (ESTALE);
|
||||||
vfslocked = VFS_LOCK_GIANT(mp);
|
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) {
|
if (error) {
|
||||||
vfs_unbusy(mp);
|
vfs_unbusy(mp);
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
|
@ -1128,7 +1128,7 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
|
error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp);
|
||||||
if (error) {
|
if (error) {
|
||||||
/* Make sure the server replies ESTALE to the client. */
|
/* Make sure the server replies ESTALE to the client. */
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
|
@ -1797,7 +1797,7 @@ nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp,
|
|||||||
goto out;
|
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)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
vs->vs_vnlocked = TRUE;
|
vs->vs_vnlocked = TRUE;
|
||||||
|
@ -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_sync_t(struct mount *mp, int waitfor);
|
||||||
typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags,
|
typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags,
|
||||||
struct vnode **vpp);
|
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,
|
typedef int vfs_checkexp_t(struct mount *mp, struct sockaddr *nam,
|
||||||
int *extflagsp, struct ucred **credanonp,
|
int *extflagsp, struct ucred **credanonp,
|
||||||
int *numsecflavors, int **secflavors);
|
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_SYNC(MP, WAIT) (*(MP)->mnt_op->vfs_sync)(MP, WAIT)
|
||||||
#define VFS_VGET(MP, INO, FLAGS, VPP) \
|
#define VFS_VGET(MP, INO, FLAGS, VPP) \
|
||||||
(*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP)
|
(*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP)
|
||||||
#define VFS_FHTOVP(MP, FIDP, VPP) \
|
#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) \
|
||||||
(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
|
(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP)
|
||||||
#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) \
|
#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) \
|
||||||
(*(MP)->mnt_op->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) \
|
#define VFS_EXTATTRCTL(MP, C, FN, NS, N) \
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
* in the range 5 to 9.
|
* in the range 5 to 9.
|
||||||
*/
|
*/
|
||||||
#undef __FreeBSD_version
|
#undef __FreeBSD_version
|
||||||
#define __FreeBSD_version 900037 /* Master, propagated to newvers */
|
#define __FreeBSD_version 900038 /* Master, propagated to newvers */
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
#define P_OSREL_SIGSEGV 700004
|
#define P_OSREL_SIGSEGV 700004
|
||||||
|
@ -1640,9 +1640,10 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
|
|||||||
* those rights via. exflagsp and credanonp
|
* those rights via. exflagsp and credanonp
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ffs_fhtovp(mp, fhp, vpp)
|
ffs_fhtovp(mp, fhp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct fid *fhp;
|
struct fid *fhp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
struct ufid *ufhp;
|
struct ufid *ufhp;
|
||||||
@ -1653,7 +1654,7 @@ ffs_fhtovp(mp, fhp, vpp)
|
|||||||
if (ufhp->ufid_ino < ROOTINO ||
|
if (ufhp->ufid_ino < ROOTINO ||
|
||||||
ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
|
ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
|
||||||
return (ESTALE);
|
return (ESTALE);
|
||||||
return (ufs_fhtovp(mp, ufhp, vpp));
|
return (ufs_fhtovp(mp, ufhp, flags, vpp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,7 +56,7 @@ extern struct vop_vector ufs_vnodeops;
|
|||||||
int ufs_bmap(struct vop_bmap_args *);
|
int ufs_bmap(struct vop_bmap_args *);
|
||||||
int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *,
|
int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *,
|
||||||
struct buf *, int *, int *);
|
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 *);
|
int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);
|
||||||
void ufs_dirbad(struct inode *, doff_t, char *);
|
void ufs_dirbad(struct inode *, doff_t, char *);
|
||||||
int ufs_dirbadentry(struct vnode *, struct direct *, int);
|
int ufs_dirbadentry(struct vnode *, struct direct *, int);
|
||||||
|
@ -208,9 +208,10 @@ ufs_uninit(vfsp)
|
|||||||
* Call the VFS_CHECKEXP beforehand to verify access.
|
* Call the VFS_CHECKEXP beforehand to verify access.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ufs_fhtovp(mp, ufhp, vpp)
|
ufs_fhtovp(mp, ufhp, flags, vpp)
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct ufid *ufhp;
|
struct ufid *ufhp;
|
||||||
|
int flags;
|
||||||
struct vnode **vpp;
|
struct vnode **vpp;
|
||||||
{
|
{
|
||||||
struct inode *ip;
|
struct inode *ip;
|
||||||
|
Loading…
Reference in New Issue
Block a user