Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ffs Fix block shift to work with different device bl...



details:   https://anonhg.NetBSD.org/src/rev/03bf61d32d37
branches:  trunk
changeset: 751297:03bf61d32d37
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jan 31 10:54:10 2010 +0000

description:
Fix block shift to work with different device block sizes.

Unlike other filesystems this has some side issues because
the shift values are stored in the superblock and because
userland utitlies share the same fsbtodb macros.

-> the kernel now ignores the value stored in the superblock.
-> the macro adaption is only done for defined(_KERNEL) code.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |  20 ++++++++------------
 sys/ufs/ffs/fs.h         |   7 ++++++-
 2 files changed, 14 insertions(+), 13 deletions(-)

diffs (100 lines):

diff -r 0636a9b6f98c -r 03bf61d32d37 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Sun Jan 31 10:50:23 2010 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Sun Jan 31 10:54:10 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.255 2010/01/31 10:50:23 mlelstv Exp $ */
+/*     $NetBSD: ffs_vfsops.c,v 1.256 2010/01/31 10:54:10 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.255 2010/01/31 10:50:23 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.256 2010/01/31 10:54:10 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -585,8 +585,6 @@
        struct fs *fs, *newfs;
        struct partinfo dpart;
        int i, bsize, blks, error;
-       uint64_t numsecs;
-       unsigned secsize;
        int32_t *lp;
        struct ufsmount *ump;
        daddr_t sblockloc;
@@ -608,11 +606,9 @@
         * Step 2: re-read superblock from disk.
         */
        fs = ump->um_fs;
-       error = getdisksize(devvp, &numsecs, &secsize);
-       if (error)
-               secsize = DEV_BSIZE;
+
        /* XXX we don't handle possibility that superblock moved. */
-       error = bread(devvp, fs->fs_sblockloc / secsize, fs->fs_sbsize,
+       error = bread(devvp, fs->fs_sblockloc / DEV_BSIZE, fs->fs_sbsize,
                      NOCRED, 0, &bp);
        if (error) {
                brelse(bp, 0);
@@ -665,7 +661,7 @@
                /* Manually look for an apple ufs label, and if a valid one
                 * is found, then treat it like an Apple UFS filesystem anyway
                 */
-               error = bread(devvp, (daddr_t)(APPLEUFS_LABEL_OFFSET / secsize),
+               error = bread(devvp, (daddr_t)(APPLEUFS_LABEL_OFFSET / DEV_BSIZE),
                        APPLEUFS_LABEL_SIZE, cred, 0, &bp);
                if (error) {
                        brelse(bp, 0);
@@ -884,7 +880,7 @@
                        fs = NULL;
                        goto out;
                }
-               error = bread(devvp, sblock_try[i] / secsize, SBLOCKSIZE, cred,
+               error = bread(devvp, sblock_try[i] / DEV_BSIZE, SBLOCKSIZE, cred,
                              0, &bp);
                if (error) {
                        fs = NULL;
@@ -1032,7 +1028,7 @@
                /* Manually look for an apple ufs label, and if a valid one
                 * is found, then treat it like an Apple UFS filesystem anyway
                 */
-               error = bread(devvp, (daddr_t)(APPLEUFS_LABEL_OFFSET / size),
+               error = bread(devvp, (daddr_t)(APPLEUFS_LABEL_OFFSET / DEV_BSIZE),
                        APPLEUFS_LABEL_SIZE, cred, 0, &bp);
                if (error)
                        goto out;
@@ -1186,7 +1182,7 @@
        ump->um_devvp = devvp;
        ump->um_nindir = fs->fs_nindir;
        ump->um_lognindir = ffs(fs->fs_nindir) - 1;
-       ump->um_bptrtodb = fs->fs_fsbtodb;
+       ump->um_bptrtodb = fs->fs_fshift - DEV_BSHIFT;
        ump->um_seqinc = fs->fs_frag;
        for (i = 0; i < MAXQUOTAS; i++)
                ump->um_quotas[i] = NULLVP;
diff -r 0636a9b6f98c -r 03bf61d32d37 sys/ufs/ffs/fs.h
--- a/sys/ufs/ffs/fs.h  Sun Jan 31 10:50:23 2010 +0000
+++ b/sys/ufs/ffs/fs.h  Sun Jan 31 10:54:10 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fs.h,v 1.54 2009/06/28 09:26:18 ad Exp $       */
+/*     $NetBSD: fs.h,v 1.55 2010/01/31 10:54:10 mlelstv Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -599,8 +599,13 @@
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.
  */
+#if defined (_KERNEL)
+#define        fsbtodb(fs, b)  ((b) << ((fs)->fs_fshift - DEV_BSHIFT))
+#define        dbtofsb(fs, b)  ((b) >> ((fs)->fs_fshift - DEV_BSHIFT))
+#else
 #define        fsbtodb(fs, b)  ((b) << (fs)->fs_fsbtodb)
 #define        dbtofsb(fs, b)  ((b) >> (fs)->fs_fsbtodb)
+#endif
 
 /*
  * Cylinder group macros to locate things in cylinder groups.



Home | Main Index | Thread Index | Old Index