예제 #1
0
        private List <ArrayPosition> TranslateSectors(long startSectorIndex, int sectorCount)
        {
            List <ArrayPosition> result = new List <ArrayPosition>();

            int numberOfDisks = m_extents.Count;

            int  sectorsLeft        = sectorCount;
            long currentSectorIndex = startSectorIndex;

            while (sectorsLeft > 0)
            {
                long extentStartSectorInColumn     = 0;
                long nextExtentStartSectorInColumn = 0;
                for (int index = 0; index < m_extents.Count; index++)
                {
                    DynamicDiskExtent extent = m_extents[index];
                    extentStartSectorInColumn      = nextExtentStartSectorInColumn;
                    nextExtentStartSectorInColumn += extent.TotalSectors;
                    if (currentSectorIndex >= extentStartSectorInColumn && currentSectorIndex < nextExtentStartSectorInColumn)
                    {
                        long          sectorIndexInExtent = currentSectorIndex - extentStartSectorInColumn;
                        int           sectorCountInExtent = (int)Math.Min(extent.TotalSectors - sectorIndexInExtent, sectorsLeft);
                        ArrayPosition position            = new ArrayPosition(index, sectorIndexInExtent, sectorCountInExtent);
                        result.Add(position);
                        currentSectorIndex += sectorCountInExtent;
                        sectorsLeft        -= sectorCountInExtent;
                    }
                }
            }

            return(result);
        }
예제 #2
0
        public List <ArrayPosition> TranslateSectors(long startSectorIndex, int sectorCount)
        {
            List <ArrayPosition> result = new List <ArrayPosition>();

            int numberOfColumns = m_columns.Count;

            int  sectorsLeft        = sectorCount;
            long currentSectorIndex = startSectorIndex;

            while (sectorsLeft > 0)
            {
                long stripeIndexInVolume = currentSectorIndex / m_sectorsPerStripe;
                long stripeIndexInColumn = stripeIndexInVolume / numberOfColumns;

                int diskIndex = (int)(stripeIndexInVolume % numberOfColumns);

                long columnSectorIndex = stripeIndexInColumn * m_sectorsPerStripe + (currentSectorIndex % m_sectorsPerStripe);

                int sectorsToReadFromCurrentColumnStripe = Math.Min(m_sectorsPerStripe - (int)(columnSectorIndex % m_sectorsPerStripe), sectorsLeft);

                // e.g. :
                // Column 0: 0 3 6 ...
                // Column 1: 1 4 7 ...
                // Column 2: 2 5 8 ...

                ArrayPosition position = new ArrayPosition(diskIndex, columnSectorIndex, sectorsToReadFromCurrentColumnStripe);
                result.Add(position);
                currentSectorIndex += sectorsToReadFromCurrentColumnStripe;
                sectorsLeft        -= sectorsToReadFromCurrentColumnStripe;
            }

            return(result);
        }
예제 #3
0
        // Each ArrayPosition is within a single stripe
        public List <ArrayPosition> TranslateSectors(long startSectorIndex, int sectorCount)
        {
            List <ArrayPosition> result = new List <ArrayPosition>();

            int numberOfColumns = m_columns.Count;

            int  sectorsLeft        = sectorCount;
            long currentSectorIndex = startSectorIndex;

            while (sectorsLeft > 0)
            {
                long dataStripeIndexInVolume = currentSectorIndex / m_sectorsPerStripe; // stripe index if we don't count parity stripes
                long stripeIndexInColumn     = dataStripeIndexInVolume / (numberOfColumns - 1);

                int parityColumnIndex = (numberOfColumns - 1) - (int)(stripeIndexInColumn % numberOfColumns);
                int columnIndex       = (int)(dataStripeIndexInVolume % numberOfColumns);

                // Another way to calculate columnIndex:
                //int stripeVerticalIndex = (int)(dataStripeIndexInVolume % (numberOfColumns - 1));
                //int columnIndex2 = (parityColumnIndex + 1 + stripeVerticalIndex) % numberOfColumns;


                long columnSectorIndex = stripeIndexInColumn * m_sectorsPerStripe + (currentSectorIndex % m_sectorsPerStripe);

                int sectorsToReadFromCurrentColumnStripe = Math.Min(m_sectorsPerStripe - (int)(columnSectorIndex % m_sectorsPerStripe), sectorsLeft);

                // e.g. :
                // Column 0: 0 3 P ...
                // Column 1: 1 P 4 ...
                // Column 2: P 2 5 ...

                // Column 0: 0 4 8  P ...
                // Column 1: 1 5 P 09 ...
                // Column 2: 2 P 6 10 ...
                // Column 3: P 3 7 11 ...

                ArrayPosition position = new ArrayPosition(columnIndex, columnSectorIndex, sectorsToReadFromCurrentColumnStripe);
                result.Add(position);
                currentSectorIndex += sectorsToReadFromCurrentColumnStripe;
                sectorsLeft        -= sectorsToReadFromCurrentColumnStripe;
            }

            return(result);
        }