Date: Sat, 12 Feb 2011 12:52:13 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r218602 - head/sys/ufs/ffs Message-ID: <201102121252.p1CCqDog002089@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sat Feb 12 12:52:12 2011 New Revision: 218602 URL: http://svn.freebsd.org/changeset/base/218602 Log: Use the native sector size of the device backing the UFS volume for SU+J journal blocks, instead of hard coding 512 byte sector size. Journal need to atomically write the block, that can only be guaranteed at the device sector size, not larger. Attempt to write less then sector size results in driver errors. Note that this is the first structure in UFS that depends on the sector size. Other elements are written in the units of fragments. In collaboration with: pho Reviewed by: jeff Tested by: bz, pho Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/fs.h Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sat Feb 12 12:46:00 2011 (r218601) +++ head/sys/ufs/ffs/ffs_softdep.c Sat Feb 12 12:52:12 2011 (r218602) @@ -750,7 +750,7 @@ static void handle_written_jnewblk(struc 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 *); @@ -2557,8 +2557,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; @@ -2569,9 +2569,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 @@ -2721,19 +2721,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) { /* @@ -2788,7 +2790,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; /* @@ -2808,7 +2810,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. */ @@ -2827,8 +2829,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; } Modified: head/sys/ufs/ffs/fs.h ============================================================================== --- head/sys/ufs/ffs/fs.h Sat Feb 12 12:46:00 2011 (r218601) +++ head/sys/ufs/ffs/fs.h Sat Feb 12 12:52:12 2011 (r218602) @@ -682,7 +682,7 @@ struct jsegrec { uint64_t jsr_seq; /* Our sequence number */ uint64_t jsr_oldest; /* Oldest valid sequence number */ uint16_t jsr_cnt; /* Count of valid records */ - uint16_t jsr_blocks; /* Count of DEV_BSIZE blocks. */ + uint16_t jsr_blocks; /* Count of device bsize blocks. */ uint32_t jsr_crc; /* 32bit crc of the valid space */ ufs_time_t jsr_time; /* timestamp for mount instance */ };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102121252.p1CCqDog002089>