tech-kern archive

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

Re: Problems with raidframe under NetBSD-5.1/i386



In article <20110107205035.7d03116f%quad.oster.net@localhost>,
Greg Oster  <oster%cs.usask.ca@localhost> wrote:
>On Fri, 7 Jan 2011 15:22:03 -0800
>buhrow%lothlorien.nfbcal.org@localhost (Brian Buhrow) wrote:
>
>>      hello Greg.  Regarding problem 1, the inability to
>> reconstruct disks in raid sets with wedges in them, I confess I don't
>> understand the vnode stuff entirely, but rf_getdisksize() in
>> rf_netbsdkintf.c looks suspicious to me.  I'm a little unclear, but
>> it looks like it tries to get the disk size a number of ways,
>> including by checking for a possible wedge on the component.  I
>> wonder if that's what's sending the reference count too high? -thanks
>
>In rf_reconstruct.c:rf_ReconstructInPlace() we have this:
>
>       retcode = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD,
>                       curlwp->l_cred);
>
>I think will fail for wedges... it should be doing:
>
>        retcode = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, l->l_cred);
>
>for the wedge case (see rf_getdisksize()).  Now: since the kernel
>prints:

You mean something like this [untested, probably doesn't even compile]?

Index: rf_reconstruct.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_reconstruct.c,v
retrieving revision 1.110
diff -u -u -r1.110 rf_reconstruct.c
--- rf_reconstruct.c    19 Nov 2010 06:44:40 -0000      1.110
+++ rf_reconstruct.c    8 Jan 2011 15:47:48 -0000
@@ -339,6 +339,45 @@
    rebuild the data "on the spot".
 
 */
+static int
+disk_info(struct vnode *vp, uint64_t *partition_size, uint32_t *sector_size)
+{
+       struct dkwedge_info dkw;
+       struct partinfo dpart;
+       int error;
+       if ((error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD,
+           curlwp->l_cred)) == 0) {
+               struct plistref *pref;
+               *partition_size = dkw.dkw_size;
+
+               if ((error = VOP_IOCTL(vp, DIOCGDISKINFO, &pref, FREAD,
+                   curlwp->l_cred)) == 0) {
+                   prop_dictionary_t disc_dict;
+                   if ((error = prop_dictionary_copyin_ioctl(pref, FREAD,
+                       &disk_dict)) == 0) {
+                           prop_dictionary_t geom_dict =
+                               prop_dictionary_get(disk_dict, "geometry");
+                           if (geom_dict != NULL) {
+                                   if (prop_dictionary_get_uint32(geom_dict,
+                                       "sector-size", sector_size));
+                                           return 0;
+                                   else
+                                           error = ESRCH;
+                           }
+               }
+       }
+       /*
+        * Compat, should be removed when everything has been
+        * converted to wedges
+        */
+       if ((error = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD,
+           curlwp->l_cred)) == 0) {
+               sector_size = dpart.disklab->d_secsize;
+               partition_size = dpart.part->p_size;
+               return 0;
+       }
+       return error;
+}
 
 int
 rf_ReconstructInPlace(RF_Raid_t *raidPtr, RF_RowCol_t col)
@@ -348,12 +387,13 @@
        const RF_LayoutSW_t *lp;
        RF_ComponentLabel_t *c_label;
        int     numDisksDone = 0, rc;
-       struct partinfo dpart;
        struct pathbuf *pb;
        struct vnode *vp;
        struct vattr va;
        int retcode;
        int ac;
+       uint64_t partition_size;
+       uint32_t sector_size;
 
        lp = raidPtr->Layout.map;
        if (!lp->SubmitReconBuffer) {
@@ -462,19 +502,18 @@
                return(retcode);
        }
 
-       retcode = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, curlwp->l_cred);
-       if (retcode) {
+
+       if ((retcode = disk_info(vp, &sector_size, &partition_size)) != 0) {
                RF_LOCK_MUTEX(raidPtr->mutex);
                raidPtr->reconInProgress--;
                RF_UNLOCK_MUTEX(raidPtr->mutex);
                RF_SIGNAL_COND(raidPtr->waitForReconCond);
-               return(retcode);
+               return retcode;
        }
        RF_LOCK_MUTEX(raidPtr->mutex);
-       raidPtr->Disks[col].blockSize = dpart.disklab->d_secsize;
+       raidPtr->Disks[col].blockSize = sector_size;
 
-       raidPtr->Disks[col].numBlocks = dpart.part->p_size -
-               rf_protectedSectors;
+       raidPtr->Disks[col].numBlocks = partition_size - rf_protectedSectors;
 
        raidPtr->raid_cinfo[col].ci_vp = vp;
        raidPtr->raid_cinfo[col].ci_dev = va.va_rdev;



Home | Main Index | Thread Index | Old Index