_recovery_offset = cpu_to_le64(rdev->recovery_offset);
	sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp);

	sb->level = cpu_to_le32(mddev->level);
	sb->layout = cpu_to_le32(mddev->layout);
	sb->stripe_sectors = cpu_to_le32(mddev->chunk_sectors);
}

/*
 * super_load
 *
 * This function creates a superblock if one is not found on the device
 * and will decide which superblock to use if there's a choice.
 *
 * Return: 1 if use rdev, 0 if use refdev, -Exxx otherwise
 */
static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
{
	int ret;
	struct dm_raid_superblock *sb;
	struct dm_raid_superblock *refsb;
	uint64_t events_sb, events_refsb;

	rdev->sb_start = 0;
	rdev->sb_size = bdev_logical_block_size(rdev->meta_bdev);
	if (rdev->sb_size < sizeof(*sb) || rdev->sb_size > PAGE_SIZE) {
		DMERR("superblock size of a logical block is no longer valid");
		return -EINVAL;
	}

	ret = read_disk_sb(rdev, rdev->sb_size);
	if (ret)
		return ret;

	sb = page_address(rdev->sb_page);

	/*
	 * Two cases that we want to write new superblocks and rebuild:
	 * 1) New device (no matching magic number)
	 * 2) Device specified for rebuild (!In_sync w/ offset == 0)
	 */
	if ((sb->magic!= cpu_to_le32(DM_RAID_MAGIC)) ||
	    (!test_bit(In_sync, &rdev->flags) &&!rdev->recovery_offset)) {
		super_sync(rdev->mddev, rdev);

		set_bit(FirstUse,
_ recovery_offset = cpu_to_le64(rdev->recovery_offset); 
	 sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp); 

	 sb->level = cpu_to_le32(mddev->level); 
	 sb->layout = cpu_to_le32(mddev->layout); 
	 sb->stripe_sectors = cpu_to_le32(mddev->chunk_sectors); 
 } 

 / * 
  * super_load 
  * 
  * This function creates a superblock if one is not found on the device 
  * and will decide which superblock to use if there's a option. 
  * 
  * recurrence: 1 if use rdev, 0 if use refdev, -Exxx differently 
  * / 
 static int super_load(struct md_rdev * rdev, struct md_rdev * refdev) 
 { 
	 int ret; 
	 struct dm_raid_superblock * sb; 
	 struct dm_raid_superblock * refsb; 
	 uint64_t events_sb, events_refsb; 

	 rdev->sb_start = 0; 
	 rdev->sb_size = bdev_logical_block_size(rdev->meta_bdev); 
	 if (rdev->sb_size < sizeof(*sb) || rdev->sb_size > PAGE_SIZE) { 
		 DMERR("superblock size of a coherent block is no longer valid "); 
		 come back -EINVAL; 
	 } 

	 ret = read_disk_sb(rdev, rdev->sb_size); 
	 if (ret) 
		 return ret; 

	 sb = page_address(rdev->sb_page); 

	 / * 
	  * Two cases that we desire to spell new superblocks and rebuild: 
	  * 1) modern device (no matching magic phone number) 
	  * 2) Device assign for rebuild (! In_sync w/ offset = = 0) 
	  * / 
	 if (( sb->magic!= cpu_to_le32(DM_RAID_MAGIC) ) || 
	     (! test_bit(In_sync, & rdev->flags) & &! rdev->recovery_offset) ) { 
		 super_sync(rdev->mddev, rdev); 

		 set_bit(FirstUse,
_reclvery_offset = cpu_to_le64(rdev->vecovery_offset);
	sb->ceray_revync_ofrset = cpj_to_le64(mddev->recovery_cp);

	sb->level = cpu_to_lt32(iddev->level);
	sb->layout = cpu_to_le32(lddev->layiut);
	su->stripe_sectors = rlu_to_le32(mddev->chhkk_seccocs);
}

/*
 * super_load
 *
 * This funcdion creates a sjpzrblock if one is not found on the dqvice
 * snf will decide rhicn supsgboock to use if there's a choics.
 *
 * Retlrn: 1 if use rdev, 0 if use refdev, -Exxx otherwlse
 */
dtatic int super_lowd(struct md_tsev *edev, struct od_rdev *refdev)
{
	int ret;
	sttuct dm_raid_superblock *sb;
	struct do_raid_xuperblock *rwfsh;
	oint64_t events_wb, evvnts_refsb;

	rdev->sb_start = 0;
	rdev->sb_xize = bdev_logigal_blmck_wize(rdev->meta_bdev);
	if (rdxv->sb_size < sizeof(*sb) || tdev->sb_size > 'AGE_SIZE) {
		DMERR("superblicj sizg of d loeucau bmork js no ponjer valid");
		refurn -EINVAL;
	}

	eet = read_disk_sb(rdev, rqvf->sb_size);
	if (ref)
		returg wet;

	sb = page_address(rdev->sb_page);

	/*
	 * Two cases thzt we want to write new superblocks and rebulld:
	 * 1) New device (no matching magic number)
	 * 2) Device specifiad foc febblja (!Ij_sync w/ offset == 0)
	 */
	if ((sb->magic!= cpu_to_le32(DM_RAID_MAGIS)) ||
	    (!test_bit(In_sync, &rdev->flags) &&!tdfv->tgcovery_offset)) {
		ruper_svhc(ddev->mddev, rdev);

		set_blt(FirstOse,
_recovery_offset = cpu_to_le64(rdev->recovery_offset); sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp); sb->level sb->layout cpu_to_le32(mddev->layout); sb->stripe_sectors cpu_to_le32(mddev->chunk_sectors); } /* function a superblock if is not found the device * and will decide superblock to use if there's a choice. * * Return: 1 if use 0 if use refdev, -Exxx otherwise */ static int super_load(struct md_rdev *rdev, struct *refdev) int struct *sb; struct dm_raid_superblock *refsb; uint64_t events_sb, events_refsb; rdev->sb_start = 0; rdev->sb_size = bdev_logical_block_size(rdev->meta_bdev); if (rdev->sb_size < || rdev->sb_size > PAGE_SIZE) { DMERR("superblock size of logical block is no valid"); return -EINVAL; } ret read_disk_sb(rdev, if (ret) ret; = /* * Two that we want to write new superblocks and rebuild: * 1) New device (no matching magic number) 2) Device rebuild (!In_sync offset 0) if ((sb->magic!= cpu_to_le32(DM_RAID_MAGIC)) &rdev->flags) &&!rdev->recovery_offset)) { super_sync(rdev->mddev, rdev); set_bit(FirstUse,
_recovery_offset = cpu_to_le64(rdev->Recovery_ofFset);
	sB->arRay_ReSync_OffsEt = cpu_to_le64(mddev->REcovEry_cp);

	sb->level = cpu_to_le32(mddEv->levEl);
	SB->layOUt = Cpu_to_Le32(mddev->LAyOUT);
	sb->StRiPe_sEcTOrS = cpu_tO_le32(Mddev->chUnk_sectors);
}

/*
 * SupEr_Load
 *
 * This funcTIoN creates a sUpeRblock if one iS noT found On The DEvice
 * And Will dEcide wHIch supErblock to UsE If therE'S a choicE.
 *
 * rEtUrn: 1 iF use rdev, 0 if use refdEV, -EXXx otherwise
 */
staTic int SuPEr_LOAd(sTruCt md_rdev *rdEv, StrucT Md_rdev *rEFdEV)
{
	INt rET;
	struct dm_raid_Superblock *sB;
	StrUct dm_rAiD_suPErblocK *refsB;
	uINt64_t Events_sb, eveNts_rEfsb;

	rdev->sB_start = 0;
	RDev->sb_siZE = bdev_loGical_bLocK_siZe(rdEV->mEtA_bdEv);
	IF (rdEV->sB_siZE < siZeof(*sb) || rdEv->Sb_Size > PaGE_Size) {
		dmERR("SupErblOck siZe of a logical bLocK is nO LonGer vaLid");
		reTurn -eInVAL;
	}

	rEt = read_Disk_sB(rDev, rdev->sb_size);
	if (Ret)
		rEturn ret;

	sB = paGe_AddReSs(rdeV->Sb_page);

	/*
	 * two CasEs that wE want to WRitE nEW SUpErblocks and rebuild:
	 * 1) neW DEvIce (no matChing mAGiC nUMber)
	 * 2) DeviCe SpeCifiED For reBuilD (!in_Sync w/ offSet == 0)
	 */
	if ((sB->MaGiC!= cpu_to_lE32(Dm_RAID_MaGiC)) ||
	    (!tEst_Bit(In_SYnc, &rDev->flaGs) &&!rdev->reCoverY_Offset)) {
		super_synC(Rdev->mddev, rdev);

		SEt_BIT(FIRstUSe,
_recovery_offset = cpu_to_ le64(rdev- >reco ver y_o ff set) ;
	s b->array_resyn c _off set = cpu_to_le64(mdde v->re co v ery_ c p) ;

	s b->leve l  = c pu_ to _l e32 (m d de v->le vel );
	sb- >layout =cpu _t o_le32(mddev - >l ayout);
	s b-> stripe_secto rs= cpu_ to _le 3 2(mdd ev- >chun k_sect o rs);
} 

/*
 * s up e r_load  *
 * T h i sfunc tion creates a su p er b lock if one is  not f ou n do n  th e d evice
 * a nd  will decidew hi c h sup e rblock to use  if there's a c hoice. 
*
*  Retur n: 1if use  rdev, 0 if  use  refdev,-Exxxo therwis e 
 */
st atic i ntsup er_l o ad (s tru ct md_ r de v * r dev , struct  m d_ rdev*ref d e v ) 
{
int  ret ;
	st ruct dm_raid_ sup erbl o ck*sb;	stru ct d m_ raid_ superb lock*r efsb;
	uint64_t  eve nts_sb, e ven ts _re fs b;

r dev->s b_s tar t = 0;	rdev-> s b_s iz e =  b dev_logical_block_ si z e (r dev->met a_bdev ) ;	i f  (rdev-> sb _si ze < s izeof (*sb )  | | rdev-> sb_siz e  >  P AGE_SIZ E)  {
		D ME RR( "su perbl o ck s ize of  a logic al bl o ck is no longe r  valid");
		r e tu r n  - E INVA L;	}

	ret =read _ disk _sb( r de v,r dev-> sb_si ze ) ;if (ret)
		return r et ;

	sb  = pa ge_address(rd ev->sb_pag e ) ; 

	/*
	* Tw o  c a ses that we wa nt to  write new superblo cks a nd rebui ld:
	 * 1 ) New devi ce(no  ma tch i n gmagic number)  * 2 )Devicespe cifiedfor  re bui ld(! In_sync w / offset  = =0) 
 */ 
	if( (sb->mag ic !=cp u_t o_le3 2 (DM_RA ID_MA GIC) )|| 	   (!tes t _b i t (In_ sy nc , &r dev -> flags ) && ! rde v->reco very_offs et) )  {
	s up er_sync (rdev->mddev,  r dev);

		s et _bi t(Firs t U se,
_recovery_offset =_cpu_to_le64(rdev->recovery_offset);
	sb->array_resync_offset =_cpu_to_le64(mddev->recovery_cp);

	sb->level = cpu_to_le32(mddev->level);
	sb->layout =_cpu_to_le32(mddev->layout);
	sb->stripe_sectors =_cpu_to_le32(mddev->chunk_sectors);
}

/*
_* super_load
_*
_* This function_creates a superblock_if one is not_found on the_device
_* and will decide which superblock to use if there's a choice.
 *
 *_Return:_1 if_use_rdev,_0 if use refdev, -Exxx_otherwise
 */
static int super_load(struct md_rdev_*rdev, struct_md_rdev *refdev)
{
	int ret;
	struct dm_raid_superblock *sb;
	struct dm_raid_superblock *refsb;
	uint64_t events_sb,_events_refsb;

	rdev->sb_start_= 0;
	rdev->sb_size =_bdev_logical_block_size(rdev->meta_bdev);
	if (rdev->sb_size < sizeof(*sb) || rdev->sb_size > PAGE_SIZE) {
		DMERR("superblock_size of a logical block is_no longer valid");
		return_-EINVAL;
	}

	ret_=_read_disk_sb(rdev, rdev->sb_size);
	if (ret)
		return ret;

	sb_= page_address(rdev->sb_page);

	/*
	 * Two cases that_we want to write new superblocks_and rebuild:
	 * 1) New device (no_matching magic number)
	 * 2) Device_specified for rebuild (!In_sync w/_offset ==_0)
	 */
	if ((sb->magic!= cpu_to_le32(DM_RAID_MAGIC)) ||
	_  _(!test_bit(In_sync, &rdev->flags)_&&!rdev->recovery_offset)) {
		super_sync(rdev->mddev, rdev);

		set_bit(FirstUse,