tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Move the vnode lock into file systems



On Tue, Jun 29, 2010 at 04:54:46PM +0200, Juergen Hannken-Illjes wrote:
> On Sat, Jun 26, 2010 at 10:39:27AM +0200, Juergen Hannken-Illjes wrote:
> > The vnode lock operations currently work on a rw lock located inside the
> > vnode.  I propose to move this lock into the file system node.
> > 
> > This place is more logical as we lock a file system node and not a vnode.
> > This becomes clear if we think of a file system where one file system node
> > is attached to more than one vnode.  Ptyfs allowing multiple mounts is such
> > a candidate.
> > 
> > A diff implemeting this for ufs, lfs and ext2fs is attached.
> > 
> > Comments or objections anyone?
> 
> Looks like the minimal consensus for now is to remove the vlockmgr().
> The attached diff does it and rearranges vnode locking (in the genfs case)
> into the functions genfs_lock(), genfs_unlock() and genfs_islocked().
> The lock itself goes into the vnode and the remaining LK_* flags move
> from sys/lock.h to sys/vnode.h.  All in-file system calls to vlockmgr()
> get replaced with VOP_LOCK() or VOP_UNLOCK().
> 
> Comments or objections anyone?

I think, if I was doing this, I'd look at putting the lock into genfs_node,
and directly into the in-core inode for file systems that don't make use
of genfs.

Not sure what advantage there is to converting in-FS vlockmgr() calls over
to VOP_LOCK/VOP_UNLOCK.

(Then kill the in-vnode lock completely and take a critical look
at the fields in the vnode that are protected by the vnode lock.  I know
of at least a couple of external places that have implicit dependencies
on the vnode lock, example the namecache.)

