Lines Matching refs:sp
55 rc_snapshot_t *sp;
56 sp = uu_zalloc(sizeof (*sp));
58 (void) pthread_mutex_init(&sp->rs_lock, NULL);
59 (void) pthread_cond_init(&sp->rs_cv, NULL);
61 sp->rs_refcnt++;
62 return (sp);
66 snapshot_free(rc_snapshot_t *sp)
70 assert(sp->rs_refcnt == 0 && sp->rs_childref == 0);
72 (void) pthread_mutex_destroy(&sp->rs_lock);
73 (void) pthread_cond_destroy(&sp->rs_cv);
75 for (lvl = sp->rs_levels; lvl != NULL; lvl = next) {
78 assert(lvl->rsl_parent == sp);
88 uu_free(sp);
92 rc_snapshot_hold(rc_snapshot_t *sp)
94 (void) pthread_mutex_lock(&sp->rs_lock);
95 sp->rs_refcnt++;
96 assert(sp->rs_refcnt > 0);
97 (void) pthread_mutex_unlock(&sp->rs_lock);
101 rc_snapshot_rele(rc_snapshot_t *sp)
104 (void) pthread_mutex_lock(&sp->rs_lock);
105 assert(sp->rs_refcnt > 0);
106 sp->rs_refcnt--;
107 done = ((sp->rs_flags & RC_SNAPSHOT_DEAD) &&
108 sp->rs_refcnt == 0 && sp->rs_childref == 0);
109 (void) pthread_mutex_unlock(&sp->rs_lock);
112 snapshot_free(sp);
118 rc_snapshot_t *sp = lvl->rsl_parent;
119 (void) pthread_mutex_lock(&sp->rs_lock);
120 sp->rs_childref++;
121 assert(sp->rs_childref > 0);
122 (void) pthread_mutex_unlock(&sp->rs_lock);
129 rc_snapshot_t *sp = lvl->rsl_parent;
130 (void) pthread_mutex_lock(&sp->rs_lock);
131 assert(sp->rs_childref > 0);
132 sp->rs_childref--;
133 done = ((sp->rs_flags & RC_SNAPSHOT_DEAD) &&
134 sp->rs_refcnt == 0 && sp->rs_childref == 0);
135 (void) pthread_mutex_unlock(&sp->rs_lock);
138 snapshot_free(sp);
159 rc_snapshot_t *sp;
164 for (sp = bp->sb_head; sp != NULL; sp = sp->rs_hash_next) {
165 if (sp->rs_snap_id == snap_id) {
166 rc_snapshot_hold(sp);
167 return (sp);
174 snapshot_insert_unlocked(snapshot_bucket_t *bp, rc_snapshot_t *sp)
177 assert(bp == SNAPSHOT_BUCKET(sp->rs_snap_id));
179 assert(sp->rs_hash_next == NULL);
181 sp->rs_hash_next = bp->sb_head;
182 bp->sb_head = sp;
186 snapshot_remove_unlocked(snapshot_bucket_t *bp, rc_snapshot_t *sp)
191 assert(bp == SNAPSHOT_BUCKET(sp->rs_snap_id));
193 assert(sp->rs_hash_next == NULL);
196 if (*spp == sp)
199 assert(*spp == sp);
200 *spp = sp->rs_hash_next;
201 sp->rs_hash_next = NULL;
215 rc_snapshot_t *sp;
219 sp = snapshot_lookup_unlocked(bp, snap_id);
220 if (sp != NULL) {
222 (void) pthread_mutex_lock(&sp->rs_lock);
223 while (sp->rs_flags & RC_SNAPSHOT_FILLING)
224 (void) pthread_cond_wait(&sp->rs_cv, &sp->rs_lock);
226 if (sp->rs_flags & RC_SNAPSHOT_DEAD) {
227 (void) pthread_mutex_unlock(&sp->rs_lock);
228 rc_snapshot_rele(sp);
231 assert(sp->rs_flags & RC_SNAPSHOT_READY);
232 (void) pthread_mutex_unlock(&sp->rs_lock);
233 *snpp = sp;
236 sp = snapshot_alloc();
237 sp->rs_snap_id = snap_id;
238 sp->rs_flags |= RC_SNAPSHOT_FILLING;
239 snapshot_insert_unlocked(bp, sp);
245 r = object_fill_snapshot(sp);
253 snapshot_remove_unlocked(bp, sp);
256 (void) pthread_mutex_lock(&sp->rs_lock);
257 sp->rs_flags &= ~RC_SNAPSHOT_FILLING;
258 sp->rs_flags |= RC_SNAPSHOT_DEAD;
259 (void) pthread_cond_broadcast(&sp->rs_cv);
260 (void) pthread_mutex_unlock(&sp->rs_lock);
261 rc_snapshot_rele(sp); /* may free sp */
264 (void) pthread_mutex_lock(&sp->rs_lock);
265 sp->rs_flags &= ~RC_SNAPSHOT_FILLING;
266 sp->rs_flags |= RC_SNAPSHOT_READY;
267 (void) pthread_cond_broadcast(&sp->rs_cv);
268 (void) pthread_mutex_unlock(&sp->rs_lock);
269 *snpp = sp;