From 09400d5abe7b07993d6e778050891a31b9dc0915 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 21 Jul 2008 23:01:09 +0000 Subject: - Disallow XFS mounting in write mode. The write support never worked really and there is no need to maintain it. - Fix vn_get() in order to let it call vget(9) with a valid locking request. vget(9) returns the vnode locked in order to prevent recycling, but in this case internal XFS locks alredy prevent it from happening, so it is safe to drop the vnode lock before to return by vn_get(). - Add a VNASSERT() in vget(9) in order to catch malformed locking requests. Discussed with: kan, kib Tested by: Lothar Braun --- sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c | 2 ++ sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c | 15 ++++++++++----- sys/kern/vfs_subr.c | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c index 244ad3099e84..ea815b21e74e 100644 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c +++ b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c @@ -199,6 +199,8 @@ _xfs_mount(struct mount *mp, if (mp->mnt_flag & MNT_UPDATE) return (0); + if ((mp->mnt_flag & MNT_RDONLY) == 0) + return (EPERM); xmp = xfsmount_allocate(mp); if (xmp == NULL) diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c b/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c index 8e2b1f97274a..3b3f3e5b4916 100644 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c +++ b/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c @@ -104,13 +104,18 @@ vn_get( vp = vmap->v_vp; - error = vget(vp, 0, curthread); - if (error) { - vdrop(vp); + error = vget(vp, LK_EXCLUSIVE, curthread); + vdrop(vp); + if (error) return (NULL); - } - vdrop(vp); + /* + * Drop the vnode returned by vget here. + * VOP_RECLAIM(9) should block on internal XFS locks so that + * the reclaiming scheme still remains consistent even if the + * vp is not locked. + */ + VOP_UNLOCK(vp, 0); if (vp->v_data != xfs_vp) { vput(vp); return (NULL); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2e7f52b75983..16fa8e4137c2 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2038,6 +2038,8 @@ vget(struct vnode *vp, int flags, struct thread *td) error = 0; VFS_ASSERT_GIANT(vp->v_mount); + VNASSERT((flags & LK_TYPE_MASK) != 0, vp, + ("vget: invalid lock operation")); if ((flags & LK_INTERLOCK) == 0) VI_LOCK(vp); vholdl(vp); -- cgit v1.2.3