> 
> -- 
> Juergen Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig 
> (Germany)
> 
> Index: sys/coda/coda_vnops.c
> ===================================================================
> RCS file: /cvsroot/src/sys/coda/coda_vnops.c,v
> retrieving revision 1.74
> diff -p -u -4 -r1.74 coda_vnops.c
> --- sys/coda/coda_vnops.c     24 Jun 2010 13:03:06 -0000      1.74
> +++ sys/coda/coda_vnops.c     29 Jun 2010 10:27:29 -0000
> @@ -1774,9 +1774,8 @@ coda_lock(void *v)
>  /* true args */
>      struct vop_lock_args *ap = v;
>      struct vnode *vp = ap->a_vp;
>      struct cnode *cp = VTOC(vp);
> -    int flags  = ap->a_flags;
>  /* upcall decl */
>  /* locals */
>  
>      ENTRY;
> @@ -1785,9 +1784,9 @@ coda_lock(void *v)
>       myprintf(("Attempting lock on %s\n",
>                 coda_f2s(&cp->c_fid)));
>      }
>  
> -    return (vlockmgr(&vp->v_lock, flags));
> +    return genfs_lock(v);
>  }
>  
>  int
>  coda_unlock(void *v)
> @@ -1804,19 +1803,18 @@ coda_unlock(void *v)
>       myprintf(("Attempting unlock on %s\n",
>                 coda_f2s(&cp->c_fid)));
>      }
>  
> -    return (vlockmgr(&vp->v_lock, LK_RELEASE));
> +    return genfs_unlock(v);
>  }
>  
>  int
>  coda_islocked(void *v)
>  {
>  /* true args */
> -    struct vop_islocked_args *ap = v;
>      ENTRY;
>  
> -    return (vlockstatus(&ap->a_vp->v_lock));
> +    return genfs_islocked(v);
>  }
>  
>  /*
>   * Given a device and inode, obtain a locked vnode.  One reference is
> Index: sys/fs/adosfs/adutil.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/adosfs/adutil.c,v
> retrieving revision 1.11
> diff -p -u -4 -r1.11 adutil.c
> --- sys/fs/adosfs/adutil.c    14 Mar 2009 21:04:23 -0000      1.11
> +++ sys/fs/adosfs/adutil.c    29 Jun 2010 10:27:31 -0000
> @@ -86,9 +86,9 @@ start_over:
>   */
>  void
>  adosfs_ainshash(struct adosfsmount *amp, struct anode *ap)
>  {
> -     vlockmgr(&ap->vp->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(ATOV(ap), LK_EXCLUSIVE);
>  
>       simple_lock(&adosfs_hashlock);
>       LIST_INSERT_HEAD(&amp->anodetab[AHASH(ap->block)], ap, link);
>       simple_unlock(&adosfs_hashlock);
> Index: sys/fs/cd9660/cd9660_node.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/cd9660/cd9660_node.c,v
> retrieving revision 1.25
> diff -p -u -4 -r1.25 cd9660_node.c
> --- sys/fs/cd9660/cd9660_node.c       24 Jun 2010 13:03:09 -0000      1.25
> +++ sys/fs/cd9660/cd9660_node.c       29 Jun 2010 10:27:31 -0000
> @@ -177,9 +177,9 @@ cd9660_ihashins(struct iso_node *ip)
>       ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
>       LIST_INSERT_HEAD(ipp, ip, i_hash);
>       mutex_exit(&cd9660_ihash_lock);
>  
> -     vlockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(ITOV(ip), LK_EXCLUSIVE);
>  }
>  
>  /*
>   * Remove the inode from the hash table.
> Index: sys/fs/efs/efs_ihash.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/efs/efs_ihash.c,v
> retrieving revision 1.4
> diff -p -u -4 -r1.4 efs_ihash.c
> --- sys/fs/efs/efs_ihash.c    5 May 2008 17:11:16 -0000       1.4
> +++ sys/fs/efs/efs_ihash.c    29 Jun 2010 10:27:31 -0000
> @@ -166,9 +166,9 @@ efs_ihashins(struct efs_inode *eip)
>  
>       KASSERT(mutex_owned(&efs_hashlock));
>  
>       /* lock the inode, then put it on the appropriate hash list */
> -     vlockmgr(&eip->ei_vp->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(EFS_ITOV(eip), LK_EXCLUSIVE);
>  
>       mutex_enter(&efs_ihash_lock);
>       ipp = &ihashtbl[INOHASH(eip->ei_dev, eip->ei_number)];
>       LIST_INSERT_HEAD(ipp, eip, ei_hash);
> Index: sys/fs/filecorefs/filecore_node.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/filecorefs/filecore_node.c,v
> retrieving revision 1.20
> diff -p -u -4 -r1.20 filecore_node.c
> --- sys/fs/filecorefs/filecore_node.c 24 Jun 2010 13:03:09 -0000      1.20
> +++ sys/fs/filecorefs/filecore_node.c 29 Jun 2010 10:27:31 -0000
> @@ -189,17 +189,15 @@ loop:
>  void
>  filecore_ihashins(struct filecore_node *ip)
>  {
>       struct ihashhead *ipp;
> -     struct vnode *vp;
>  
>       simple_lock(&filecore_ihash_slock);
>       ipp = &filecorehashtbl[INOHASH(ip->i_dev, ip->i_number)];
>       LIST_INSERT_HEAD(ipp, ip, i_hash);
>       simple_unlock(&filecore_ihash_slock);
>  
> -     vp = ip->i_vnode;
> -     vlockmgr(&vp->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(ITOV(ip), LK_EXCLUSIVE);
>  }
>  
>  /*
>   * Remove the inode from the hash table.
> Index: sys/fs/hfs/hfs_nhash.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/hfs/hfs_nhash.c,v
> retrieving revision 1.9
> diff -p -u -4 -r1.9 hfs_nhash.c
> --- sys/fs/hfs/hfs_nhash.c    3 Sep 2008 22:57:46 -0000       1.9
> +++ sys/fs/hfs/hfs_nhash.c    29 Jun 2010 10:27:31 -0000
> @@ -149,9 +149,9 @@ hfs_nhashinsert(struct hfsnode *hp)
>  {
>       struct nhashhead *hpp;
>  
>       /* lock the inode, then put it on the appropriate hash list */
> -     vlockmgr(&hp->h_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(HTOV(hp), LK_EXCLUSIVE);
>  
>       mutex_enter(&hfs_nhash_lock);
>       hpp = &nhashtbl[HNOHASH(hp->h_dev, hp->h_rec.u.cnid, hp->h_fork)];
>       LIST_INSERT_HEAD(hpp, hp, h_hash);
> Index: sys/fs/ntfs/ntfs_vfsops.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/ntfs/ntfs_vfsops.c,v
> retrieving revision 1.81
> diff -p -u -4 -r1.81 ntfs_vfsops.c
> --- sys/fs/ntfs/ntfs_vfsops.c 24 Jun 2010 13:03:10 -0000      1.81
> +++ sys/fs/ntfs/ntfs_vfsops.c 29 Jun 2010 10:27:31 -0000
> @@ -806,9 +806,9 @@ ntfs_vgetex(
>  
>       if (ino == NTFS_ROOTINO)
>               vp->v_vflag |= VV_ROOT;
>  
> -     if (lkflags & LK_TYPE_MASK) {
> +     if (lkflags & (LK_EXCLUSIVE | LK_SHARED)) {
>               error = vn_lock(vp, lkflags);
>               if (error) {
>                       vput(vp);
>                       return (error);
> Index: sys/fs/ptyfs/ptyfs_subr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/ptyfs/ptyfs_subr.c,v
> retrieving revision 1.19
> diff -p -u -4 -r1.19 ptyfs_subr.c
> --- sys/fs/ptyfs/ptyfs_subr.c 24 Jun 2010 13:03:10 -0000      1.19
> +++ sys/fs/ptyfs/ptyfs_subr.c 29 Jun 2010 10:27:31 -0000
> @@ -387,9 +387,9 @@ ptyfs_hashins(struct ptyfsnode *pp)
>  {
>       struct ptyfs_hashhead *ppp;
>  
>       /* lock the ptyfsnode, then put it on the appropriate hash list */
> -     vlockmgr(&pp->ptyfs_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(PTYFSTOV(pp), LK_EXCLUSIVE);
>  
>       mutex_enter(&ptyfs_used_slock);
>       ppp = &ptyfs_used_tbl[PTYHASH(pp->ptyfs_type, pp->ptyfs_pty,
>           ptyfs_used_mask)];
> Index: sys/fs/udf/udf_subr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/udf/udf_subr.c,v
> retrieving revision 1.105
> diff -p -u -4 -r1.105 udf_subr.c
> --- sys/fs/udf/udf_subr.c     6 Jun 2010 08:01:31 -0000       1.105
> +++ sys/fs/udf/udf_subr.c     29 Jun 2010 10:27:32 -0000
> @@ -5451,9 +5451,9 @@ udf_get_node(struct udf_mount *ump, stru
>               DPRINTF(NODE, ("\tnode fe/efe failed!\n"));
>               /* recycle udf_node */
>               udf_dispose_node(udf_node);
>  
> -             vlockmgr(&nvp->v_lock, LK_RELEASE);
> +             VOP_UNLOCK(nvp);
>               nvp->v_data = NULL;
>               ungetnewvnode(nvp);
>  
>               return EINVAL;          /* error code ok? */
> @@ -5547,9 +5547,9 @@ udf_get_node(struct udf_mount *ump, stru
>       if (error) {
>               /* recycle udf_node */
>               udf_dispose_node(udf_node);
>  
> -             vlockmgr(&nvp->v_lock, LK_RELEASE);
> +             VOP_UNLOCK(nvp);
>               nvp->v_data = NULL;
>               ungetnewvnode(nvp);
>  
>               return EINVAL;          /* error code ok? */
> @@ -5882,9 +5882,9 @@ udf_create_node_raw(struct vnode *dvp, s
>  error_out_unreserve:
>       udf_do_unreserve_space(ump, NULL, vpart_num, 1);
>  
>  error_out_unlock:
> -     vlockmgr(&nvp->v_lock, LK_RELEASE);
> +     VOP_UNLOCK(nvp);
>  
>  error_out_unget:
>       nvp->v_data = NULL;
>       ungetnewvnode(nvp);
> Index: sys/fs/union/union_vnops.c
> ===================================================================
> RCS file: /cvsroot/src/sys/fs/union/union_vnops.c,v
> retrieving revision 1.36
> diff -p -u -4 -r1.36 union_vnops.c
> --- sys/fs/union/union_vnops.c        24 Jun 2010 13:03:11 -0000      1.36
> +++ sys/fs/union/union_vnops.c        29 Jun 2010 10:27:32 -0000
> @@ -1625,10 +1625,10 @@ union_lock(void *v)
>       struct union_node *un;
>       int error;
>  
>       /* XXX unionfs can't handle shared locks yet */
> -     if ((flags & LK_TYPE_MASK) == LK_SHARED) {
> -             flags = LK_EXCLUSIVE | (flags & ~LK_TYPE_MASK);
> +     if ((flags & LK_SHARED) != 0) {
> +             flags = (flags & ~LK_SHARED) | LK_EXCLUSIVE;
>       }
>  
>       genfs_nolock(ap);
>       /*
> Index: sys/kern/vfs_subr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
> retrieving revision 1.407
> diff -p -u -4 -r1.407 vfs_subr.c
> --- sys/kern/vfs_subr.c       24 Jun 2010 13:03:12 -0000      1.407
> +++ sys/kern/vfs_subr.c       29 Jun 2010 10:27:33 -0000
> @@ -712,9 +712,9 @@ vnalloc(struct mount *mp)
>               vp->v_mount = mp;
>               vp->v_type = VBAD;
>               vp->v_iflag = VI_MARKER;
>       } else {
> -             rw_init(&vp->v_lock.vl_lock);
> +             rw_init(&vp->v_lock);
>       }
>  
>       return vp;
>  }
> @@ -728,9 +728,9 @@ vnfree(vnode_t *vp)
>  
>       KASSERT(vp->v_usecount == 0);
>  
>       if ((vp->v_iflag & VI_MARKER) == 0) {
> -             rw_destroy(&vp->v_lock.vl_lock);
> +             rw_destroy(&vp->v_lock);
>               mutex_enter(&vnode_free_list_lock);
>               numvnodes--;
>               mutex_exit(&vnode_free_list_lock);
>       }
> @@ -1331,9 +1331,9 @@ vget(vnode_t *vp, int flags)
>       /*
>        * Ok, we got it in good shape.  Just locking left.
>        */
>       KASSERT((vp->v_iflag & VI_CLEAN) == 0);
> -     if (flags & LK_TYPE_MASK) {
> +     if (flags & (LK_EXCLUSIVE | LK_SHARED)) {
>               error = vn_lock(vp, flags | LK_INTERLOCK);
>               if (error != 0) {
>                       vrele(vp);
>               }
> @@ -2719,13 +2719,11 @@ const char vnode_flagbits[] = VNODE_FLAG
>   */
>  void
>  vprint(const char *label, struct vnode *vp)
>  {
> -     struct vnlock *vl;
>       char bf[96];
>       int flag;
>  
> -     vl = &vp->v_lock;
>       flag = vp->v_iflag | vp->v_vflag | vp->v_uflag;
>       snprintb(bf, sizeof(bf), vnode_flagbits, flag);
>  
>       if (label != NULL)
> @@ -2735,9 +2733,9 @@ vprint(const char *label, struct vnode *
>           "\tfreelisthd %p, mount %p, data %p lock %p\n",
>           vp, bf, ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag,
>           ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
>           vp->v_usecount, vp->v_writecount, vp->v_holdcnt,
> -         vp->v_freelisthd, vp->v_mount, vp->v_data, vl);
> +         vp->v_freelisthd, vp->v_mount, vp->v_data, &vp->v_lock);
>       if (vp->v_data != NULL) {
>               printf("\t");
>               VOP_PRINT(vp);
>       }
> @@ -2914,54 +2912,8 @@ setrootfstime(time_t t)
>  {
>       rootfstime = t;
>  }
>  
> -/*
> - * Sham lock manager for vnodes.  This is a temporary measure.
> - */
> -int
> -vlockmgr(struct vnlock *vl, int flags)
> -{
> -
> -     KASSERT((flags & ~(LK_NOWAIT | LK_TYPE_MASK)) == 0);
> -
> -     switch (flags & (LK_NOWAIT | LK_TYPE_MASK)) {
> -     case LK_SHARED:
> -             rw_enter(&vl->vl_lock, RW_READER);
> -             return 0;
> -
> -     case LK_SHARED | LK_NOWAIT:
> -             return rw_tryenter(&vl->vl_lock, RW_READER) ? 0 : EBUSY;
> -
> -     case LK_EXCLUSIVE:
> -             rw_enter(&vl->vl_lock, RW_WRITER);
> -             return 0;
> -
> -     case LK_EXCLUSIVE | LK_NOWAIT:
> -             return rw_tryenter(&vl->vl_lock, RW_WRITER) ? 0 : EBUSY;
> -
> -     case LK_RELEASE:
> -             rw_exit(&vl->vl_lock);
> -             return 0;
> -
> -     default:
> -             panic("vlockmgr: flags %x", flags);
> -     }
> -}
> -
> -int
> -vlockstatus(struct vnlock *vl)
> -{
> -
> -     if (rw_write_held(&vl->vl_lock)) {
> -             return LK_EXCLUSIVE;
> -     }
> -     if (rw_read_held(&vl->vl_lock)) {
> -             return LK_SHARED;
> -     }
> -     return 0;
> -}
> -
>  static const uint8_t vttodt_tab[9] = {
>       DT_UNKNOWN,     /* VNON  */
>       DT_REG,         /* VREG  */
>       DT_DIR,         /* VDIR  */
> Index: sys/miscfs/genfs/genfs_vnops.c
> ===================================================================
> RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
> retrieving revision 1.181
> diff -p -u -4 -r1.181 genfs_vnops.c
> --- sys/miscfs/genfs/genfs_vnops.c    24 Jun 2010 13:03:16 -0000      1.181
> +++ sys/miscfs/genfs/genfs_vnops.c    29 Jun 2010 10:27:36 -0000
> @@ -287,10 +287,20 @@ genfs_lock(void *v)
>               int a_flags;
>       } */ *ap = v;
>       struct vnode *vp = ap->a_vp;
>       int flags = ap->a_flags;
> +     krw_t op;
>  
> -     return (vlockmgr(&vp->v_lock, flags));
> +     KASSERT((flags & ~(LK_EXCLUSIVE | LK_SHARED | LK_NOWAIT)) == 0);
> +
> +     op = ((flags & LK_EXCLUSIVE) != 0 ? RW_WRITER : RW_READER);
> +
> +     if ((flags & LK_NOWAIT) != 0)
> +             return (rw_tryenter(&vp->v_lock, op) ? 0 : EBUSY);
> +
> +     rw_enter(&vp->v_lock, op);
> +
> +     return 0;
>  }
>  
>  /*
>   * Unlock the node.
> @@ -302,9 +312,11 @@ genfs_unlock(void *v)
>               struct vnode *a_vp;
>       } */ *ap = v;
>       struct vnode *vp = ap->a_vp;
>  
> -     return (vlockmgr(&vp->v_lock, LK_RELEASE));
> +     rw_exit(&vp->v_lock);
> +
> +     return 0;
>  }
>  
>  /*
>   * Return whether or not the node is locked.
> @@ -316,9 +328,15 @@ genfs_islocked(void *v)
>               struct vnode *a_vp;
>       } */ *ap = v;
>       struct vnode *vp = ap->a_vp;
>  
> -     return (vlockstatus(&vp->v_lock));
> +     if (rw_write_held(&vp->v_lock))
> +             return LK_EXCLUSIVE;
> +
> +     if (rw_read_held(&vp->v_lock))
> +             return LK_SHARED;
> +
> +     return 0;
>  }
>  
>  /*
>   * Stubs to use when there is no locking to be done on the underlying object.
> Index: sys/miscfs/kernfs/kernfs_subr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/miscfs/kernfs/kernfs_subr.c,v
> retrieving revision 1.20
> diff -p -u -4 -r1.20 kernfs_subr.c
> --- sys/miscfs/kernfs/kernfs_subr.c   15 Mar 2009 17:22:38 -0000      1.20
> +++ sys/miscfs/kernfs/kernfs_subr.c   29 Jun 2010 10:27:36 -0000
> @@ -332,9 +332,9 @@ kernfs_hashins(struct kernfs_node *pp)
>  {
>       struct kfs_hashhead *ppp;
>  
>       /* lock the kfsnode, then put it on the appropriate hash list */
> -     vlockmgr(&pp->kfs_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(KERNFSTOV(pp), LK_EXCLUSIVE);
>  
>       mutex_enter(&kfs_ihash_lock);
>       ppp = &kfs_hashtbl[KFSVALUEHASH(pp->kfs_value)];
>       LIST_INSERT_HEAD(ppp, pp, kfs_hash);
> Index: sys/miscfs/procfs/procfs_subr.c
> ===================================================================
> RCS file: /cvsroot/src/sys/miscfs/procfs/procfs_subr.c,v
> retrieving revision 1.95
> diff -p -u -4 -r1.95 procfs_subr.c
> --- sys/miscfs/procfs/procfs_subr.c   15 Mar 2009 17:22:38 -0000      1.95
> +++ sys/miscfs/procfs/procfs_subr.c   29 Jun 2010 10:27:41 -0000
> @@ -619,9 +619,9 @@ procfs_hashins(struct pfsnode *pp)
>  {
>       struct pfs_hashhead *ppp;
>  
>       /* lock the pfsnode, then put it on the appropriate hash list */
> -     vlockmgr(&pp->pfs_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(PFSTOV(pp), LK_EXCLUSIVE);
>  
>       mutex_enter(&pfs_ihash_lock);
>       ppp = &pfs_hashtbl[PFSPIDHASH(pp->pfs_pid)];
>       LIST_INSERT_HEAD(ppp, pp, pfs_hash);
> Index: sys/netsmb/smb_conn.c
> ===================================================================
> RCS file: /cvsroot/src/sys/netsmb/smb_conn.c,v
> retrieving revision 1.25
> diff -p -u -4 -r1.25 smb_conn.c
> --- sys/netsmb/smb_conn.c     18 Mar 2009 16:00:24 -0000      1.25
> +++ sys/netsmb/smb_conn.c     29 Jun 2010 10:27:43 -0000
> @@ -134,9 +134,9 @@ smb_sm_done(void)
>       return 0;
>  }
>  
>  static int
> -smb_sm_lockvclist(int flags)
> +smb_sm_lockvclist(void)
>  {
>       int error;
>  
>       mutex_enter(&smb_vclist.co_interlock);
> @@ -222,9 +222,9 @@ smb_sm_lookup(struct smb_vcspec *vcspec,
>       int fail, error;
>  
>       *vcpp = vcp = NULL;
>  
> -     error = smb_sm_lockvclist(LK_EXCLUSIVE);
> +     error = smb_sm_lockvclist();
>       if (error)
>               return error;
>       fail = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
>       if (!fail || (vcspec->flags & SMBV_CREATE) == 0) {
> Index: sys/nfs/nfs_node.c
> ===================================================================
> RCS file: /cvsroot/src/sys/nfs/nfs_node.c,v
> retrieving revision 1.111
> diff -p -u -4 -r1.111 nfs_node.c
> --- sys/nfs/nfs_node.c        24 Jun 2010 13:03:17 -0000      1.111
> +++ sys/nfs/nfs_node.c        29 Jun 2010 10:27:43 -0000
> @@ -230,9 +230,9 @@ loop:
>       np->n_rcred = curlwp->l_cred;
>       kauth_cred_hold(np->n_rcred);
>       np->n_wcred = curlwp->l_cred;
>       kauth_cred_hold(np->n_wcred);
> -     vlockmgr(&vp->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(vp, LK_EXCLUSIVE);
>       NFS_INVALIDATE_ATTRCACHE(np);
>       uvm_vnp_setsize(vp, 0);
>       rb_tree_insert_node(&nmp->nm_rbtree, &np->n_rbnode);
>       rw_exit(&nmp->nm_rbtlock);
> Index: sys/sys/lock.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/lock.h,v
> retrieving revision 1.85
> diff -p -u -4 -r1.85 lock.h
> --- sys/sys/lock.h    24 Jun 2010 07:54:47 -0000      1.85
> +++ sys/sys/lock.h    29 Jun 2010 10:27:44 -0000
> @@ -72,18 +72,8 @@
>  #include <sys/mutex.h>
>  
>  #include <machine/lock.h>
>  
> -#define      LK_TYPE_MASK    0x0000000f      /* type of lock sought */
> -#define      LK_SHARED       0x00000001      /* shared lock */
> -#define      LK_EXCLUSIVE    0x00000002      /* exclusive lock */
> -#define      LK_RELEASE      0x00000006      /* release any type of lock */
> -
> -#define      LK_NOWAIT       0x00000010      /* do not sleep to await lock */
> -#define      LK_INTERLOCK    0x00010000      /* unlock passed simple lock 
> after
> -                                        getting lk_interlock */
> -#define      LK_RETRY        0x00020000      /* vn_lock: retry until locked 
> */
> -
>  #ifdef _KERNEL
>  
>  /*
>   * From <machine/lock.h>.
> Index: sys/sys/param.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/param.h,v
> retrieving revision 1.368
> diff -p -u -4 -r1.368 param.h
> --- sys/sys/param.h   26 Jun 2010 14:24:27 -0000      1.368
> +++ sys/sys/param.h   29 Jun 2010 10:27:44 -0000
> @@ -62,9 +62,9 @@
>   *   NetBSD-2.0H     (200080000) was changed on 20041001 to:
>   *   2.99.9          (299000900)
>   */
>  
> -#define      __NetBSD_Version__      599003300       /* NetBSD 5.99.33 */
> +#define      __NetBSD_Version__      599003400       /* NetBSD 5.99.34 */
>  
>  #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
>      (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
>  
> Index: sys/sys/vnode.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/vnode.h,v
> retrieving revision 1.220
> diff -p -u -4 -r1.220 vnode.h
> --- sys/sys/vnode.h   18 Jun 2010 16:29:02 -0000      1.220
> +++ sys/sys/vnode.h   29 Jun 2010 10:27:44 -0000
> @@ -121,12 +121,8 @@ struct buf;
>  
>  LIST_HEAD(buflists, buf);
>  TAILQ_HEAD(vnodelst, vnode);
>  
> -struct vnlock {
> -     krwlock_t       vl_lock;
> -};
> -
>  /*
>   * Reading or writing any of these items requires holding the appropriate
>   * lock.  Field markings and the corresponding locks:
>   *
> @@ -136,9 +132,9 @@ struct vnlock {
>   *   m       mntvnode_lock
>   *   n       namecache_lock
>   *   s       syncer_data_lock
>   *   u       locked by underlying filesystem
> - *   v       v_lock
> + *   v       vnode lock
>   *   x       v_interlock + bufcache_lock to modify, either to inspect
>   *
>   * Each underlying filesystem allocates its own private area and hangs
>   * it from v_data.
> @@ -173,9 +169,9 @@ struct vnode {
>               struct uvm_ractx *vu_ractx;     /* i: read-ahead ctx (VREG) */
>       } v_un;
>       enum vtype      v_type;                 /* :: vnode type */
>       enum vtagtype   v_tag;                  /* :: type of underlying data */
> -     struct vnlock   v_lock;                 /* v: lock for this vnode */
> +     krwlock_t       v_lock;                 /* v: lock for this vnode */
>       void            *v_data;                /* :: private data for fs */
>       struct klist    v_klist;                /* i: notes attached to vnode */
>  };
>  #define      v_usecount      v_uobj.uo_refs
> @@ -189,15 +185,9 @@ struct vnode {
>  typedef struct vnodelst vnodelst_t;
>  typedef struct vnode vnode_t;
>  
>  /*
> - * All vnode locking operations should use vp->v_lock.
> - *
> - * All filesystems must (pretend to) understand lockmanager flags.
> - */
> -
> -/*
> - * Vnode flags.  The first set are locked by vp->v_lock or are stable.
> + * Vnode flags.  The first set are locked by vnode lock or are stable.
>   * VSYSTEM is only used to skip vflush()ing quota files.  VISTTY is used
>   * when reading dead vnodes.
>   */
>  #define      VV_ROOT         0x00000001      /* root of its file system */
> @@ -243,8 +233,17 @@ typedef struct vnode vnode_t;
>  #define      VC_XLOCK        0x80000000
>  #define      VC_MASK         0x7fffffff
>  
>  /*
> + * vnode lock flags
> + */
> +#define      LK_SHARED       0x00000001      /* shared lock */
> +#define      LK_EXCLUSIVE    0x00000002      /* exclusive lock */
> +#define      LK_NOWAIT       0x00000010      /* do not sleep to await lock */
> +#define      LK_INTERLOCK    0x00010000      /* caller holds v_interlock */
> +#define      LK_RETRY        0x00020000      /* vn_lock: retry until locked 
> */
> +
> +/*
>   * Vnode attributes.  A field value of VNOVAL represents a field whose value
>   * is unavailable (getattr) or which is not to be changed (setattr).
>   */
>  struct vattr {
> @@ -633,10 +632,8 @@ void     vntblinit(void);
>  void vn_syncer_add_to_worklist(struct vnode *, int);
>  void vn_syncer_remove_from_worklist(struct vnode *);
>  int  speedup_syncer(void);
>  int  dorevoke(struct vnode *, kauth_cred_t);
> -int  vlockmgr(struct vnlock *, int);
> -int  vlockstatus(struct vnlock *);
>  int  rawdev_mounted(struct vnode *, struct vnode **);
>  uint8_t      vtype2dt(enum vtype);
>  
>  /* see vfssubr(9) */
> Index: sys/ufs/lfs/lfs_syscalls.c
> ===================================================================
> RCS file: /cvsroot/src/sys/ufs/lfs/lfs_syscalls.c,v
> retrieving revision 1.137
> diff -p -u -4 -r1.137 lfs_syscalls.c
> --- sys/ufs/lfs/lfs_syscalls.c        24 Jun 2010 13:03:19 -0000      1.137
> +++ sys/ufs/lfs/lfs_syscalls.c        29 Jun 2010 10:27:44 -0000
> @@ -1139,9 +1139,9 @@ lfs_fastvget(struct mount *mp, ino_t ino
>                             " for ino %d\n", ino));
>                       ufs_ihashrem(ip);
>  
>                       /* Unlock and discard unneeded inode. */
> -                     vlockmgr(&vp->v_lock, LK_RELEASE);
> +                     VOP_UNLOCK(vp);
>                       lfs_vunref(vp);
>                       *vpp = NULL;
>                       return (error);
>               }
> @@ -1162,9 +1162,9 @@ lfs_fastvget(struct mount *mp, ino_t ino
>                        */
>                       ufs_ihashrem(ip);
>  
>                       /* Unlock and discard unneeded inode. */
> -                     vlockmgr(&vp->v_lock, LK_RELEASE);
> +                     VOP_UNLOCK(vp);
>                       lfs_vunref(vp);
>                       brelse(bp, 0);
>                       *vpp = NULL;
>                       return (error);
> Index: sys/ufs/ufs/ufs_ihash.c
> ===================================================================
> RCS file: /cvsroot/src/sys/ufs/ufs/ufs_ihash.c,v
> retrieving revision 1.28
> diff -p -u -4 -r1.28 ufs_ihash.c
> --- sys/ufs/ufs/ufs_ihash.c   5 Nov 2009 08:18:02 -0000       1.28
> +++ sys/ufs/ufs/ufs_ihash.c   29 Jun 2010 10:27:44 -0000
> @@ -170,9 +170,9 @@ ufs_ihashins(struct inode *ip)
>  
>       KASSERT(mutex_owned(&ufs_hashlock));
>  
>       /* lock the inode, then put it on the appropriate hash list */
> -     vlockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE);
> +     VOP_LOCK(ITOV(ip), LK_EXCLUSIVE);
>  
>       mutex_enter(&ufs_ihash_lock);
>       ipp = &ihashtbl[INOHASH(ip->i_dev, ip->i_number)];
>       LIST_INSERT_HEAD(ipp, ip, i_hash);


Home | Main Index | Thread Index | Old Index