⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_pqdegdags.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 2 页
字号:
   pdas of P and Q, followed by the raidPtr. The list can look like   pda, pda, ... , p pda, q pda, raidptr, asm      or   pda, pda, ... , p_1 pda, p_2 pda, q_1 pda, q_2 pda, raidptr, asm   depending on wether two chunks of recovery data were required.   The second condition only arises if there are two failed buffers   whose lengths do not add up a stripe unit.*/int rf_PQDoubleRecoveryFunc(node)  RF_DagNode_t  *node;{  int np = node->numParams;  RF_AccessStripeMap_t *asmap = (RF_AccessStripeMap_t *) node->params[np-1].p;  RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[np-2].p;  RF_RaidLayout_t *layoutPtr = (RF_RaidLayout_t *) &(raidPtr->Layout);  int d, i;  unsigned coeff;  RF_RaidAddr_t sosAddr, suoffset;  RF_SectorCount_t len, secPerSU = layoutPtr->sectorsPerStripeUnit;  int two = 0;  RF_PhysDiskAddr_t *ppda,*ppda2,*qpda,*qpda2,*pda,npda;  char *buf;  int numDataCol = layoutPtr->numDataCol;  RF_Etimer_t timer;  RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;  RF_ETIMER_START(timer);  if (asmap->failedPDAtwo &&       (asmap->failedPDAtwo->numSector + asmap->failedPDA->numSector < secPerSU))    {      RF_ASSERT(0);      ppda  = node->params[np-6].p;      ppda2 = node->params[np-5].p;      qpda  = node->params[np-4].p;      qpda2 = node->params[np-3].p;      d = (np-6);      two = 1;    }  else    {      ppda = node->params[np-4].p;      qpda = node->params[np-3].p;      d = (np-4);    }  for (i=0; i < d; i++)    {      pda = node->params[i].p;      buf = pda->bufPtr;      suoffset = rf_StripeUnitOffset(layoutPtr, pda->startSector);      len = pda->numSector;      coeff = rf_RaidAddressToStripeUnitID(layoutPtr,pda->raidAddress);      /* compute the data unit offset within the column */      coeff = (coeff % raidPtr->Layout.numDataCol);      /* see if pda intersects a recovery pda */      applyPDA(raidPtr,pda,ppda,qpda,node->dagHdr->bp);      if (two)	applyPDA(raidPtr,pda,ppda,qpda,node->dagHdr->bp);    }  /* ok, we got the parity back to the point where we can recover.     We now need to determine the coeff of the columns that need to be     recovered. We can also only need to recover a single stripe unit.     */    if (asmap->failedPDAtwo == NULL)    { /* only a single stripe unit to recover. */      pda = asmap->failedPDA;      sosAddr      = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, asmap->raidAddress);      /* need to determine the column of the other failed disk */      coeff = rf_RaidAddressToStripeUnitID(layoutPtr,pda->raidAddress);      /* compute the data unit offset within the column */      coeff = (coeff % raidPtr->Layout.numDataCol);      for (i=0; i < numDataCol; i++)	{	  npda.raidAddress = sosAddr + (i * secPerSU);	  (raidPtr->Layout.map->MapSector)(raidPtr,npda.raidAddress, &(npda.row), &(npda.col), &(npda.startSector), 0);	  /* skip over dead disks */	  if (RF_DEAD_DISK(raidPtr->Disks[npda.row][npda.col].status))	    if (i != coeff) break;	}      RF_ASSERT (i < numDataCol);      RF_ASSERT (two==0);      /* recover the data. Since we need only want to recover one column, we overwrite the	 parity with the other one. */      if (coeff < i) /* recovering 'a' */	rf_PQ_recover((unsigned long *)ppda->bufPtr,(unsigned long *)qpda->bufPtr,(unsigned long *)pda->bufPtr,(unsigned long *)ppda->bufPtr,rf_RaidAddressToByte(raidPtr,pda->numSector), coeff, i);      else /* recovering 'b' */	rf_PQ_recover((unsigned long *)ppda->bufPtr,(unsigned long *)qpda->bufPtr,(unsigned long *)ppda->bufPtr,(unsigned long *)pda->bufPtr,rf_RaidAddressToByte(raidPtr,pda->numSector), i, coeff);    }  else    RF_PANIC();  RF_ETIMER_STOP(timer);  RF_ETIMER_EVAL(timer);  if (tracerec)    tracerec->q_us += RF_ETIMER_VAL_US(timer);  rf_GenericWakeupFunc(node,0);  return(0);}int rf_PQWriteDoubleRecoveryFunc(node)  RF_DagNode_t  *node;{  /* The situation:         We are doing a write that hits only one	 failed data unit.	 The other failed data unit is not being overwritten, so	 we need to generate it.	 	 For the moment, we assume all the nonfailed data being	 written is in the shadow of the failed data unit.	 (i.e,, either a single data unit write or the entire	 failed stripe unit is being overwritten. )	 	 Recovery strategy: 	     apply the recovery data to the parity and q.	     Use P & Q to recover the second failed data unit in P.	     Zero fill Q, then apply the recovered data to p.	     Then apply the data being written to the failed drive.	     Then walk through the surviving drives, applying new data	     when it exists, othewise the recovery data. Quite a mess.	The params	read pda0, read pda1, ... read pda (numDataCol-3), 	write pda0, ... , write pda (numStripeUnitAccess - numDataFailed),	failed pda, raidPtr, asmap   */  int np = node->numParams;  RF_AccessStripeMap_t *asmap = (RF_AccessStripeMap_t *) node->params[np-1].p;  RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[np-2].p;  RF_RaidLayout_t *layoutPtr = (RF_RaidLayout_t *) &(raidPtr->Layout);  int i;  RF_RaidAddr_t sosAddr;  unsigned coeff;  RF_StripeCount_t secPerSU = layoutPtr->sectorsPerStripeUnit;  RF_PhysDiskAddr_t *ppda,*qpda,*pda,npda;  int numDataCol = layoutPtr->numDataCol;  RF_Etimer_t timer;  RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;  RF_ASSERT(node->numResults == 2);  RF_ASSERT(asmap->failedPDAtwo == NULL);  RF_ETIMER_START(timer);  ppda = node->results[0];  qpda = node->results[1];  /* apply the recovery data */  for (i=0; i < numDataCol-2; i++)    applyPDA(raidPtr,node->params[i].p,ppda,qpda, node->dagHdr->bp);  /* determine the other failed data unit */  pda = asmap->failedPDA;  sosAddr      = rf_RaidAddressOfPrevStripeBoundary(layoutPtr, asmap->raidAddress);  /* need to determine the column of the other failed disk */  coeff = rf_RaidAddressToStripeUnitID(layoutPtr,pda->raidAddress);  /* compute the data unit offset within the column */  coeff = (coeff % raidPtr->Layout.numDataCol);  for (i=0; i < numDataCol; i++)    {      npda.raidAddress = sosAddr + (i * secPerSU);      (raidPtr->Layout.map->MapSector)(raidPtr,npda.raidAddress, &(npda.row), &(npda.col), &(npda.startSector), 0);      /* skip over dead disks */      if (RF_DEAD_DISK(raidPtr->Disks[npda.row][npda.col].status))	if (i != coeff) break;    }  RF_ASSERT (i < numDataCol);  /* recover the data. The column we want to recover we write over the parity.     The column we don't care about we dump in q. */  if (coeff < i) /* recovering 'a' */    rf_PQ_recover((unsigned long *)ppda->bufPtr,(unsigned long *)qpda->bufPtr,(unsigned long *)ppda->bufPtr,(unsigned long *)qpda->bufPtr,rf_RaidAddressToByte(raidPtr,pda->numSector), coeff, i);  else /* recovering 'b' */    rf_PQ_recover((unsigned long *)ppda->bufPtr,(unsigned long *)qpda->bufPtr,(unsigned long *)qpda->bufPtr,(unsigned long *)ppda->bufPtr,rf_RaidAddressToByte(raidPtr,pda->numSector), i, coeff);    /* OK. The valid data is in P. Zero fill Q, then inc it into it. */  bzero(qpda->bufPtr,rf_RaidAddressToByte(raidPtr,qpda->numSector));  rf_IncQ((unsigned long *)qpda->bufPtr,(unsigned long *)ppda->bufPtr,rf_RaidAddressToByte(raidPtr,qpda->numSector),i);  /* now apply all the write data to the buffer */  /* single stripe unit write case: the failed data is only thing we are writing. */  RF_ASSERT(asmap->numStripeUnitsAccessed == 1);  /* dest, src, len, coeff */  rf_IncQ((unsigned long *)qpda->bufPtr,(unsigned long *)asmap->failedPDA->bufPtr,rf_RaidAddressToByte(raidPtr,qpda->numSector),coeff);  rf_bxor(asmap->failedPDA->bufPtr,ppda->bufPtr,rf_RaidAddressToByte(raidPtr,ppda->numSector),node->dagHdr->bp);    /* now apply all the recovery data */  for (i=0; i < numDataCol-2; i++)    applyPDA(raidPtr,node->params[i].p,ppda,qpda, node->dagHdr->bp);  RF_ETIMER_STOP(timer);  RF_ETIMER_EVAL(timer);  if (tracerec)    tracerec->q_us += RF_ETIMER_VAL_US(timer);	  rf_GenericWakeupFunc(node,0);  return(0);}RF_CREATE_DAG_FUNC_DECL(rf_PQ_DDLargeWrite){  RF_PANIC();}/*   Two lost data unit write case.   There are really two cases here:   (1) The write completely covers the two lost data units.        In that case, a reconstruct write that doesn't write the       failed data units will do the correct thing. So in this case,       the dag looks like            full stripe read of surviving data units (not being overwriten)	    write new data (ignoring failed units)   compute P&Q	                                             write P&Q   (2) The write does not completely cover both failed data units       (but touches at least one of them). Then we need to do the        equivalent of a reconstruct read to recover the missing data       unit from the other stripe.             For any data we are writing that is not in the "shadow"       of the failed units, we need to do a four cycle update.       PANIC on this case. for now*/RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateWriteDAG){  RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);  RF_SectorCount_t sectorsPerSU = layoutPtr->sectorsPerStripeUnit;  int sum;  int nf = asmap->numDataFailed;  sum = asmap->failedPDA->numSector;  if (nf == 2)    sum += asmap->failedPDAtwo->numSector;  if ((nf == 2) && ( sum == (2*sectorsPerSU)))    {      /* large write case */      rf_PQ_DDLargeWrite(raidPtr, asmap, dag_h, bp, flags, allocList);      return;    }    if ((nf == asmap->numStripeUnitsAccessed) || (sum >= sectorsPerSU))    {      /* small write case, no user data not in shadow */      rf_PQ_DDSimpleSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList);      return;    }  RF_PANIC();}RF_CREATE_DAG_FUNC_DECL(rf_PQ_DDSimpleSmallWrite){  rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Rq", "Wq", "PQ Recovery", rf_PQWriteDoubleRecoveryFunc);}#endif /* (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -