Home | History | Annotate | Download | only in raidframe

Lines Matching refs:pm

63 rf_paritymap_status(struct rf_paritymap *pm, struct rf_pmstat *ps)
66 if (pm == NULL)
70 ps->region_size = pm->region_size;
71 mutex_enter(&pm->lock);
72 memcpy(&ps->params, &pm->params, sizeof(ps->params));
73 memcpy(ps->dirty, pm->disk_now, sizeof(ps->dirty));
74 memcpy(&ps->ctrs, &pm->ctrs, sizeof(ps->ctrs));
75 mutex_exit(&pm->lock);
85 rf_paritymap_test(struct rf_paritymap *pm, daddr_t sector)
87 unsigned region = sector / pm->region_size;
90 mutex_enter(&pm->lock);
91 retval = isset(pm->disk_boot->bits, region) ? 1 : 0;
92 mutex_exit(&pm->lock);
98 rf_paritymap_begin(struct rf_paritymap *pm, daddr_t offset, daddr_t size)
102 b = offset / pm->region_size;
103 e = (offset + size - 1) / pm->region_size;
106 rf_paritymap_begin_region(pm, i);
111 rf_paritymap_end(struct rf_paritymap *pm, daddr_t offset, daddr_t size)
115 b = offset / pm->region_size;
116 e = (offset + size - 1) / pm->region_size;
119 rf_paritymap_end_region(pm, i);
123 rf_paritymap_begin_region(struct rf_paritymap *pm, unsigned region)
128 pm->ctrs.nwrite++;
131 mutex_enter(&pm->lock);
132 if (pm->current->state[region] < 0)
133 pm->current->state[region] = 0;
136 KASSERT(pm->current->state[region] < 127);
137 pm->current->state[region]++;
139 needs_write = isclr(pm->disk_now->bits, region);
142 KASSERT(pm->current->state[region] == 1);
143 rf_paritymap_write_locked(pm);
146 mutex_exit(&pm->lock);
150 rf_paritymap_end_region(struct rf_paritymap *pm, unsigned region)
154 mutex_enter(&pm->lock);
155 KASSERT(pm->current->state[region] > 0);
156 --pm->current->state[region];
158 if (pm->current->state[region] <= 0) {
159 pm->current->state[region] = -pm->params.cooldown;
160 KASSERT(pm->current->state[region] <= 0);
161 mutex_enter(&pm->lk_flags);
162 if (!(pm->flags & TICKING)) {
163 pm->flags |= TICKING;
164 mutex_exit(&pm->lk_flags);
165 callout_schedule(&pm->ticker,
166 mstohz(pm->params.tickms));
168 mutex_exit(&pm->lk_flags);
170 mutex_exit(&pm->lock);
179 rf_paritymap_write(struct rf_paritymap *pm)
181 mutex_enter(&pm->lock);
182 rf_paritymap_write_locked(pm);
183 mutex_exit(&pm->lock);
186 /* As above, but to be used when pm->lock is already held. */
188 rf_paritymap_write_locked(struct rf_paritymap *pm)
195 w0 = pm->disk_now->bits[i];
196 w = pm->disk_boot->bits[i];
199 if (pm->current->state[i * NBBY + j] != 0)
207 pm->disk_now->bits[i] = w;
209 pm->ctrs.ncachesync += setting + clearing;
210 pm->ctrs.nclearing += clearing;
223 rf_sync_component_caches(pm->raid, 1);
224 rf_paritymap_kern_write(pm->raid, pm->disk_now);
226 rf_sync_component_caches(pm->raid, 1);
231 rf_paritymap_invalidate(struct rf_paritymap *pm)
233 mutex_enter(&pm->lock);
234 memset(pm->disk_boot, (unsigned char)~0, sizeof(*pm->disk_boot));
235 mutex_exit(&pm->lock);
240 rf_paritymap_forceclean(struct rf_paritymap *pm)
242 mutex_enter(&pm->lock);
243 memset(pm->disk_boot, 0, sizeof(*pm->disk_boot));
244 mutex_exit(&pm->lock);
255 struct rf_paritymap *pm = arg;
257 mutex_enter(&pm->lk_flags);
258 pm->flags |= TICKED;
259 mutex_exit(&pm->lk_flags);
261 rf_lock_mutex2(pm->raid->iodone_lock);
262 rf_signal_cond2(pm->raid->iodone_cv); /* XXX */
263 rf_unlock_mutex2(pm->raid->iodone_lock);
271 rf_paritymap_checkwork(struct rf_paritymap *pm)
275 mutex_enter(&pm->lk_flags);
276 if (pm->flags & TICKED) {
279 pm->flags &= ~TICKED;
280 mutex_exit(&pm->lk_flags);
282 mutex_enter(&pm->lock);
284 if (pm->current->state[i] < 0) {
286 pm->current->state[i]++;
287 if (pm->current->state[i] == 0)
293 callout_schedule(&pm->ticker,
294 mstohz(pm->params.tickms));
296 mutex_enter(&pm->lk_flags);
297 pm->flags &= ~TICKING;
298 mutex_exit(&pm->lk_flags);
302 rf_paritymap_write_locked(pm);
303 mutex_exit(&pm->lock);
305 mutex_exit(&pm->lk_flags);
316 rf_paritymap_set_params(struct rf_paritymap *pm,
326 ? params->cooldown : pm->params.cooldown;
328 ? params->tickms : pm->params.tickms;
330 ? params->regions : pm->params.regions;
333 printf("raid%d: cooldown %d out of range\n", pm->raid->raidid,
339 pm->raid->raidid, tickms);
343 regions = rf_paritymap_nreg(pm->raid);
346 pm->raid->raidid, regions, RF_PARITYMAP_NREG);
351 pm->params.cooldown = cooldown;
352 pm->params.tickms = tickms;
354 if (pm->params.regions == 0)
355 pm->params.regions = regions;
358 pm->ctrs.nwrite = pm->ctrs.ncachesync = pm->ctrs.nclearing = 0;
361 raidPtr = pm->raid;
424 rf_paritymap_init(struct rf_paritymap *pm, RF_Raid_t *raid,
430 pm->raid = raid;
431 pm->params.regions = 0;
432 if (0 != rf_paritymap_set_params(pm, params, 0)) {
443 if (0 != rf_paritymap_set_params(pm, &safe, 0))
447 rstripes = howmany(raid->Layout.numStripe, pm->params.regions);
448 pm->region_size = rstripes * raid->Layout.dataSectorsPerStripe;
450 callout_init(&pm->ticker, CALLOUT_MPSAFE);
451 callout_setfunc(&pm->ticker, rf_paritymap_tick, pm);
452 pm->flags = 0;
454 pm->disk_boot = kmem_alloc(sizeof(struct rf_paritymap_ondisk),
456 pm->disk_now = kmem_alloc(sizeof(struct rf_paritymap_ondisk),
458 pm->current = kmem_zalloc(sizeof(struct rf_paritymap_current),
461 rf_paritymap_kern_read(pm->raid, pm->disk_boot);
462 memcpy(pm->disk_now, pm->disk_boot, sizeof(*pm->disk_now));
464 mutex_init(&pm->lock, MUTEX_DEFAULT, IPL_NONE);
465 mutex_init(&pm->lk_flags, MUTEX_DEFAULT, IPL_SOFTCLOCK);
475 rf_paritymap_destroy(struct rf_paritymap *pm, int force)
479 callout_halt(&pm->ticker, NULL); /* XXX stop? halt? */
480 callout_destroy(&pm->ticker);
485 if (pm->current->state[i] < 0)
486 pm->current->state[i] = 0;
489 rf_paritymap_write_locked(pm);
492 mutex_destroy(&pm->lock);
493 mutex_destroy(&pm->lk_flags);
495 kmem_free(pm->disk_boot, sizeof(struct rf_paritymap_ondisk));
496 kmem_free(pm->disk_now, sizeof(struct rf_paritymap_ondisk));
497 kmem_free(pm->current, sizeof(struct rf_paritymap_current));
510 rf_paritymap_rewrite(struct rf_paritymap *pm)
516 for (i = 0; i < pm->params.regions; i++) {
517 mutex_enter(&pm->lock);
518 if (isset(pm->disk_boot->bits, i)) {
519 mutex_exit(&pm->lock);
521 reg_b = i * pm->region_size;
522 reg_e = reg_b + pm->region_size;
523 if (reg_e > pm->raid->totalSectors)
524 reg_e = pm->raid->totalSectors;
526 if (rf_RewriteParityRange(pm->raid, reg_b,
529 if (pm->raid->waitShutdown)
532 mutex_enter(&pm->lock);
533 clrbit(pm->disk_boot->bits, i);
534 rf_paritymap_write_locked(pm);
535 mutex_exit(&pm->lock);
538 mutex_exit(&pm->lock);
543 rf_paritymap_forceclean(pm);
544 rf_paritymap_write(pm);
587 struct rf_paritymap *pm = raidPtr->parity_map;
591 rf_paritymap_destroy(pm, 0);
592 kmem_free(pm, sizeof(*pm));
732 rf_paritymap_init_label(struct rf_paritymap *pm, RF_ComponentLabel_t *clabel)
734 if (pm != NULL) {
737 clabel->parity_map_tickms = pm->params.tickms;
738 clabel->parity_map_ntick = pm->params.cooldown;
745 clabel->parity_map_regions = pm->params.regions;