From owner-svn-src-all@FreeBSD.ORG Sat Feb 12 13:17:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA9AD106564A; Sat, 12 Feb 2011 13:17:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B8A238FC1A; Sat, 12 Feb 2011 13:17:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1CDHEQJ002746; Sat, 12 Feb 2011 13:17:14 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1CDHE9v002742; Sat, 12 Feb 2011 13:17:14 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201102121317.p1CDHE9v002742@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 12 Feb 2011 13:17:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218604 - head/sbin/fsck_ffs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Feb 2011 13:17:14 -0000 Author: kib Date: Sat Feb 12 13:17:14 2011 New Revision: 218604 URL: http://svn.freebsd.org/changeset/base/218604 Log: In checker, read journal by sectors. Due to UFS insistence to pretend that device sector size is 512 bytes, sector size is obtained from ioctl(DIOCGSECTORSIZE) for real devices, and from the label otherwise. The file images without label have to be made with 512 sector size. In collaboration with: pho Reviewed by: jeff Tested by: bz, pho Modified: head/sbin/fsck_ffs/fsck.h head/sbin/fsck_ffs/setup.c head/sbin/fsck_ffs/suj.c Modified: head/sbin/fsck_ffs/fsck.h ============================================================================== --- head/sbin/fsck_ffs/fsck.h Sat Feb 12 13:12:45 2011 (r218603) +++ head/sbin/fsck_ffs/fsck.h Sat Feb 12 13:17:14 2011 (r218604) @@ -268,6 +268,7 @@ char snapname[BUFSIZ]; /* when doing sna char *cdevname; /* name of device being checked */ long dev_bsize; /* computed value of DEV_BSIZE */ long secsize; /* actual disk sector size */ +long real_dev_bsize; char nflag; /* assume a no response */ char yflag; /* assume a yes response */ int bkgrdflag; /* use a snapshot to run on an active system */ Modified: head/sbin/fsck_ffs/setup.c ============================================================================== --- head/sbin/fsck_ffs/setup.c Sat Feb 12 13:12:45 2011 (r218603) +++ head/sbin/fsck_ffs/setup.c Sat Feb 12 13:17:14 2011 (r218604) @@ -446,7 +446,7 @@ sblock_init(void) if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errx(EEXIT, "cannot allocate space for superblock"); if ((lp = getdisklabel(NULL, fsreadfd))) - dev_bsize = secsize = lp->d_secsize; + real_dev_bsize = dev_bsize = secsize = lp->d_secsize; else dev_bsize = secsize = DEV_BSIZE; } Modified: head/sbin/fsck_ffs/suj.c ============================================================================== --- head/sbin/fsck_ffs/suj.c Sat Feb 12 13:12:45 2011 (r218603) +++ head/sbin/fsck_ffs/suj.c Sat Feb 12 13:17:14 2011 (r218604) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -201,6 +202,11 @@ opendisk(const char *devnam) disk->d_error); } fs = &disk->d_fs; + if (real_dev_bsize == 0 && ioctl(disk->d_fd, DIOCGSECTORSIZE, + &real_dev_bsize) == -1) + real_dev_bsize = secsize; + if (debug) + printf("dev_bsize %ld\n", real_dev_bsize); } /* @@ -2262,7 +2268,7 @@ suj_build(void) rec = (union jrec *)seg->ss_blk; for (i = 0; i < seg->ss_rec.jsr_cnt; off += JREC_SIZE, rec++) { /* skip the segrec. */ - if ((off % DEV_BSIZE) == 0) + if ((off % real_dev_bsize) == 0) continue; switch (rec->rec_jrefrec.jr_op) { case JOP_ADDREF: @@ -2340,7 +2346,7 @@ suj_prune(void) TAILQ_FOREACH_SAFE(seg, &allsegs, ss_next, segn) { if (!discard && newseq++ == seg->ss_rec.jsr_seq) { jrecs += seg->ss_rec.jsr_cnt; - jbytes += seg->ss_rec.jsr_blocks * DEV_BSIZE; + jbytes += seg->ss_rec.jsr_blocks * real_dev_bsize; continue; } discard = 1; @@ -2440,7 +2446,7 @@ jblocks_next(struct jblocks *jblocks, in int freecnt; int blocks; - blocks = bytes / DEV_BSIZE; + blocks = bytes / disk->d_bsize; jext = &jblocks->jb_extent[jblocks->jb_head]; freecnt = jext->je_blocks - jblocks->jb_off; if (freecnt == 0) { @@ -2452,7 +2458,7 @@ jblocks_next(struct jblocks *jblocks, in } if (freecnt > blocks) freecnt = blocks; - *actual = freecnt * DEV_BSIZE; + *actual = freecnt * disk->d_bsize; daddr = jext->je_daddr + jblocks->jb_off; return (daddr); @@ -2466,7 +2472,7 @@ static void jblocks_advance(struct jblocks *jblocks, int bytes) { - jblocks->jb_off += bytes / DEV_BSIZE; + jblocks->jb_off += bytes / disk->d_bsize; } static void @@ -2563,7 +2569,7 @@ restart: } for (rec = (void *)block; size; size -= recsize, rec = (struct jsegrec *)((uintptr_t)rec + recsize)) { - recsize = DEV_BSIZE; + recsize = real_dev_bsize; if (rec->jsr_time != fs->fs_mtime) { if (debug) printf("Rec time %jd != fs mtime %jd\n", @@ -2579,7 +2585,7 @@ restart: continue; } blocks = rec->jsr_blocks; - recsize = blocks * DEV_BSIZE; + recsize = blocks * real_dev_bsize; if (recsize > size) { /* * We may just have run out of buffer, restart @@ -2592,7 +2598,7 @@ restart: if (debug) printf("Found invalid segsize %d > %d\n", recsize, size); - recsize = DEV_BSIZE; + recsize = real_dev_bsize; jblocks_advance(suj_jblocks, recsize); continue; } @@ -2600,15 +2606,15 @@ restart: * Verify that all blocks in the segment are present. */ for (i = 1; i < blocks; i++) { - recn = (void *) - ((uintptr_t)rec) + i * DEV_BSIZE; + recn = (void *)((uintptr_t)rec) + i * + real_dev_bsize; if (recn->jsr_seq == rec->jsr_seq && recn->jsr_time == rec->jsr_time) continue; if (debug) printf("Incomplete record %jd (%d)\n", rec->jsr_seq, i); - recsize = i * DEV_BSIZE; + recsize = i * real_dev_bsize; jblocks_advance(suj_jblocks, recsize); goto restart; }