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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/comstar/stmf/lun_map.c
          +++ new/usr/src/uts/common/io/comstar/stmf/lun_map.c
↓ open down ↓ 259 lines elided ↑ open up ↑
 260  260                  for (n = 0; n < sm->lm_nentries; n++) {
 261  261                          if ((ent = (stmf_lun_map_ent_t *)sm->lm_plus[n])
 262  262                              != NULL) {
 263  263                                  if (ent->ent_itl_datap) {
 264  264                                          stmf_do_itl_dereg(ent->ent_lu,
 265  265                                              ent->ent_itl_datap,
 266  266                                              STMF_ITL_REASON_IT_NEXUS_LOSS);
 267  267                                  }
 268  268                                  ilu = (stmf_i_lu_t *)
 269  269                                      ent->ent_lu->lu_stmf_private;
 270      -                                atomic_add_32(&ilu->ilu_ref_cnt, -1);
      270 +                                atomic_dec_32(&ilu->ilu_ref_cnt);
 271  271                                  kmem_free(sm->lm_plus[n],
 272  272                                      sizeof (stmf_lun_map_ent_t));
 273  273                          }
 274  274                  }
 275  275                  kmem_free(sm->lm_plus,
 276  276                      sizeof (stmf_lun_map_ent_t *) * sm->lm_nentries);
 277  277          }
 278  278  
 279  279          kmem_free(sm, sizeof (*sm));
 280  280          return (STMF_SUCCESS);
↓ open down ↓ 132 lines elided ↑ open up ↑
 413  413                  new_flags = ISS_GOT_INITIAL_LUNS;
 414  414                  atomic_or_32(&ilport->ilport_flags, ILPORT_SS_GOT_INITIAL_LUNS);
 415  415                  stmf_state.stmf_process_initial_luns = 1;
 416  416          }
 417  417  
 418  418          lun_map_ent = (stmf_lun_map_ent_t *)
 419  419              kmem_zalloc(sizeof (stmf_lun_map_ent_t), KM_SLEEP);
 420  420          lun_map_ent->ent_lu = lu;
 421  421          ret = stmf_add_ent_to_map(sm, (void *)lun_map_ent, lu_nbr);
 422  422          ASSERT(ret == STMF_SUCCESS);
 423      -        atomic_add_32(&ilu->ilu_ref_cnt, 1);
      423 +        atomic_inc_32(&ilu->ilu_ref_cnt);
 424  424          /*
 425  425           * do not set lun inventory flag for standby port
 426  426           * as this would be handled from peer
 427  427           */
 428  428          if (ilport->ilport_standby == 0) {
 429  429                  new_flags |= ISS_LUN_INVENTORY_CHANGED;
 430  430          }
 431  431          atomic_or_32(&iss->iss_flags, new_flags);
 432  432          return (STMF_SUCCESS);
 433  433  }
↓ open down ↓ 16 lines elided ↑ open up ↑
 450  450              ((uint16_t)lu_nbr[1] | (((uint16_t)(lu_nbr[0] & 0x3F)) << 8));
 451  451  
 452  452          ASSERT(mutex_owned(&stmf_state.stmf_lock));
 453  453          lun_map_ent = stmf_get_ent_from_map(sm, luNbr);
 454  454          ASSERT(lun_map_ent && lun_map_ent->ent_lu == lu);
 455  455  
 456  456          ilu = (stmf_i_lu_t *)lu->lu_stmf_private;
 457  457  
 458  458          ret = stmf_remove_ent_from_map(sm, lu_nbr);
 459  459          ASSERT(ret == STMF_SUCCESS);
 460      -        atomic_add_32(&ilu->ilu_ref_cnt, -1);
      460 +        atomic_dec_32(&ilu->ilu_ref_cnt);
 461  461          iss->iss_flags |= ISS_LUN_INVENTORY_CHANGED;
 462  462          if (lun_map_ent->ent_itl_datap) {
 463  463                  stmf_do_itl_dereg(lu, lun_map_ent->ent_itl_datap,
 464  464                      STMF_ITL_REASON_USER_REQUEST);
 465  465          }
 466  466          kmem_free((void *)lun_map_ent, sizeof (stmf_lun_map_ent_t));
 467  467          return (STMF_SUCCESS);
 468  468  }
 469  469  
 470  470  /*
↓ open down ↓ 206 lines elided ↑ open up ↑
 677  677  stmf_append_id(stmf_id_list_t *idlist, stmf_id_data_t *id)
 678  678  {
 679  679          id->id_next = NULL;
 680  680  
 681  681          if ((id->id_prev = idlist->idl_tail) == NULL) {
 682  682                  idlist->idl_head = idlist->idl_tail = id;
 683  683          } else {
 684  684                  idlist->idl_tail->id_next = id;
 685  685                  idlist->idl_tail = id;
 686  686          }
 687      -        atomic_add_32(&idlist->id_count, 1);
      687 +        atomic_inc_32(&idlist->id_count);
 688  688  }
 689  689  
 690  690  void
 691  691  stmf_remove_id(stmf_id_list_t *idlist, stmf_id_data_t *id)
 692  692  {
 693  693          if (id->id_next) {
 694  694                  id->id_next->id_prev = id->id_prev;
 695  695          } else {
 696  696                  idlist->idl_tail = id->id_prev;
 697  697          }
 698  698  
 699  699          if (id->id_prev) {
 700  700                  id->id_prev->id_next = id->id_next;
 701  701          } else {
 702  702                  idlist->idl_head = id->id_next;
 703  703          }
 704      -        atomic_add_32(&idlist->id_count, -1);
      704 +        atomic_dec_32(&idlist->id_count);
 705  705  }
 706  706  
 707  707  
 708  708  /*
 709  709   * The refcnts of objects in a view entry are updated when then entry
 710  710   * is successfully added. ve_map is just another representation of the
 711  711   * view enrtries in a LU. Duplicating or merging a ve map does not
 712  712   * affect any refcnts.
 713  713   */
 714  714  stmf_lun_map_t *
↓ open down ↓ 1054 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX