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


3131                 mutex_destroy(&bucketp->b_lock);
3132         }
3133         /*
3134          * Empty and destroy the freed open owner list.
3135          */
3136         foop = list_head(&mi->mi_foo_list);
3137         while (foop != NULL) {
3138                 list_remove(&mi->mi_foo_list, foop);
3139                 nfs4_destroy_open_owner(foop);
3140                 foop = list_head(&mi->mi_foo_list);
3141         }
3142         list_destroy(&mi->mi_foo_list);
3143         list_destroy(&mi->mi_bseqid_list);
3144         list_destroy(&mi->mi_lost_state);
3145         avl_destroy(&mi->mi_filehandles);
3146         kmem_free(mi, sizeof (*mi));
3147 }
3148 void
3149 mi_hold(mntinfo4_t *mi)
3150 {
3151         atomic_add_32(&mi->mi_count, 1);
3152         ASSERT(mi->mi_count != 0);
3153 }
3154 
3155 void
3156 mi_rele(mntinfo4_t *mi)
3157 {
3158         ASSERT(mi->mi_count != 0);
3159         if (atomic_add_32_nv(&mi->mi_count, -1) == 0) {
3160                 nfs_free_mi4(mi);
3161         }
3162 }
3163 
3164 vnode_t    nfs4_xattr_notsupp_vnode;
3165 
3166 void
3167 nfs4_clnt_init(void)
3168 {
3169         nfs4_vnops_init();
3170         (void) nfs4_rnode_init();
3171         (void) nfs4_shadow_init();
3172         (void) nfs4_acache_init();
3173         (void) nfs4_subr_init();
3174         nfs4_acl_init();
3175         nfs_idmap_init();
3176         nfs4_callback_init();
3177         nfs4_secinfo_init();
3178 #ifdef  DEBUG
3179         tsd_create(&nfs4_tsd_key, NULL);


4094          */
4095         sfh4_hold(sfh);
4096         fnp->fn_sfh = sfh;
4097 
4098         avl_create(&fnp->fn_children, fncmp, sizeof (nfs4_fname_t),
4099             offsetof(nfs4_fname_t, fn_tree));
4100         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4101             "fn_get %p:%s, a new nfs4_fname_t!",
4102             (void *)fnp, fnp->fn_name));
4103         if (parent != NULL) {
4104                 avl_insert(&parent->fn_children, fnp, where);
4105                 mutex_exit(&parent->fn_lock);
4106         }
4107 
4108         return (fnp);
4109 }
4110 
4111 void
4112 fn_hold(nfs4_fname_t *fnp)
4113 {
4114         atomic_add_32(&fnp->fn_refcnt, 1);
4115         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4116             "fn_hold %p:%s, new refcnt=%d",
4117             (void *)fnp, fnp->fn_name, fnp->fn_refcnt));
4118 }
4119 
4120 /*
4121  * Decrement the reference count of the given fname, and destroy it if its
4122  * reference count goes to zero.  Nulls out the given pointer.
4123  */
4124 
4125 void
4126 fn_rele(nfs4_fname_t **fnpp)
4127 {
4128         nfs4_fname_t *parent;
4129         uint32_t newref;
4130         nfs4_fname_t *fnp;
4131 
4132 recur:
4133         fnp = *fnpp;
4134         *fnpp = NULL;
4135 
4136         mutex_enter(&fnp->fn_lock);
4137         parent = fnp->fn_parent;
4138         if (parent != NULL)
4139                 mutex_enter(&parent->fn_lock);   /* prevent new references */
4140         newref = atomic_add_32_nv(&fnp->fn_refcnt, -1);
4141         if (newref > 0) {
4142                 NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4143                     "fn_rele %p:%s, new refcnt=%d",
4144                     (void *)fnp, fnp->fn_name, fnp->fn_refcnt));
4145                 if (parent != NULL)
4146                         mutex_exit(&parent->fn_lock);
4147                 mutex_exit(&fnp->fn_lock);
4148                 return;
4149         }
4150 
4151         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4152             "fn_rele %p:%s, last reference, deleting...",
4153             (void *)fnp, fnp->fn_name));
4154         if (parent != NULL) {
4155                 avl_remove(&parent->fn_children, fnp);
4156                 mutex_exit(&parent->fn_lock);
4157         }
4158         kmem_free(fnp->fn_name, fnp->fn_len + 1);
4159         sfh4_rele(&fnp->fn_sfh);
4160         mutex_destroy(&fnp->fn_lock);




3131                 mutex_destroy(&bucketp->b_lock);
3132         }
3133         /*
3134          * Empty and destroy the freed open owner list.
3135          */
3136         foop = list_head(&mi->mi_foo_list);
3137         while (foop != NULL) {
3138                 list_remove(&mi->mi_foo_list, foop);
3139                 nfs4_destroy_open_owner(foop);
3140                 foop = list_head(&mi->mi_foo_list);
3141         }
3142         list_destroy(&mi->mi_foo_list);
3143         list_destroy(&mi->mi_bseqid_list);
3144         list_destroy(&mi->mi_lost_state);
3145         avl_destroy(&mi->mi_filehandles);
3146         kmem_free(mi, sizeof (*mi));
3147 }
3148 void
3149 mi_hold(mntinfo4_t *mi)
3150 {
3151         atomic_inc_32(&mi->mi_count);
3152         ASSERT(mi->mi_count != 0);
3153 }
3154 
3155 void
3156 mi_rele(mntinfo4_t *mi)
3157 {
3158         ASSERT(mi->mi_count != 0);
3159         if (atomic_dec_32_nv(&mi->mi_count) == 0) {
3160                 nfs_free_mi4(mi);
3161         }
3162 }
3163 
3164 vnode_t    nfs4_xattr_notsupp_vnode;
3165 
3166 void
3167 nfs4_clnt_init(void)
3168 {
3169         nfs4_vnops_init();
3170         (void) nfs4_rnode_init();
3171         (void) nfs4_shadow_init();
3172         (void) nfs4_acache_init();
3173         (void) nfs4_subr_init();
3174         nfs4_acl_init();
3175         nfs_idmap_init();
3176         nfs4_callback_init();
3177         nfs4_secinfo_init();
3178 #ifdef  DEBUG
3179         tsd_create(&nfs4_tsd_key, NULL);


4094          */
4095         sfh4_hold(sfh);
4096         fnp->fn_sfh = sfh;
4097 
4098         avl_create(&fnp->fn_children, fncmp, sizeof (nfs4_fname_t),
4099             offsetof(nfs4_fname_t, fn_tree));
4100         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4101             "fn_get %p:%s, a new nfs4_fname_t!",
4102             (void *)fnp, fnp->fn_name));
4103         if (parent != NULL) {
4104                 avl_insert(&parent->fn_children, fnp, where);
4105                 mutex_exit(&parent->fn_lock);
4106         }
4107 
4108         return (fnp);
4109 }
4110 
4111 void
4112 fn_hold(nfs4_fname_t *fnp)
4113 {
4114         atomic_inc_32(&fnp->fn_refcnt);
4115         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4116             "fn_hold %p:%s, new refcnt=%d",
4117             (void *)fnp, fnp->fn_name, fnp->fn_refcnt));
4118 }
4119 
4120 /*
4121  * Decrement the reference count of the given fname, and destroy it if its
4122  * reference count goes to zero.  Nulls out the given pointer.
4123  */
4124 
4125 void
4126 fn_rele(nfs4_fname_t **fnpp)
4127 {
4128         nfs4_fname_t *parent;
4129         uint32_t newref;
4130         nfs4_fname_t *fnp;
4131 
4132 recur:
4133         fnp = *fnpp;
4134         *fnpp = NULL;
4135 
4136         mutex_enter(&fnp->fn_lock);
4137         parent = fnp->fn_parent;
4138         if (parent != NULL)
4139                 mutex_enter(&parent->fn_lock);   /* prevent new references */
4140         newref = atomic_dec_32_nv(&fnp->fn_refcnt);
4141         if (newref > 0) {
4142                 NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4143                     "fn_rele %p:%s, new refcnt=%d",
4144                     (void *)fnp, fnp->fn_name, fnp->fn_refcnt));
4145                 if (parent != NULL)
4146                         mutex_exit(&parent->fn_lock);
4147                 mutex_exit(&fnp->fn_lock);
4148                 return;
4149         }
4150 
4151         NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
4152             "fn_rele %p:%s, last reference, deleting...",
4153             (void *)fnp, fnp->fn_name));
4154         if (parent != NULL) {
4155                 avl_remove(&parent->fn_children, fnp);
4156                 mutex_exit(&parent->fn_lock);
4157         }
4158         kmem_free(fnp->fn_name, fnp->fn_len + 1);
4159         sfh4_rele(&fnp->fn_sfh);
4160         mutex_destroy(&fnp->fn_lock);