Date: 09 Sep 1998 10:18:41 +0200 From: dag-erli@ifi.uio.no (Dag-Erling =?iso-8859-1?Q?Co=EFdan?= =?iso-8859-1?Q?Sm=F8rgrav?= ) To: Bruce Evans <bde@zeta.org.au> Cc: tmb@rcru.rl.ac.uk, freebsd-current@FreeBSD.ORG Subject: [LONG PATCH] Re: 2048-byte sector support for DOS filesystem. Message-ID: <xzphfyhzoke.fsf@hrotti.ifi.uio.no> In-Reply-To: Bruce Evans's message of "Wed, 9 Sep 1998 13:03:51 %2B1000" References: <199809090303.NAA16240@godzilla.zeta.org.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <bde@zeta.org.au> 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 <sys/mount.h>
#include <sys/buf.h>
#include <sys/file.h>
+#include <sys/disklabel.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
#include <sys/malloc.h>
#include <msdosfs/bpb.h>
@@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzphfyhzoke.fsf>
