Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/lofs/lofs_subr.c
          +++ new/usr/src/uts/common/fs/lofs/lofs_subr.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   26  /*
  29   27   * The idea behind composition-based stacked filesystems is to add a
  30   28   * vnode to the stack of vnodes for each mount. These vnodes have their
  31   29   * own set of mount options and filesystem-specific functions, so they
  32   30   * can modify data or operations before they are passed along. Such a
  33   31   * filesystem must maintain a mapping from the underlying vnodes to its
  34   32   * interposing vnodes.
  35   33   *
  36   34   * In lofs, this mapping is implemented by a hashtable. Each bucket
  37   35   * contains a count of the number of nodes currently contained, the
↓ open down ↓ 244 lines elided ↑ open up ↑
 282  280                          if (flag != LOF_FORCE)
 283  281                                  lp = lfind(vp, li);
 284  282                          if (lp != NULL) {
 285  283                                  kmem_cache_free(lnode_cache, tlp);
 286  284                                  vn_free(nvp);
 287  285                                  VN_RELE(vp);
 288  286                                  goto found_lnode;
 289  287                          }
 290  288                          lp = tlp;
 291  289                  }
 292      -                atomic_add_32(&li->li_refct, 1);
      290 +                atomic_inc_32(&li->li_refct);
 293  291                  vfsp = makelfsnode(vp->v_vfsp, li);
 294  292                  lp->lo_vnode = nvp;
 295  293                  VN_SET_VFS_TYPE_DEV(nvp, vfsp, vp->v_type, vp->v_rdev);
 296  294                  nvp->v_flag |= (vp->v_flag & (VNOMOUNT|VNOMAP|VDIROPEN));
 297  295                  vn_setops(nvp, lo_vnodeops);
 298  296                  nvp->v_data = (caddr_t)lp;
 299  297                  lp->lo_vp = vp;
 300  298                  lp->lo_looping = 0;
 301  299                  lsave(lp, li);
 302  300                  vn_exists(vp);
↓ open down ↓ 322 lines elided ↑ open up ↑
 625  623   * Our version of vfs_rele() that stops at 1 instead of 0, and calls
 626  624   * freelfsnode() instead of kmem_free().
 627  625   */
 628  626  static void
 629  627  lfs_rele(struct lfsnode *lfs, struct loinfo *li)
 630  628  {
 631  629          vfs_t *vfsp = &lfs->lfs_vfs;
 632  630  
 633  631          ASSERT(MUTEX_HELD(&li->li_lfslock));
 634  632          ASSERT(vfsp->vfs_count > 1);
 635      -        if (atomic_add_32_nv(&vfsp->vfs_count, -1) == 1)
      633 +        if (atomic_dec_32_nv(&vfsp->vfs_count) == 1)
 636  634                  freelfsnode(lfs, li);
 637  635  }
 638  636  
 639  637  /*
 640  638   * Remove a lnode from the table
 641  639   */
 642  640  void
 643  641  freelonode(lnode_t *lp)
 644  642  {
 645  643          lnode_t *lt;
↓ open down ↓ 19 lines elided ↑ open up ↑
 665  663          }
 666  664          mutex_exit(&vp->v_lock);
 667  665  
 668  666          for (lt = TABLE_BUCKET(lp->lo_vp, li); lt != NULL;
 669  667              ltprev = lt, lt = lt->lo_next) {
 670  668                  if (lt == lp) {
 671  669  #ifdef LODEBUG
 672  670                          lo_dprint(4, "freeing %p, vfsp %p\n",
 673  671                              vp, vp->v_vfsp);
 674  672  #endif
 675      -                        atomic_add_32(&li->li_refct, -1);
      673 +                        atomic_dec_32(&li->li_refct);
 676  674                          vfsp = vp->v_vfsp;
 677  675                          vn_invalid(vp);
 678  676                          if (vfsp != li->li_mountvfs) {
 679  677                                  mutex_enter(&li->li_lfslock);
 680  678                                  /*
 681  679                                   * Check for unused lfs
 682  680                                   */
 683  681                                  lfs = li->li_lfs;
 684  682                                  while (lfs != NULL) {
 685  683                                          nextlfs = lfs->lfs_next;
↓ open down ↓ 88 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX