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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs_vnops.c
          +++ new/usr/src/uts/common/fs/nfs/nfs_vnops.c
↓ open down ↓ 4357 lines elided ↑ open up ↑
4358 4358           * and we can prevent the deadlock that would have occurred
4359 4359           * when nfs_addmap() would have acquired it out of order.
4360 4360           *
4361 4361           * Since we are not protecting r_inmap by any lock, we do not
4362 4362           * hold any lock when we decrement it. We atomically decrement
4363 4363           * r_inmap after we release r_lkserlock.
4364 4364           */
4365 4365  
4366 4366          if (nfs_rw_enter_sig(&rp->r_rwlock, RW_WRITER, INTR(vp)))
4367 4367                  return (EINTR);
4368      -        atomic_add_int(&rp->r_inmap, 1);
     4368 +        atomic_inc_uint(&rp->r_inmap);
4369 4369          nfs_rw_exit(&rp->r_rwlock);
4370 4370  
4371 4371          if (nfs_rw_enter_sig(&rp->r_lkserlock, RW_READER, INTR(vp))) {
4372      -                atomic_add_int(&rp->r_inmap, -1);
     4372 +                atomic_dec_uint(&rp->r_inmap);
4373 4373                  return (EINTR);
4374 4374          }
4375 4375          if (vp->v_flag & VNOCACHE) {
4376 4376                  error = EAGAIN;
4377 4377                  goto done;
4378 4378          }
4379 4379  
4380 4380          /*
4381 4381           * Don't allow concurrent locks and mapping if mandatory locking is
4382 4382           * enabled.
↓ open down ↓ 20 lines elided ↑ open up ↑
4403 4403          vn_a.cred = cr;
4404 4404          vn_a.amp = NULL;
4405 4405          vn_a.szc = 0;
4406 4406          vn_a.lgrp_mem_policy_flags = 0;
4407 4407  
4408 4408          error = as_map(as, *addrp, len, segvn_create, &vn_a);
4409 4409          as_rangeunlock(as);
4410 4410  
4411 4411  done:
4412 4412          nfs_rw_exit(&rp->r_lkserlock);
4413      -        atomic_add_int(&rp->r_inmap, -1);
     4413 +        atomic_dec_uint(&rp->r_inmap);
4414 4414          return (error);
4415 4415  }
4416 4416  
4417 4417  /* ARGSUSED */
4418 4418  static int
4419 4419  nfs_addmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
4420 4420          size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, cred_t *cr,
4421 4421          caller_context_t *ct)
4422 4422  {
4423 4423          rnode_t *rp;
↓ open down ↓ 677 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX