linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RAID-5 Parity calculation
@ 2004-10-14 18:31 Yinan Liu
  2004-10-14 21:39 ` Guy
  2004-10-15  0:57 ` Neil Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Yinan Liu @ 2004-10-14 18:31 UTC (permalink / raw)
  To: linux-raid

Hi, I am a new guy for a Linux programming. I got a question for a
software RAID-5 parity calculation. 

If we suppose for data block D1, D2, D3, D4 with a parity block P, When
some data block is changed, P will be changed. I am not so clear how
does Linux md handle the parity re calculating, when data changed . 

Suppose there will be three cases, 

1. sequential write, is that get new P' directly with new data D1', D2',
D3' and D4' or need read D1-4 out from disk doing the normal operation. 

2. if we changed there blocks, D1',D2' and D3', does md read D1, D2, D3
out to rebuild P or just read D4 out from disk and rebuild P with D1',
D2', D3' and D4. 

3. is the simple case, just change one block. 

Thanks a lot, if some can help me get understand it. 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: RAID-5 Parity calculation
  2004-10-14 18:31 RAID-5 Parity calculation Yinan Liu
@ 2004-10-14 21:39 ` Guy
  2004-10-15  0:57 ` Neil Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Guy @ 2004-10-14 21:39 UTC (permalink / raw)
  To: 'Yinan Liu', linux-raid

If D1, D2, D3 or D4 change, then P must also change.

If all D1, D2, D3 and D4 change, then md can compute P without any reads.
Then write D1, D2, D3, D4 and P.

If less than all D1, D2, D3 and D4 change, then md has 2 options, md does
whichever requires less disk I/O.

1) md must read the unchanging data and read P, compute a new P and write
the changes.

2) Read the old D1, D2, D3 and/or D4 (whichever is changing) and read P.
Then factor out the old data from P, then factor in the new data, write all
changes.

Example 1:
	D1, D2 and D3 are changing.
	md will read D4, using D1, D2, D3 and D4 (from memory) compute new
P, write D1, D2, D3 and P.

Example 2:
	D1 is changing.
	md will read old D1 and P.  Factor out old D1 from P.  Factor new D1
into new P, write D1 and P.

Guy


-----Original Message-----
From: linux-raid-owner@vger.kernel.org
[mailto:linux-raid-owner@vger.kernel.org] On Behalf Of Yinan Liu
Sent: Thursday, October 14, 2004 2:31 PM
To: linux-raid@vger.kernel.org
Subject: RAID-5 Parity calculation

Hi, I am a new guy for a Linux programming. I got a question for a
software RAID-5 parity calculation. 

If we suppose for data block D1, D2, D3, D4 with a parity block P, When
some data block is changed, P will be changed. I am not so clear how
does Linux md handle the parity re calculating, when data changed . 

Suppose there will be three cases, 

1. sequential write, is that get new P' directly with new data D1', D2',
D3' and D4' or need read D1-4 out from disk doing the normal operation. 

2. if we changed there blocks, D1',D2' and D3', does md read D1, D2, D3
out to rebuild P or just read D4 out from disk and rebuild P with D1',
D2', D3' and D4. 

3. is the simple case, just change one block. 

Thanks a lot, if some can help me get understand it. 



-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RAID-5 Parity calculation
  2004-10-14 18:31 RAID-5 Parity calculation Yinan Liu
  2004-10-14 21:39 ` Guy
@ 2004-10-15  0:57 ` Neil Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Neil Brown @ 2004-10-15  0:57 UTC (permalink / raw)
  To: Yinan Liu; +Cc: linux-raid

On Thursday October 14, yinan@ele.uri.edu wrote:
> Hi, I am a new guy for a Linux programming. I got a question for a
> software RAID-5 parity calculation. 
> 
> If we suppose for data block D1, D2, D3, D4 with a parity block P, When
> some data block is changed, P will be changed. I am not so clear how
> does Linux md handle the parity re calculating, when data changed . 
> 
> Suppose there will be three cases, 
> 
> 1. sequential write, is that get new P' directly with new data D1', D2',
> D3' and D4' or need read D1-4 out from disk doing the normal operation. 
> 
> 2. if we changed there blocks, D1',D2' and D3', does md read D1, D2, D3
> out to rebuild P or just read D4 out from disk and rebuild P with D1',
> D2', D3' and D4. 
> 
> 3. is the simple case, just change one block. 
> 
> Thanks a lot, if some can help me get understand it. 

There are two ways raid5 can update the parity block:

 1/ read the old parity block and the old data blocks for all changed
 blocks, do the appropriate calculation, and write out the new parity
 and new data blocks.  This is called READ_MODIFY_WRITE.
 2/ read all data blocks in the stripe that *aren't* being changed,
 calculate the new parity from those and the changed blocks, and write
 out the new parity and new blocks.  This is called RECONSTRUCT_WRITE.

Both require the same number of writes, but possibly different numbers
of reads.  Having some blocks already in the cache may also affect the
number of reads required.
raid5 delays processing stripes as long as possible (but no longer) in
the "hope" of gathering multiple updates in a single stripe.  It then
calculates how many reads will be needed to updated the parity using
each mechanism, and chooses the mechanism that results in the fewest reads.

NeilBrown

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-15  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-14 18:31 RAID-5 Parity calculation Yinan Liu
2004-10-14 21:39 ` Guy
2004-10-15  0:57 ` Neil Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).