From owner-freebsd-current Wed Sep 9 01:18:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA05391 for freebsd-current-outgoing; Wed, 9 Sep 1998 01:18:54 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA05383 for ; Wed, 9 Sep 1998 01:18:51 -0700 (PDT) (envelope-from dag-erli@ifi.uio.no) Received: from hrotti.ifi.uio.no (2602@hrotti.ifi.uio.no [129.240.64.15]) by ifi.uio.no (8.8.8/8.8.7/ifi0.2) with ESMTP id KAA23100; Wed, 9 Sep 1998 10:18:42 +0200 (MET DST) Received: (from dag-erli@localhost) by hrotti.ifi.uio.no ; Wed, 9 Sep 1998 10:18:41 +0200 (MET DST) Mime-Version: 1.0 To: Bruce Evans Cc: tmb@rcru.rl.ac.uk, freebsd-current@FreeBSD.ORG Subject: [LONG PATCH] Re: 2048-byte sector support for DOS filesystem. References: <199809090303.NAA16240@godzilla.zeta.org.au> Organization: University of Oslo, Department of Informatics X-url: http://www.stud.ifi.uio.no/~dag-erli/ X-other-addresses: 'finger dag-erli@ifi.uio.no' for a list X-disclaimer-1: The views expressed in this article are mine alone, and do X-disclaimer-2: not necessarily coincide with those of any organisation or X-disclaimer-3: company with which I am or have been affiliated. X-Stop-Spam: http://www.cauce.org/ From: dag-erli@ifi.uio.no (Dag-Erling =?iso-8859-1?Q?Co=EFdan?= =?iso-8859-1?Q?Sm=F8rgrav?= ) Date: 09 Sep 1998 10:18:41 +0200 In-Reply-To: Bruce Evans's message of "Wed, 9 Sep 1998 13:03:51 +1000" Message-ID: Lines: 256 X-Mailer: Gnus v5.5/Emacs 19.34 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.freebsd.org id BAA05387 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Bruce Evans writes: > > Such is my understanding. Somebody in the CAM team will have to > > confirm it. > CAM should have no affect on this, since the driver already supports > 2048-byte sectors. msdosfs doesn't support them. It begins by > attempting to read a 512-byte boot sector... Ah. I was thinking of the inability of the od driver to handle media with >512 byte sectors. Then this is a different problem altogether, which the second patch in kern-7210 addresses: ---------------------------------------------------------------------- Index: src/sys/kern/subr_diskslice.c =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/kern/subr_diskslice.c,v retrieving revision 1.30.2.4 diff -u -r1.30.2.4 subr_diskslice.c --- subr_diskslice.c 1998/06/06 03:13:54 1.30.2.4 +++ subr_diskslice.c 1998/07/06 15:41:18 @@ -210,6 +210,8 @@ ic->ic_prev_iodone_chain = bp->b_iodone_chain; ic->ic_args[0].ia_long = (LABELSECTOR + labelsect - blkno) << DEV_BSHIFT; + if (lp) + ic->ic_args[0].ia_long *= lp->d_secsize / DEV_BSIZE; ic->ic_args[1].ia_ptr = sp; bp->b_flags |= B_CALL; bp->b_iodone = dsiodone; Index: src/sys/msdosfs/msdosfs_fat.c =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/msdosfs/msdosfs_fat.c,v retrieving revision 1.10 diff -u -r1.10 msdosfs_fat.c --- msdosfs_fat.c 1995/12/03 16:41:57 1.10 +++ msdosfs_fat.c 1998/07/06 14:16:23 @@ -116,7 +116,7 @@ * pmp->pm_BytesPerSec; bn += pmp->pm_fatblk; if (bnp) - *bnp = bn; + *bnp = bn * pmp->pm_SecBlkRatio; if (sizep) *sizep = size; if (bop) @@ -185,7 +185,7 @@ return E2BIG; } if (bnp) - *bnp = pmp->pm_rootdirblk + (findcn * pmp->pm_SectPerClust); + *bnp = (pmp->pm_rootdirblk + (findcn * pmp->pm_SectPerClust)) * pmp->pm_SecBlkRatio; if (cnp) *cnp = MSDOSFSROOT; return 0; @@ -340,7 +340,7 @@ * bwrite()'s and really slow things down. */ for (i = 1; i < pmp->pm_FATs; i++) { - fatbn += pmp->pm_FATsecs; + fatbn += pmp->pm_FATsecs * pmp->pm_SecBlkRatio; /* getblk() never fails */ bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0); bcopy(bp->b_data, bpn->b_data, bp->b_bcount); Index: src/sys/msdosfs/msdosfs_vfsops.c =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/msdosfs/msdosfs_vfsops.c,v retrieving revision 1.13.2.1 diff -u -r1.13.2.1 msdosfs_vfsops.c --- msdosfs_vfsops.c 1998/03/23 18:28:14 1.13.2.1 +++ msdosfs_vfsops.c 1998/07/06 14:16:23 @@ -58,6 +58,9 @@ #include #include #include +#include +#include +#include #include #include @@ -273,6 +276,8 @@ struct buf *bp0 = NULL; struct byte_bpb33 *b33; struct byte_bpb50 *b50; + struct partinfo msdosfspart; + int secsize; #ifdef PC98 u_int pc98_wrk; u_int Phy_Sector_Size; @@ -300,14 +305,16 @@ if (error) return error; needclose = 1; -#ifdef HDSUPPORT + /* * Put this in when we support reading dos filesystems from * partitioned harddisks. */ - if (VOP_IOCTL(devvp, DIOCGPART, &msdosfspart, FREAD, NOCRED, p) == 0) { + if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&msdosfspart, FREAD, NOCRED, p) == 0) { + secsize = msdosfspart.disklab->d_secsize; + } else { + secsize = DEV_BSIZE; } -#endif /* * Read the boot sector of the filesystem, and then check the boot @@ -319,7 +326,7 @@ devvp->v_flag &= 0xffff; error = bread(devvp, 0, 1024, NOCRED, &bp0); #else - error = bread(devvp, 0, 512, NOCRED, &bp0); + error = bread(devvp, 0, secsize, NOCRED, &bp0); #endif if (error) goto error_exit; @@ -349,6 +356,9 @@ pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); bzero((caddr_t)pmp, sizeof *pmp); pmp->pm_mountp = mp; + + /* calculate the ratio of sector size to DEV_BSIZE */ + pmp->pm_SecBlkRatio = secsize/DEV_BSIZE; /* * Compute several useful quantities from the bpb in the Index: src/sys/msdosfs/msdosfsmount.h =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/msdosfs/msdosfsmount.h,v retrieving revision 1.6 diff -u -r1.6 msdosfsmount.h --- msdosfsmount.h 1996/01/30 22:57:25 1.6 +++ msdosfsmount.h 1998/07/06 14:16:23 @@ -60,6 +60,9 @@ mode_t pm_mask; /* mask to and with file protection bits */ struct vnode *pm_devvp; /* vnode for block device mntd */ struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */ + int pm_SecBlkRatio; /* How many DEV_BSIZE blocks fit inside + * a physical sector + */ u_long pm_fatblk; /* block # of first FAT */ u_long pm_rootdirblk; /* block # of root directory */ u_long pm_rootdirsize; /* size in blocks (not clusters) */ @@ -124,20 +127,20 @@ * Map a cluster number into a filesystem relative block number. */ #define cntobn(pmp, cn) \ - ((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster) + (((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster) * (pmp)->pm_SecBlkRatio) /* * Map a filesystem relative block number back into a cluster number. */ #define bntocn(pmp, bn) \ - ((((bn) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST) + (((((bn)/((pmp)->pm_SecBlkRatio)) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST) /* * Calculate block number for directory entry in root dir, offset dirofs */ #define roottobn(pmp, dirofs) \ - (((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \ - + (pmp)->pm_rootdirblk) + ((((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \ + + (pmp)->pm_rootdirblk) * (pmp)->pm_SecBlkRatio) /* * Calculate block number for directory entry at cluster dirclu, offset Index: src/sys/ufs/ffs/ffs_vfsops.c =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/ufs/ffs/ffs_vfsops.c,v retrieving revision 1.41.2.2 diff -u -r1.41.2.2 ffs_vfsops.c --- ffs_vfsops.c 1997/03/26 20:05:53 1.41.2.2 +++ ffs_vfsops.c 1998/07/06 14:16:24 @@ -461,9 +461,8 @@ struct buf *bp; register struct fs *fs; dev_t dev = devvp->v_rdev; - struct partinfo dpart; caddr_t base, space; - int havepart = 0, blks; + int blks; int error, i, size; int ronly; u_int strsize; @@ -491,12 +490,16 @@ error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); if (error) return (error); +#if 0 if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) size = DEV_BSIZE; else { havepart = 1; size = dpart.disklab->d_secsize; } +#else + size = DEV_BSIZE; +#endif bp = NULL; ump = NULL; @@ -519,6 +522,9 @@ goto out; } } + /* XXX bread assumes b_blkno in DEV_BSIZE unit, calculate fsbtodb */ + fs->fs_fsbtodb = ffs(fs->fs_fsize / DEV_BSIZE) - 1; + ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK); bzero((caddr_t)ump, sizeof *ump); ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT, @@ -1051,6 +1057,10 @@ /* Restore compatibility to old file systems. XXX */ if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ ((struct fs *)bp->b_data)->fs_nrpos = -1; /* XXX */ + + /* XXX restore fsbtodb which was modified for fixed b_blkno unit */ + ((struct fs *)bp->b_data)->fs_fsbtodb = ffs(fs->fs_nspf) - 1; + if (waitfor == MNT_WAIT) error = bwrite(bp); else Index: src/sys/ufs/ufs/ufs_disksubr.c =================================================================== RCS file: /mo1/FreeBSD-CVS/src/sys/ufs/ufs/ufs_disksubr.c,v retrieving revision 1.26.2.1 diff -u -r1.26.2.1 ufs_disksubr.c --- ufs_disksubr.c 1998/05/06 19:16:03 1.26.2.1 +++ ufs_disksubr.c 1998/07/06 15:44:34 @@ -159,7 +159,7 @@ bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; - bp->b_blkno = LABELSECTOR; + bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_bcount = lp->d_secsize; bp->b_flags &= ~B_INVAL; bp->b_flags |= B_BUSY | B_READ; @@ -261,7 +261,7 @@ } bp = geteblk((int)lp->d_secsize); bp->b_dev = dkmodpart(dev, labelpart); - bp->b_blkno = LABELSECTOR; + bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_bcount = lp->d_secsize; #if 1 /* ---------------------------------------------------------------------- DES -- Dag-Erling Smørgrav - dag-erli@ifi.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message