/* * move deltas from deltamap into the log */ void top_log(ufsvfs_t *ufsvfsp, char *va, offset_t vamof, off_t nb, caddr_t buf, uint32_t bufsz) { ml_unit_t *ul = ufsvfsp->vfs_log; mapentry_t *me; offset_t hmof; uint32_t hnb, nb1; /* * needed for the roll thread's heuristic */ ul->un_logmap->mtm_ref = 1; if (buf && ufs_crb_enable) { ASSERT((bufsz & DEV_BMASK) == 0); /* * Move any deltas to the logmap. Split requests that * straddle MAPBLOCKSIZE hash boundaries (i.e. summary info). */ for (hmof = vamof - (va - buf), nb1 = nb; bufsz; bufsz -= hnb, hmof += hnb, buf += hnb, nb1 -= hnb) { hnb = MAPBLOCKSIZE - (hmof & MAPBLOCKOFF); if (hnb > bufsz) hnb = bufsz; me = deltamap_remove(ul->un_deltamap, MAX(hmof, vamof), MIN(hnb, nb1)); if (me) { logmap_add_buf(ul, va, hmof, me, buf, hnb); } } } else { /* * if there are deltas */ me = deltamap_remove(ul->un_deltamap, vamof, nb); if (me) { /* * move to logmap */ logmap_add(ul, va, vamof, me); } } ASSERT((ul->un_matamap == NULL) || matamap_within(ul->un_matamap, vamof, nb)); }
void lqfs_write_strategy(ml_unit_t *ul, buf_t *bp) { offset_t mof = ldbtob(bp->b_blkno); off_t nb = bp->b_bcount; char *va; mapentry_t *me; uchar_t ord; qfsvfs_t *qfsvfsp = ul->un_qfsvfs; #ifdef LUFS #else caddr_t buf; va = bp_mapin_common(bp, VM_SLEEP); buf = bp->b_un.b_addr; #endif /* LUFS */ ASSERT((nb & DEV_BMASK) == 0); ul->un_logmap->mtm_ref = 1; /* * if there are deltas, move into log */ ord = lqfs_find_ord(qfsvfsp, bp); #ifdef LUFS me = deltamap_remove(ul->un_deltamap, mof, ord, nb); if (me) { va = bp_mapin_common(bp, VM_SLEEP); ASSERT(((ul->un_debug & MT_WRITE_CHECK) == 0) || (ul->un_matamap == NULL)|| matamap_within(ul->un_matamap, mof, ord, nb)); /* * move to logmap */ if (qfs_crb_enable) { logmap_add_buf(ul, va, mof, ord, me, bp->b_un.b_addr, nb); } else { logmap_add(ul, va, mof, ord, me); } if (ul->un_flags & LDL_ERROR) { bp->b_flags |= B_ERROR; bp->b_error = EIO; } biodone(bp); return; } #else if (buf && qfs_crb_enable) { uint32_t bufsz; offset_t vamof; offset_t hmof; uchar_t vaord; uchar_t hord; uint32_t hnb, nb1; bufsz = bp->b_bcount; ASSERT((bufsz & DEV_BMASK) == 0); vamof = mof; vaord = ord; /* * Move any deltas to the logmap. Split requests that * straddle MAPBLOCKSIZE hash boundaries (i.e. summary info). */ for (hmof = vamof - (va - buf), nb1 = nb; bufsz; bufsz -= hnb, hmof += hnb, buf += hnb, nb1 -= hnb) { hnb = MAPBLOCKSIZE - (hmof & MAPBLOCKOFF); if (hnb > bufsz) { hnb = bufsz; } LQFS_MSG(CE_WARN, "lqfs_write_strategy(): Removing " "deltamap deltas within mof 0x%llx ord %d nb %d\n", MAX(hmof, vamof), vaord, MIN(hnb, nb1)); me = deltamap_remove(ul->un_deltamap, MAX(hmof, vamof), vaord, MIN(hnb, nb1)); hord = vaord; if (me) { logmap_add_buf(ul, va, hmof, hord, me, buf, hnb); if (ul->un_flags & LDL_ERROR) { bp->b_flags |= B_ERROR; bp->b_error = EIO; } biodone(bp); return; } } } else { /* * if there are deltas */ LQFS_MSG(CE_WARN, "lqfs_write_strategy(): Removing " "deltamap deltas within mof 0x%x ord %d nb %d\n", mof, ord, nb); me = deltamap_remove(ul->un_deltamap, mof, ord, nb); if (me) { ASSERT(((ul->un_debug & MT_WRITE_CHECK) == 0) || (ul->un_matamap == NULL)|| matamap_within(ul->un_matamap, mof, ord, nb)); /* * move to logmap */ logmap_add(ul, va, mof, ord, me); if (ul->un_flags & LDL_ERROR) { bp->b_flags |= B_ERROR; bp->b_error = EIO; } biodone(bp); return; } } #endif /* LUFS */ if (ul->un_flags & LDL_ERROR) { bp->b_flags |= B_ERROR; bp->b_error = EIO; biodone(bp); return; } /* * Check that we are not updating metadata, or if so then via B_PHYS. */ ASSERT((ul->un_matamap == NULL) || !(matamap_overlap(ul->un_matamap, mof, ord, nb) && ((bp->b_flags & B_PHYS) == 0))); LQFS_SET_IOTSTAMP(ul->un_qfsvfs, ddi_get_lbolt()); logstats.ls_lwrites.value.ui64++; #ifdef LQFS_TODO_SNAPSHOT /* If snapshots are enabled, write through the snapshot driver */ if (ul->un_qfsvfs->vfs_snapshot) { fssnap_strategy(&ul->un_qfsvfs->vfs_snapshot, bp); } else { #endif /* LQFS_TODO_SNAPSHOT */ if ((bp->b_flags & B_READ) == 0) { LQFS_MSG(CE_WARN, "lqfs_write_strategy(): " "bdev_strategy writing mof 0x%x edev %ld " "nb %d\n", bp->b_blkno * 512, bp->b_edev, bp->b_bcount); } else { LQFS_MSG(CE_WARN, "lqfs_write_strategy(): " "bdev_strategy reading mof 0x%x edev %ld " "nb %d\n", bp->b_blkno * 512, bp->b_edev, bp->b_bcount); } (void) bdev_strategy(bp); #ifdef LQFS_TODO_SNAPSHOT } #endif /* LQFS_TODO_SNAPSHOT */ #ifdef LQFS_TODO_STATS lwp_stat_update(LWP_STAT_OUBLK, 1); #endif /* LQFS_TODO_STATS */ }