Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 1996 02:09:46 -0700 (PDT)
From:      asami@cs.berkeley.edu (Satoshi Asami)
To:        current@freebsd.org
Cc:        ccd@stampede.cs.berkeley.edu
Subject:   ccd offset, please review + test
Message-ID:  <199605030909.CAA02043@silvia.HIP.Berkeley.EDU>

next in thread | raw e-mail | index | archive | help
Below is a small patch to make ccd ignore the first 16 sectors in the
component partitions.  The purpose of this is to allow people to do
things like

dd if=/dev/zero of=/dev/rsd237 bs=512 count=2 # destroy slice table
disklabel -wr sd237 auto                      # create default label

and then just use /dev/sd237c et al. for the ccd components.  I
temporarily turned off the "4.2BSD" type check too, this part won't be
permanent, but for now, it is necessary for the above to work because
/dev/sd237c will be marked "unused".

>From what I understand (which is certainly not very much), the reason
why the above doesn't work with the current ccd code is because the
disklabels are at the beginning of the slices, and "disklabel ccd0"
will confuse the first component's disklabel with the ccd's (i.e., if
you combine /dev/sd237c and /dev/sd280c in this order to create ccd0,
sd237's disklabel will be confused as ccd0's disklabel).

Also, the first 16 sectors of the slices are read-only, so ccd will
fail at some point if you have a component (not the first one) that
starts at the beginning of the slice (i.e., if you combine /dev/sd237g 
and /dev/sd280c, where sd237g doesn't start at the beginning of the
slice, it will appear to work for a while but fail at some point when
the driver actually tries to write something to the first 16 sectors
of sd280).

Of course the man page tells you not to use a partition that starts at
the beginning of a slice, but the above command samples are very
convenient.  Consider yourself to be a novice sysadmin who just
installed FreeBSD for the ccd driver and also purchased 64 4-gig
Atlases for the news spool (and aren't particularly in the mood of
diving into the disklabel man page :).

Satoshi
-------
Index: ccd.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/ccd/ccd.c,v
retrieving revision 1.10
diff -u -r1.10 ccd.c
--- ccd.c	1996/04/24 09:42:22	1.10
+++ ccd.c	1996/05/03 07:08:57
@@ -228,6 +228,9 @@
 
 static int ccd_devsw_installed = 0;
 
+/* Offset from beginning of component partitions. */
+#define CCD_OFFSET 16
+
 /*
  * Called by main() during pseudo-device attachment.  All we need
  * to do is allocate enough space for devices to be configured later, and
@@ -371,11 +374,11 @@
 			free(cs->sc_cinfo, M_DEVBUF);
 			return (error);
 		}
-		if (dpart.part->p_fstype == FS_BSDFFS) {
+		if (dpart.part->p_fstype == FS_BSDFFS || 1) {
 			maxsecsize =
 			    ((dpart.disklab->d_secsize > maxsecsize) ?
 			    dpart.disklab->d_secsize : maxsecsize);
-			size = dpart.part->p_size;
+			size = dpart.part->p_size - CCD_OFFSET;
 		} else {
 #ifdef DEBUG
 			if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
@@ -879,7 +882,7 @@
 	cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone;
 	cbp->cb_buf.b_proc = bp->b_proc;
 	cbp->cb_buf.b_dev = ci->ci_dev;		/* XXX */
-	cbp->cb_buf.b_blkno = cbn + cboff;
+	cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
 	cbp->cb_buf.b_data = addr;
 	cbp->cb_buf.b_vp = ci->ci_vp;
 	if (cs->sc_ileave == 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605030909.CAA02043>