Author Topic: How does parity work... really?  (Read 3939 times)

Offline Robbie Ferguson

  • Full Member
  • ***
  • Posts: 124
  • twitter.com/robbieferguson
    • Category5 Technology TV
How does parity work... really?
« on: September 12, 2009, 03:32:06 PM »
My basic RAID experience has my brain thinking in terms of RAID1... a mirror.

My conventional mind thinks, if I have a 400 GB drive, I need 400 GB on another drive to have redundancy.

How is it then, I can have a 750 GB parity drive, but then two 500 GB data drives (which would total more in sum than the entire capacity of the parity drive), yet still have redundancy without striping?
Robbie Ferguson, Host
Category5 Technology TV
www.Category5.TV

Offline WeeboTech

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7925
    • My GoogleCode unRAID Support Page
Re: How does parity work... really?
« Reply #1 on: September 12, 2009, 04:26:31 PM »
I don't know the mathematics to it.
Yet I do know that matching blocks on each drive is XOR'ed with one another and written to the parity drive.

Think in terms of RAID4 only with out stripping across multiple drives.

Instead of stripping a filesystem across multiple drives, a filesystem is contiguous on one spindle.
Multiple matching sectors across multiple drives are used to calculate a parity.

See
http://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_4
and


In the image,
 DISK 0 is a filesystem,
 but block A1, A2, A3 (on each filesystem) is used to create the parity for the respectively addressed block.

When the system sees that a disk has ended, ot assumes 0 in the XOR calculation and just uses what is left.
DISK3, Parity needs to be the largest disk. so that there is at least one parity block for every sector on other drives.

Hope my oversimplified explanation helps.

In updating parity, there is a bit of performance penalty for a sector.
The process is:
    * Read the old data block
    * Read the old parity block
    * Compare the old data block with the write request. For each bit that has flipped (changed from 0 to 1, or from 1 to 0) in the data block, flip the corresponding bit in the parity block
    * Write the new data block
    * Write the new parity block
« Last Edit: September 12, 2009, 04:28:40 PM by WeeboTech »
My Google Code Page

If you propose to speak, THINK and ask yourself... Is it True ?   Is it Helpful ?   Is it Inspiring ?   Is it Necessary ?   Is it Kind ?

If it's none of these, Is it really worth posting?

Offline bjp999

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4573
  • ASRock E3C224-4L/A+, SM C2SEE/B, Asus P5B VM DO/C

Offline Robbie Ferguson

  • Full Member
  • ***
  • Posts: 124
  • twitter.com/robbieferguson
    • Category5 Technology TV
Re: How does parity work... really?
« Reply #3 on: September 12, 2009, 05:03:42 PM »
Thanks so much!  Reminding myself that digital data is stored in 1 or 0 makes it all make sense now.

In honesty though, now that I understand it, I'm astonished.  It's really ... brilliant!  I hope someone won a prize for creating parity-based redundancy  :)
Robbie Ferguson, Host
Category5 Technology TV
www.Category5.TV

Offline Joe L.

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 18819
Re: How does parity work... really?
« Reply #4 on: September 12, 2009, 08:20:54 PM »
yet still have redundancy without striping?
Now that you have gotten a good idea how "parity" works...  The "striping" part just puts part of the parity data on each disk rather than all on one disk.  In the same way, for any given file, part of it is on all the remaining disks for that stripe.  This was originally done for speed... (Older disks were slower, and to issue 5 "read" operations, each for 1/5th of the file's data, you could get each disk to respond in parallel and get to the total data faster)

striping is done to improve performance, by having each disk do a fraction of the I/O, but with all of them spinning.  It is also why losing two disks in a normal RAID5 array loses all the data on ALL drives... because 2/5ths of each block of data on the disks is missing.  If you are using striping, all the disks in the array have to be the same size (or be limited by the size of the smallest drive)

parity is done for protection of data loss.  The two concepts are often used together in a RAID array.
Raid5 is illustrated here: http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel5-c.html

unRAID is actually RAID4, but without striping.  (There is no official name for it as a "RAID" standard)