Please consider the following diagram of a RAID-5 array (Ignore the gray background):
Now, given a logical address, how can one return the device number (0-3)?
For example, DeviceByLogicalSector(50) = 0, DeviceByLogicalSector(31)=2.
I've need to implement DeviceByLogicalSector method. I can use space if that's required.
Now, I've noticed the following:
Let's observe only the first $4$ rows; If we have a sector which is above the $P$-diagonal then the formula is: $\frac{(\text{logical_addr} \mod 12)}{4}$. And if the sector is below the diagonal then we need to add $1$.
Thanks