[BACK]Return to ffs_vnops.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ffs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/ufs/ffs/ffs_vnops.c between version 1.86.4.1 and 1.93.6.3

version 1.86.4.1, 2007/03/13 17:51:21 version 1.93.6.3, 2008/01/10 23:44:44
Line 64  __KERNEL_RCSID(0, "$NetBSD$");
Line 64  __KERNEL_RCSID(0, "$NetBSD$");
   
 #include <uvm/uvm.h>  #include <uvm/uvm.h>
   
 static int ffs_full_fsync(void *);  
   
 /* Global vfs data structures for ufs. */  /* Global vfs data structures for ufs. */
 int (**ffs_vnodeop_p)(void *);  int (**ffs_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {  const struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
Line 101  const struct vnodeopv_entry_desc ffs_vno
Line 99  const struct vnodeopv_entry_desc ffs_vno
         { &vop_abortop_desc, ufs_abortop },             /* abortop */          { &vop_abortop_desc, ufs_abortop },             /* abortop */
         { &vop_inactive_desc, ufs_inactive },           /* inactive */          { &vop_inactive_desc, ufs_inactive },           /* inactive */
         { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */          { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */
         { &vop_lock_desc, ufs_lock },                   /* lock */          { &vop_lock_desc, ffs_lock },                   /* lock */
         { &vop_unlock_desc, ufs_unlock },               /* unlock */          { &vop_unlock_desc, ffs_unlock },               /* unlock */
         { &vop_bmap_desc, ufs_bmap },                   /* bmap */          { &vop_bmap_desc, ufs_bmap },                   /* bmap */
         { &vop_strategy_desc, ufs_strategy },           /* strategy */          { &vop_strategy_desc, ufs_strategy },           /* strategy */
         { &vop_print_desc, ufs_print },                 /* print */          { &vop_print_desc, ufs_print },                 /* print */
         { &vop_islocked_desc, ufs_islocked },           /* islocked */          { &vop_islocked_desc, ffs_islocked },           /* islocked */
         { &vop_pathconf_desc, ufs_pathconf },           /* pathconf */          { &vop_pathconf_desc, ufs_pathconf },           /* pathconf */
         { &vop_advlock_desc, ufs_advlock },             /* advlock */          { &vop_advlock_desc, ufs_advlock },             /* advlock */
         { &vop_bwrite_desc, vn_bwrite },                /* bwrite */          { &vop_bwrite_desc, vn_bwrite },                /* bwrite */
         { &vop_getpages_desc, ffs_getpages },           /* getpages */          { &vop_getpages_desc, genfs_getpages },         /* getpages */
         { &vop_putpages_desc, genfs_putpages },         /* putpages */          { &vop_putpages_desc, genfs_putpages },         /* putpages */
         { &vop_openextattr_desc, ffs_openextattr },     /* openextattr */          { &vop_openextattr_desc, ffs_openextattr },     /* openextattr */
         { &vop_closeextattr_desc, ffs_closeextattr },   /* closeextattr */          { &vop_closeextattr_desc, ffs_closeextattr },   /* closeextattr */
Line 156  const struct vnodeopv_entry_desc ffs_spe
Line 154  const struct vnodeopv_entry_desc ffs_spe
         { &vop_abortop_desc, spec_abortop },            /* abortop */          { &vop_abortop_desc, spec_abortop },            /* abortop */
         { &vop_inactive_desc, ufs_inactive },           /* inactive */          { &vop_inactive_desc, ufs_inactive },           /* inactive */
         { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */          { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */
         { &vop_lock_desc, ufs_lock },                   /* lock */          { &vop_lock_desc, ffs_lock },                   /* lock */
         { &vop_unlock_desc, ufs_unlock },               /* unlock */          { &vop_unlock_desc, ffs_unlock },               /* unlock */
         { &vop_bmap_desc, spec_bmap },                  /* bmap */          { &vop_bmap_desc, spec_bmap },                  /* bmap */
         { &vop_strategy_desc, spec_strategy },          /* strategy */          { &vop_strategy_desc, spec_strategy },          /* strategy */
         { &vop_print_desc, ufs_print },                 /* print */          { &vop_print_desc, ufs_print },                 /* print */
         { &vop_islocked_desc, ufs_islocked },           /* islocked */          { &vop_islocked_desc, ffs_islocked },           /* islocked */
         { &vop_pathconf_desc, spec_pathconf },          /* pathconf */          { &vop_pathconf_desc, spec_pathconf },          /* pathconf */
         { &vop_advlock_desc, spec_advlock },            /* advlock */          { &vop_advlock_desc, spec_advlock },            /* advlock */
         { &vop_bwrite_desc, vn_bwrite },                /* bwrite */          { &vop_bwrite_desc, vn_bwrite },                /* bwrite */
Line 211  const struct vnodeopv_entry_desc ffs_fif
Line 209  const struct vnodeopv_entry_desc ffs_fif
         { &vop_abortop_desc, fifo_abortop },            /* abortop */          { &vop_abortop_desc, fifo_abortop },            /* abortop */
         { &vop_inactive_desc, ufs_inactive },           /* inactive */          { &vop_inactive_desc, ufs_inactive },           /* inactive */
         { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */          { &vop_reclaim_desc, ffs_reclaim },             /* reclaim */
         { &vop_lock_desc, ufs_lock },                   /* lock */          { &vop_lock_desc, ffs_lock },                   /* lock */
         { &vop_unlock_desc, ufs_unlock },               /* unlock */          { &vop_unlock_desc, ffs_unlock },               /* unlock */
         { &vop_bmap_desc, fifo_bmap },                  /* bmap */          { &vop_bmap_desc, fifo_bmap },                  /* bmap */
         { &vop_strategy_desc, fifo_strategy },          /* strategy */          { &vop_strategy_desc, fifo_strategy },          /* strategy */
         { &vop_print_desc, ufs_print },                 /* print */          { &vop_print_desc, ufs_print },                 /* print */
         { &vop_islocked_desc, ufs_islocked },           /* islocked */          { &vop_islocked_desc, ffs_islocked },           /* islocked */
         { &vop_pathconf_desc, fifo_pathconf },          /* pathconf */          { &vop_pathconf_desc, fifo_pathconf },          /* pathconf */
         { &vop_advlock_desc, fifo_advlock },            /* advlock */          { &vop_advlock_desc, fifo_advlock },            /* advlock */
         { &vop_bwrite_desc, vn_bwrite },                /* bwrite */          { &vop_bwrite_desc, vn_bwrite },                /* bwrite */
Line 246  ffs_fsync(void *v)
Line 244  ffs_fsync(void *v)
                 struct lwp *a_l;                  struct lwp *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct buf *bp;          struct buf *bp;
         int s, num, error, i;          int num, error, i;
         struct indir ia[NIADDR + 1];          struct indir ia[NIADDR + 1];
         int bsize;          int bsize;
         daddr_t blk_high;          daddr_t blk_high;
Line 254  ffs_fsync(void *v)
Line 252  ffs_fsync(void *v)
   
         vp = ap->a_vp;          vp = ap->a_vp;
   
         if ((error = fstrans_start(vp->v_mount, FSTRANS_LAZY)) != 0)          fstrans_start(vp->v_mount, FSTRANS_LAZY);
                 return error;  
         /*          /*
          * XXX no easy way to sync a range in a file with softdep.           * XXX no easy way to sync a range in a file with softdep.
          */           */
         if ((ap->a_offlo == 0 && ap->a_offhi == 0) || DOINGSOFTDEP(vp) ||          if ((ap->a_offlo == 0 && ap->a_offhi == 0) || DOINGSOFTDEP(vp) ||
             (vp->v_type != VREG)) {              (vp->v_type != VREG)) {
                 error = ffs_full_fsync(v);                  error = ffs_full_fsync(vp, ap->a_flags);
                 goto out;                  goto out;
         }          }
   
Line 286  ffs_fsync(void *v)
Line 283  ffs_fsync(void *v)
          * Then, flush indirect blocks.           * Then, flush indirect blocks.
          */           */
   
         s = splbio();  
         if (blk_high >= NDADDR) {          if (blk_high >= NDADDR) {
                 error = ufs_getlbns(vp, blk_high, ia, &num);                  error = ufs_getlbns(vp, blk_high, ia, &num);
                 if (error) {                  if (error)
                         splx(s);  
                         goto out;                          goto out;
                 }  
                   mutex_enter(&bufcache_lock);
                 for (i = 0; i < num; i++) {                  for (i = 0; i < num; i++) {
                         bp = incore(vp, ia[i].in_lbn);                          if ((bp = incore(vp, ia[i].in_lbn)) == NULL)
                         if (bp != NULL) {                                  continue;
                                 mutex_enter(&bp->b_interlock);                          if ((bp->b_cflags & BC_BUSY) != 0 ||
                                 if (!(bp->b_flags & B_BUSY) && (bp->b_flags & B_DELWRI)) {                              (bp->b_oflags & BO_DELWRI) == 0)
                                         bp->b_flags |= B_BUSY | B_VFLUSH;                                  continue;
                                         mutex_exit(&bp->b_interlock);                          bp->b_cflags |= BC_BUSY | BC_VFLUSH;
                                         splx(s);                          mutex_exit(&bufcache_lock);
                                         bawrite(bp);                          bawrite(bp);
                                         s = splbio();                          mutex_enter(&bufcache_lock);
                                 } else {  
                                         mutex_exit(&bp->b_interlock);  
                                 }  
                         }  
                 }                  }
                   mutex_exit(&bufcache_lock);
         }          }
   
         if (ap->a_flags & FSYNC_WAIT) {          if (ap->a_flags & FSYNC_WAIT) {
                 mutex_enter(&global_v_numoutput_lock);                  mutex_enter(&vp->v_interlock);
                 while (vp->v_numoutput > 0) {                  while (vp->v_numoutput > 0)
                         vp->v_flag |= VBWAIT;                          cv_wait(&vp->v_cv, &vp->v_interlock);
                         mtsleep(&vp->v_numoutput, PRIBIO + 1, "fsync_range", 0,                  mutex_exit(&vp->v_interlock);
                                 &global_v_numoutput_lock);  
                 }  
                 mutex_exit(&global_v_numoutput_lock);  
         }          }
         splx(s);  
   
         error = ffs_update(vp, NULL, NULL,          error = ffs_update(vp, NULL, NULL,
             ((ap->a_flags & (FSYNC_WAIT | FSYNC_DATAONLY)) == FSYNC_WAIT)              ((ap->a_flags & (FSYNC_WAIT | FSYNC_DATAONLY)) == FSYNC_WAIT)
Line 328  ffs_fsync(void *v)
Line 317  ffs_fsync(void *v)
         if (error == 0 && ap->a_flags & FSYNC_CACHE) {          if (error == 0 && ap->a_flags & FSYNC_CACHE) {
                 int l = 0;                  int l = 0;
                 VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,                  VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
                         ap->a_l->l_cred, ap->a_l);                          curlwp->l_cred);
         }          }
   
 out:  out:
Line 340  out:
Line 329  out:
  * Synch an open file.   * Synch an open file.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 static int  int
 ffs_full_fsync(void *v)  ffs_full_fsync(struct vnode *vp, int flags)
 {  {
         struct vop_fsync_args /* {  
                 struct vnode *a_vp;  
                 kauth_cred_t a_cred;  
                 int a_flags;  
                 off_t a_offlo;  
                 off_t a_offhi;  
                 struct lwp *a_l;  
         } */ *ap = v;  
         struct vnode *vp = ap->a_vp;  
         struct buf *bp, *nbp;          struct buf *bp, *nbp;
         int s, error, passes, skipmeta, inodedeps_only, waitfor;          int error, passes, skipmeta, inodedeps_only, waitfor;
   
         if (vp->v_type == VBLK &&          if (vp->v_type == VBLK &&
             vp->v_specmountpoint != NULL &&              vp->v_specmountpoint != NULL &&
             (vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP))              (vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP))
                 softdep_fsync_mountdev(vp);                  softdep_fsync_mountdev(vp);
   
         inodedeps_only = DOINGSOFTDEP(vp) && (ap->a_flags & FSYNC_RECLAIM)          mutex_enter(&vp->v_interlock);
             && vp->v_uobj.uo_npages == 0 && LIST_EMPTY(&vp->v_dirtyblkhd);  
           inodedeps_only = DOINGSOFTDEP(vp) && (flags & FSYNC_RECLAIM)
               && UVM_OBJ_IS_CLEAN(&vp->v_uobj) && LIST_EMPTY(&vp->v_dirtyblkhd);
   
         /*          /*
          * Flush all dirty data associated with a vnode.           * Flush all dirty data associated with a vnode.
          */           */
   
         if (vp->v_type == VREG || vp->v_type == VBLK) {          if (vp->v_type == VREG || vp->v_type == VBLK) {
                 mutex_enter(&vp->v_interlock);  
                 error = VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES | PGO_CLEANIT |                  error = VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES | PGO_CLEANIT |
                     ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0) |                      ((flags & FSYNC_WAIT) ? PGO_SYNCIO : 0) |
                     (fstrans_getstate(vp->v_mount) == FSTRANS_SUSPENDING ?                      (fstrans_getstate(vp->v_mount) == FSTRANS_SUSPENDING ?
                         PGO_FREE : 0));                          PGO_FREE : 0));
                 if (error) {                  if (error) {
                         return error;                          return error;
                 }                  }
         }          } else
                   mutex_exit(&vp->v_interlock);
   
         passes = NIADDR + 1;          passes = NIADDR + 1;
         skipmeta = 0;          skipmeta = 0;
         if (ap->a_flags & FSYNC_WAIT)          if (flags & FSYNC_WAIT)
                 skipmeta = 1;                  skipmeta = 1;
         s = splbio();  
   
 loop:  loop:
         LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs)          mutex_enter(&bufcache_lock);
                 bp->b_flags &= ~B_SCANNED;          LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) {
                   bp->b_cflags &= ~BC_SCANNED;
           }
         for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {          for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
                 nbp = LIST_NEXT(bp, b_vnbufs);                  nbp = LIST_NEXT(bp, b_vnbufs);
                 mutex_enter(&bp->b_interlock);                  if (bp->b_cflags & (BC_BUSY | BC_SCANNED))
                 if (bp->b_flags & (B_BUSY | B_SCANNED)) {  
                         mutex_exit(&bp->b_interlock);  
                         continue;                          continue;
                 }                  if ((bp->b_oflags & BO_DELWRI) == 0)
                 if ((bp->b_flags & B_DELWRI) == 0)  
                         panic("ffs_fsync: not dirty");                          panic("ffs_fsync: not dirty");
                 if (skipmeta && bp->b_lblkno < 0) {                  if (skipmeta && bp->b_lblkno < 0)
                         mutex_exit(&bp->b_interlock);  
                         continue;                          continue;
                 }                  bp->b_cflags |= BC_BUSY | BC_VFLUSH | BC_SCANNED;
                 mutex_exit(&bp->b_interlock);                  mutex_exit(&bufcache_lock);
                 bp->b_flags |= B_BUSY | B_VFLUSH | B_SCANNED;  
                 splx(s);  
                 /*                  /*
                  * On our final pass through, do all I/O synchronously                   * On our final pass through, do all I/O synchronously
                  * so that we can find out if our flush is failing                   * so that we can find out if our flush is failing
                  * because of write errors.                   * because of write errors.
                  */                   */
                 if (passes > 0 || !(ap->a_flags & FSYNC_WAIT))                  if (passes > 0 || !(flags & FSYNC_WAIT))
                         (void) bawrite(bp);                          (void) bawrite(bp);
                 else if ((error = bwrite(bp)) != 0)                  else if ((error = bwrite(bp)) != 0)
                         return (error);                          return (error);
                 s = splbio();  
                 /*                  /*
                  * Since we may have slept during the I/O, we need                   * Since we unlocked during the I/O, we need
                  * to start from a known point.                   * to start from a known point.
                  */                   */
                   mutex_enter(&bufcache_lock);
                 nbp = LIST_FIRST(&vp->v_dirtyblkhd);                  nbp = LIST_FIRST(&vp->v_dirtyblkhd);
         }          }
           mutex_exit(&bufcache_lock);
         if (skipmeta) {          if (skipmeta) {
                 skipmeta = 0;                  skipmeta = 0;
                 goto loop;                  goto loop;
         }          }
         if (ap->a_flags & FSYNC_WAIT) {  
                 mutex_enter(&global_v_numoutput_lock);          if (flags & FSYNC_WAIT) {
                   mutex_enter(&vp->v_interlock);
                 while (vp->v_numoutput) {                  while (vp->v_numoutput) {
                         vp->v_flag |= VBWAIT;                          cv_wait(&vp->v_cv, &vp->v_interlock);
                         (void) mtsleep(&vp->v_numoutput, PRIBIO + 1,  
                             "ffsfsync", 0, &global_v_numoutput_lock);  
                 }                  }
                 mutex_exit(&global_v_numoutput_lock);                  mutex_exit(&vp->v_interlock);
                 splx(s);  
   
                 /*                  /*
                  * Ensure that any filesystem metadata associated                   * Ensure that any filesystem metadata associated
                  * with the vnode has been written.                   * with the vnode has been written.
                  */                   */
                 if ((error = softdep_sync_metadata(ap)) != 0)                  if ((error = softdep_sync_metadata(vp)) != 0)
                         return (error);                          return (error);
   
                 s = splbio();  
                 if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {                  if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
                         /*                          /*
                         * Block devices associated with filesystems may                          * Block devices associated with filesystems may
Line 460  loop:
Line 435  loop:
 #endif  #endif
                 }                  }
         }          }
         splx(s);  
   
         if (inodedeps_only)          if (inodedeps_only)
                 waitfor = 0;                  waitfor = 0;
         else          else
                 waitfor = (ap->a_flags & FSYNC_WAIT) ? UPDATE_WAIT : 0;                  waitfor = (flags & FSYNC_WAIT) ? UPDATE_WAIT : 0;
         error = ffs_update(vp, NULL, NULL, waitfor);          error = ffs_update(vp, NULL, NULL, waitfor);
   
         if (error == 0 && ap->a_flags & FSYNC_CACHE) {          if (error == 0 && flags & FSYNC_CACHE) {
                 int i = 0;                  int i = 0;
                 VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &i, FWRITE,                  VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &i, FWRITE,
                         ap->a_l->l_cred, ap->a_l);                          curlwp->l_cred);
         }          }
   
         return error;          return error;
Line 491  ffs_reclaim(void *v)
Line 465  ffs_reclaim(void *v)
         struct inode *ip = VTOI(vp);          struct inode *ip = VTOI(vp);
         struct mount *mp = vp->v_mount;          struct mount *mp = vp->v_mount;
         struct ufsmount *ump = ip->i_ump;          struct ufsmount *ump = ip->i_ump;
           void *data;
         int error;          int error;
   
         if ((error = fstrans_start(mp, FSTRANS_LAZY)) != 0)          fstrans_start(mp, FSTRANS_LAZY);
                 return error;          if ((error = ufs_reclaim(vp)) != 0) {
         if ((error = ufs_reclaim(vp, ap->a_l)) != 0) {  
                 fstrans_done(mp);                  fstrans_done(mp);
                 return (error);                  return (error);
         }          }
         if (ip->i_din.ffs1_din != NULL) {          if (ip->i_din.ffs1_din != NULL) {
                 if (ump->um_fstype == UFS1)                  if (ump->um_fstype == UFS1)
                         pool_put(&ffs_dinode1_pool, ip->i_din.ffs1_din);                          pool_cache_put(ffs_dinode1_cache, ip->i_din.ffs1_din);
                 else                  else
                         pool_put(&ffs_dinode2_pool, ip->i_din.ffs2_din);                          pool_cache_put(ffs_dinode2_cache, ip->i_din.ffs2_din);
         }          }
         /*          /*
          * XXX MFS ends up here, too, to free an inode.  Should we create           * To interlock with ffs_sync().
          * XXX a separate pool for MFS inodes?  
          */           */
         genfs_node_destroy(vp);          genfs_node_destroy(vp);
         pool_put(&ffs_inode_pool, vp->v_data);          mutex_enter(&vp->v_interlock);
           data = vp->v_data;
         vp->v_data = NULL;          vp->v_data = NULL;
           mutex_exit(&vp->v_interlock);
   
           /*
            * XXX MFS ends up here, too, to free an inode.  Should we create
            * XXX a separate pool for MFS inodes?
            */
           pool_cache_put(ffs_inode_cache, data);
         fstrans_done(mp);          fstrans_done(mp);
         return (0);          return (0);
 }  }
   
   #if 0
 int  int
 ffs_getpages(void *v)  ffs_getpages(void *v)
 {  {
Line 550  ffs_getpages(void *v)
Line 532  ffs_getpages(void *v)
         }          }
         return genfs_getpages(v);          return genfs_getpages(v);
 }  }
   #endif
   
 /*  /*
  * Return the last logical file offset that should be written for this file   * Return the last logical file offset that should be written for this file
Line 631  ffs_getextattr(void *v)
Line 614  ffs_getextattr(void *v)
 #ifdef UFS_EXTATTR  #ifdef UFS_EXTATTR
                 int error;                  int error;
   
                 if ((error = fstrans_start(vp->v_mount, FSTRANS_SHARED)) != 0)                  fstrans_start(vp->v_mount, FSTRANS_SHARED);
                         return error;  
                 error = ufs_getextattr(ap);                  error = ufs_getextattr(ap);
                 fstrans_done(vp->v_mount);                  fstrans_done(vp->v_mount);
                 return error;                  return error;
Line 664  ffs_setextattr(void *v)
Line 646  ffs_setextattr(void *v)
 #ifdef UFS_EXTATTR  #ifdef UFS_EXTATTR
                 int error;                  int error;
   
                 if ((error = fstrans_start(vp->v_mount, FSTRANS_SHARED)) != 0)                  fstrans_start(vp->v_mount, FSTRANS_SHARED);
                         return error;  
                 error = ufs_setextattr(ap);                  error = ufs_setextattr(ap);
                 fstrans_done(vp->v_mount);                  fstrans_done(vp->v_mount);
                 return error;                  return error;
Line 717  ffs_deleteextattr(void *v)
Line 698  ffs_deleteextattr(void *v)
 #ifdef UFS_EXTATTR  #ifdef UFS_EXTATTR
                 int error;                  int error;
   
                 if ((error = fstrans_start(vp->v_mount, FSTRANS_SHARED)) != 0)                  fstrans_start(vp->v_mount, FSTRANS_SHARED);
                         return error;  
                 error = ufs_deleteextattr(ap);                  error = ufs_deleteextattr(ap);
                 fstrans_done(vp->v_mount);                  fstrans_done(vp->v_mount);
                 return error;                  return error;
Line 730  ffs_deleteextattr(void *v)
Line 710  ffs_deleteextattr(void *v)
         /* XXX Not implemented for UFS2 file systems. */          /* XXX Not implemented for UFS2 file systems. */
         return (EOPNOTSUPP);          return (EOPNOTSUPP);
 }  }
   
   /*
    * Lock the node.
    */
   int
   ffs_lock(void *v)
   {
           struct vop_lock_args /* {
                   struct vnode *a_vp;
                   int a_flags;
           } */ *ap = v;
           struct vnode *vp = ap->a_vp;
           struct mount *mp = vp->v_mount;
           struct lock *lkp;
           int flags = ap->a_flags;
           int result;
   
           /*
            * Fake lock during file system suspension.
            */
           if ((vp->v_type == VREG || vp->v_type == VDIR) &&
               fstrans_is_owner(mp) &&
               fstrans_getstate(mp) == FSTRANS_SUSPENDING) {
                   if ((flags & LK_INTERLOCK) != 0)
                           mutex_exit(&vp->v_interlock);
                   return 0;
           }
   
           KASSERT((flags & ~(LK_SHARED | LK_EXCLUSIVE | LK_SLEEPFAIL |
               LK_INTERLOCK | LK_NOWAIT | LK_CANRECURSE)) == 0);
           for (;;) {
                   if ((flags & LK_INTERLOCK) == 0) {
                           mutex_enter(&vp->v_interlock);
                           flags |= LK_INTERLOCK;
                   }
                   lkp = vp->v_vnlock;
                   result = lockmgr(lkp, flags, &vp->v_interlock);
                   if (lkp == vp->v_vnlock || result != 0)
                           return result;
                   /*
                    * Apparent success, except that the vnode mutated between
                    * snapshot file vnode and regular file vnode while this
                    * thread slept.  The lock currently held is not the right
                    * lock.  Release it, and try to get the new lock.
                    */
                   (void) lockmgr(lkp, LK_RELEASE, NULL);
                   flags &= ~LK_INTERLOCK;
           }
   }
   
   /*
    * Unlock the node.
    */
   int
   ffs_unlock(void *v)
   {
           struct vop_unlock_args /* {
                   struct vnode *a_vp;
                   int a_flags;
           } */ *ap = v;
           struct vnode *vp = ap->a_vp;
           struct mount *mp = vp->v_mount;
   
           /*
            * Fake unlock during file system suspension.
            */
           if ((vp->v_type == VREG || vp->v_type == VDIR) &&
               fstrans_is_owner(mp) &&
               fstrans_getstate(mp) == FSTRANS_SUSPENDING) {
                   if ((ap->a_flags & LK_INTERLOCK) != 0)
                           mutex_exit(&vp->v_interlock);
                   return 0;
           }
           return (lockmgr(vp->v_vnlock, ap->a_flags | LK_RELEASE,
               &vp->v_interlock));
   }
   
   /*
    * Return whether or not the node is locked.
    */
   int
   ffs_islocked(void *v)
   {
           struct vop_islocked_args /* {
                   struct vnode *a_vp;
           } */ *ap = v;
           struct vnode *vp = ap->a_vp;
   
           return (lockstatus(vp->v_vnlock));
   }

Legend:
Removed from v.1.86.4.1  
changed lines
  Added in v.1.93.6.3

CVSweb <webmaster@jp.NetBSD.org>