commit 6246b1c814068505639696bd640ed3f2d38f4f45 Author: Konstantin Belousov Date: Sat Aug 21 21:18:35 2010 +0300 Use device block size for journal blocks diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 039e436..91902da 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -745,7 +745,7 @@ static void handle_written_jnewblk(struct jnewblk *); static void handle_written_jfreeblk(struct jfreeblk *); static void handle_written_jfreefrag(struct jfreefrag *); static void complete_jseg(struct jseg *); -static void jseg_write(struct fs *, struct jblocks *, struct jseg *, +static void jseg_write(struct ufsmount *ump, struct jblocks *, struct jseg *, uint8_t *); static void jaddref_write(struct jaddref *, struct jseg *, uint8_t *); static void jremref_write(struct jremref *, struct jseg *, uint8_t *); @@ -884,7 +884,8 @@ static void handle_jwork(struct workhead *); static struct mkdir *setup_newdir(struct diradd *, ino_t, ino_t, struct buf *, struct mkdir **); static struct jblocks *jblocks_create(void); -static ufs2_daddr_t jblocks_alloc(struct jblocks *, int, int *); +static ufs2_daddr_t jblocks_alloc(struct ufsmount *, struct jblocks *, int, + int *); static void jblocks_free(struct jblocks *, struct mount *, int); static void jblocks_destroy(struct jblocks *); static void jblocks_add(struct jblocks *, ufs2_daddr_t, int); @@ -2133,7 +2134,8 @@ jblocks_create(void) } static ufs2_daddr_t -jblocks_alloc(jblocks, bytes, actual) +jblocks_alloc(ump, jblocks, bytes, actual) + struct ufsmount *ump; struct jblocks *jblocks; int bytes; int *actual; @@ -2143,7 +2145,7 @@ jblocks_alloc(jblocks, bytes, actual) int freecnt; int blocks; - blocks = bytes / DEV_BSIZE; + blocks = bytes / ump->um_devvp->v_bufobj.bo_bsize; jext = &jblocks->jb_extent[jblocks->jb_head]; freecnt = jext->je_blocks - jblocks->jb_off; if (freecnt == 0) { @@ -2155,7 +2157,7 @@ jblocks_alloc(jblocks, bytes, actual) } if (freecnt > blocks) freecnt = blocks; - *actual = freecnt * DEV_BSIZE; + *actual = freecnt * ump->um_devvp->v_bufobj.bo_bsize; daddr = jext->je_daddr + jblocks->jb_off; jblocks->jb_off += freecnt; jblocks->jb_free -= freecnt; @@ -2170,7 +2172,7 @@ jblocks_free(jblocks, mp, bytes) int bytes; { - jblocks->jb_free += bytes / DEV_BSIZE; + jblocks->jb_free += bytes / VFSTOUFS(mp)->um_devvp->v_bufobj.bo_bsize; if (jblocks->jb_suspended) worklist_speedup(); wakeup(jblocks); @@ -2414,7 +2416,8 @@ journal_space(ump, thresh) thresh = jblocks->jb_min; else thresh = jblocks->jb_low; - avail = (ump->softdep_on_journal * JREC_SIZE) / DEV_BSIZE; + avail = (ump->softdep_on_journal * JREC_SIZE) / + ump->um_devvp->v_bufobj.bo_bsize; avail = jblocks->jb_free - avail; return (avail > thresh); @@ -2547,8 +2550,8 @@ softdep_prelink(dvp, vp) } static void -jseg_write(fs, jblocks, jseg, data) - struct fs *fs; +jseg_write(ump, jblocks, jseg, data) + struct ufsmount *ump; struct jblocks *jblocks; struct jseg *jseg; uint8_t *data; @@ -2559,9 +2562,9 @@ jseg_write(fs, jblocks, jseg, data) rec->jsr_seq = jseg->js_seq; rec->jsr_oldest = jblocks->jb_oldestseq; rec->jsr_cnt = jseg->js_cnt; - rec->jsr_blocks = jseg->js_size / DEV_BSIZE; + rec->jsr_blocks = jseg->js_size / ump->um_devvp->v_bufobj.bo_bsize; rec->jsr_crc = 0; - rec->jsr_time = fs->fs_mtime; + rec->jsr_time = ump->um_fs->fs_mtime; } static inline void @@ -2711,19 +2714,21 @@ softdep_process_journal(mp, flags) int size; int cnt; int off; + int devbsize; if ((mp->mnt_kern_flag & MNTK_SUJ) == 0) return; ump = VFSTOUFS(mp); fs = ump->um_fs; jblocks = ump->softdep_jblocks; + devbsize = ump->um_devvp->v_bufobj.bo_bsize; /* * We write anywhere between a disk block and fs block. The upper * bound is picked to prevent buffer cache fragmentation and limit * processing time per I/O. */ - jrecmin = (DEV_BSIZE / JREC_SIZE) - 1; /* -1 for seg header */ - jrecmax = (fs->fs_bsize / DEV_BSIZE) * jrecmin; + jrecmin = (devbsize / JREC_SIZE) - 1; /* -1 for seg header */ + jrecmax = (fs->fs_bsize / devbsize) * jrecmin; segwritten = 0; while ((cnt = ump->softdep_on_journal) != 0) { /* @@ -2778,7 +2783,7 @@ softdep_process_journal(mp, flags) */ cnt = ump->softdep_on_journal; if (cnt < jrecmax) - size = howmany(cnt, jrecmin) * DEV_BSIZE; + size = howmany(cnt, jrecmin) * devbsize; else size = fs->fs_bsize; /* @@ -2786,9 +2791,9 @@ softdep_process_journal(mp, flags) * for truncation of the requested size if enough contiguous * space was not available. */ - bp->b_blkno = jblocks_alloc(jblocks, size, &size); + bp->b_blkno = jblocks_alloc(ump, jblocks, size, &size); bp->b_lblkno = bp->b_blkno; - bp->b_offset = bp->b_blkno * DEV_BSIZE; + bp->b_offset = bp->b_blkno * devbsize; bp->b_bcount = size; bp->b_bufobj = &ump->um_devvp->v_bufobj; bp->b_flags &= ~B_INVAL; @@ -2798,7 +2803,7 @@ softdep_process_journal(mp, flags) * sequence number to it and link it in-order. */ cnt = MIN(ump->softdep_on_journal, - (size / DEV_BSIZE) * jrecmin); + (size / devbsize) * jrecmin); jseg->js_buf = bp; jseg->js_cnt = cnt; jseg->js_refs = cnt + 1; /* Self ref. */ @@ -2817,8 +2822,8 @@ softdep_process_journal(mp, flags) while ((wk = LIST_FIRST(&ump->softdep_journal_pending)) != NULL) { /* Place a segment header on every device block. */ - if ((off % DEV_BSIZE) == 0) { - jseg_write(fs, jblocks, jseg, data); + if ((off % devbsize) == 0) { + jseg_write(ump, jblocks, jseg, data); off += JREC_SIZE; data = bp->b_data + off; }