After comments from Phk and Matt..

Particularly I'm looking for someone with a ccd and knowledge of it to
look at these patches, (not big) and see if they do anything of interest.. 

The theory is to inherrit the blocksizes of the underlying devices up to
the ccd device. I don't have a ccd array so it's a bit hard to test, but
it's more a "I think this is how it might work" sort of thing..

(also it should stop the requirement that ccds be on FFS labelled
partitions)

Anyone care to comment?


(Greg, I think these ideas probably apply to vinum, as well)
Index: ccd.c
===================================================================
RCS file: /cvs/freebsd/src/sys/dev/ccd/ccd.c,v
retrieving revision 1.56
diff -c -r1.56 ccd.c
*** ccd.c       1999/09/03 05:16:54     1.56
--- ccd.c       1999/09/09 00:59:47
***************
*** 307,313 ****
        register int ix;
        struct vnode *vp;
        size_t minsize;
!       int maxsecsize;
        struct partinfo dpart;
        struct ccdgeom *ccg = &cs->sc_geom;
        char tmppath[MAXPATHLEN];
--- 307,314 ----
        register int ix;
        struct vnode *vp;
        size_t minsize;
!       int maxsecsize, delt;
!       u_int   partsecsize;
        struct partinfo dpart;
        struct ccdgeom *ccg = &cs->sc_geom;
        char tmppath[MAXPATHLEN];
***************
*** 330,338 ****
         * Verify that each component piece exists and record
         * relevant information about it.
         */
!       maxsecsize = 0;
        minsize = 0;
        for (ix = 0; ix < cs->sc_nccdisks; ix++) {
                vp = ccd->ccd_vpp[ix];
                ci = &cs->sc_cinfo[ix];
                ci->ci_vp = vp;
--- 331,340 ----
         * Verify that each component piece exists and record
         * relevant information about it.
         */
!       maxsecsize = 1;
        minsize = 0;
        for (ix = 0; ix < cs->sc_nccdisks; ix++) {
+               partsecsize = 0;
                vp = ccd->ccd_vpp[ix];
                ci = &cs->sc_cinfo[ix];
                ci->ci_vp = vp;
***************
*** 377,388 ****
                        free(cs->sc_cinfo, M_DEVBUF);
                        return (error);
                }
                if (dpart.part->p_fstype == FS_BSDFFS) {
!                       maxsecsize =
!                           ((dpart.disklab->d_secsize > maxsecsize) ?
!                           dpart.disklab->d_secsize : maxsecsize);
!                       size = dpart.part->p_size - CCD_OFFSET;
                } else {
  #ifdef DEBUG
                        if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
                                printf("ccd%d: %s: incorrect partition type\n",
--- 379,403 ----
                        free(cs->sc_cinfo, M_DEVBUF);
                        return (error);
                }
+               size = dpart.part->p_size - CCD_OFFSET;
+               ci->ci_size = size;
                if (dpart.part->p_fstype == FS_BSDFFS) {
!                       partsecsize = dpart.disklab->d_secsize;
!               } else if (ci->ci_dev->si_bsize_phys) {
!                       partsecsize = ci->ci_dev->si_bsize_phys;
!               }
!               /*
!                * All the sector sizes must divide into each other
!                * evenly or it can't work.
!                */
!               if (partsecsize > maxsecsize) {
!                       delt = partsecsize % maxsecsize;
!                       maxsecsize = partsecsize;
                } else {
+                       delt = maxsecsize % partsecsize;
+               }
+ 
+               if ((partsecsize == 0) || (delt != 0)) {
  #ifdef DEBUG
                        if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
                                printf("ccd%d: %s: incorrect partition type\n",
***************
*** 396,406 ****
                        return (EFTYPE);
                }
  
!               /*
!                * Calculate the size, truncating to an interleave
!                * boundary if necessary.
!                */
  
                if (cs->sc_ileave > 1)
                        size -= size % cs->sc_ileave;
  
--- 411,447 ----
                        return (EFTYPE);
                }
  
!       }
! 
!       /*
!        * Don't allow the interleave to be smaller than
!        * the biggest component sector.
!        * Should be a multiple of maxsecsize.
!        * XXX but is maxsecsize a clean multiple of DEV_BSIZE?
!        */
!       if ((cs->sc_ileave > 0) &&
!          (cs->sc_ileave % (maxsecsize / DEV_BSIZE))) {
! #ifdef DEBUG
!               if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
!                       printf("ccd%d: interleave must be multiple of %d\n",
!                           ccd->ccd_unit, (maxsecsize / DEV_BSIZE));
! #endif
!               while (ci >= cs->sc_cinfo) {
!                       free(ci->ci_path, M_DEVBUF);
!                       ci--;
!               }
!               free(cs->sc_cinfo, M_DEVBUF);
!               return (EINVAL);
!       }
  
+       /*
+        * Calculate the sizes, truncating to an interleave
+        * boundary if necessary.
+        */
+       for (ix = 0; ix < cs->sc_nccdisks; ix++) {
+               ci = &cs->sc_cinfo[ix];
+               size = ci->ci_size;
+ 
                if (cs->sc_ileave > 1)
                        size -= size % cs->sc_ileave;
  
***************
*** 425,449 ****
        }
  
        /*
-        * Don't allow the interleave to be smaller than
-        * the biggest component sector.
-        */
-       if ((cs->sc_ileave > 0) &&
-           (cs->sc_ileave < (maxsecsize / DEV_BSIZE))) {
- #ifdef DEBUG
-               if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
-                       printf("ccd%d: interleave must be at least %d\n",
-                           ccd->ccd_unit, (maxsecsize / DEV_BSIZE));
- #endif
-               while (ci >= cs->sc_cinfo) {
-                       free(ci->ci_path, M_DEVBUF);
-                       ci--;
-               }
-               free(cs->sc_cinfo, M_DEVBUF);
-               return (EINVAL);
-       }
- 
-       /*
         * If uniform interleave is desired set all sizes to that of
         * the smallest component.
         */
--- 466,471 ----
***************
*** 616,621 ****
--- 638,644 ----
        struct ccd_softc *cs;
        struct disklabel *lp;
        int error = 0, part, pmask;
+       struct ccdgeom *ccg;
  
  #ifdef DEBUG
        if (ccddebug & CCDB_FOLLOW)
***************
*** 624,629 ****
--- 647,653 ----
        if (unit >= numccd)
                return (ENXIO);
        cs = &ccd_softc[unit];
+       ccg = &cs->sc_geom;
  
        if ((error = ccdlock(cs)) != 0)
                return (error);
***************
*** 633,641 ****
        part = ccdpart(dev);
        pmask = (1 << part);
  
-       dev->si_bsize_phys = DEV_BSIZE;
        dev->si_bsize_best = BLKDEV_IOSIZE;
        dev->si_bsize_max = MAXBSIZE;
  
        /*
         * If we're initialized, check to see if there are any other
--- 657,668 ----
        part = ccdpart(dev);
        pmask = (1 << part);
  
        dev->si_bsize_best = BLKDEV_IOSIZE;
        dev->si_bsize_max = MAXBSIZE;
+       if (( dev->si_bsize_phys = ccg->ccg_secsize) == 0) {
+               dev->si_bsize_phys = DEV_BSIZE;
+       }
+ 
  
        /*
         * If we're initialized, check to see if there are any other

Reply via email to