linux核心md模組raid10資料落盤方式解析及幾個關鍵參數的解讀

來源:互聯網
上載者:User


關鍵詞: linux software raid, md, raid10, r10_private_data_s, near_copies, far_copies, far_offset

核心版本:2.6.18


linux核心md模組實現的RAID10有三種laout模式,分別為near, far和offset。當用mdadm命令來建立RAID10盤時,可以選用這三種中的一種(其實near和far模式可以混用,但是把1個chunk做4個或以上的備份沒啥意義吧)。

[1]三種模式的特點

near方式下,同一個chunk被複製n份,一般為2份,這2份會存在2個相鄰的盤上相同的offset處。far方式下,同一個chunk的n個副本會存在相隔很遠的地方。所有資料的第一個副本會以RAID0條帶的方式存在所有磁碟前面部分,所有資料的第二個副本也會以RAID0條帶的方式存在所有磁碟後面部分,同時far模式保證同一chunk的所有備份都存在不同的磁碟上。

far方式能提供跟RAID0相當的連續讀效能,但是寫的效能會降低(會給寫帶來更多的尋道時間) [1][2],因此far方式更適合於讀多於寫的應用情境。

Offset方式下,同一個chunk的n個副本會以連續的位移量存在連續的磁碟上(位移1個磁碟,offset位移1個chunk)。每個stripe的副本以一個磁碟的位移量儲存。如果chunk大小合適,offset方式能夠提供與far方式相同的讀效能,但是寫效能不會像near方式那麼差。

組成RAID10磁碟的數量不必是每個chunk副本數的整數倍,但至少得有每個chunk副本數那麼多的磁碟。


[2]三種layout方式的樣本

(columns are drives, rows are stripes, LETTERS are chunks of data)

n2 layout:

2 drives         3 drives          4 drives
--------         ----------        --------------
A1  A1           A1  A1  A2        A1  A1  A2  A2
A2  A2           A2  A3  A3        A3  A3  A4  A4
A3  A3           A4  A4  A5        A5  A5  A6  A6
A4  A4           A5  A6  A6        A7  A7  A8  A8
..  ..           ..  ..  ..        ..  ..  ..  ..

f2 layout:

2 drives             3 drives             4 drives
--------             --------------       --------------------
A1  A2               A1   A2   A3         A1   A2   A3   A4
A3  A4               A4   A5   A6         A5   A6   A7   A8
A5  A6               A7   A8   A9         A9   A10  A11  A12
..  ..               ..   ..   ..         ..   ..   ..   ..
A2  A1               A3   A1   A2         A4   A1   A2   A3
A4  A3               A6   A4   A5         A8   A5   A6   A7
A6  A5               A9   A7   A8         A12  A9   A10  A11
..  ..               ..   ..   ..         ..   ..   ..   ..

n2 f2 layout:

A1  A1  A2  A2        A1  A1  A2  A2  A3
A3  A3  A4  A4        A3  A4  A4  A5  A5
A5  A5  A6  A6        A6  A6  A7  A7  A8
A7  A7  A8  A8        A8  A9  A9  A10 A10
..  ..  ..  ..        ..  ..  ..  ..  ..
A2  A2  A1  A1        A2  A3  A1  A1  A2
A4  A4  A3  A3        A5  A5  A3  A4  A4
A6  A6  A5  A5        A7  A8  A6  A6  A7
A8  A8  A7  A7        A10 A10 A8  A9  A9
..  ..  ..  ..        ..  ..  ..  ..  ..

o2 layout:

2 drives       3 drives           4 drives
--------       ------------       -----------------
A1  A2         A1  A2  A3         A1  A2  A3  A4
A2  A1         A3  A1  A2         A4  A1  A2  A3
A3  A4         A4  A5  A6         A5  A6  A7  A8
A4  A3         A6  A4  A5         A8  A5  A6  A7
A5  A6         A7  A8  A9         A9  A10 A11 A12
A6  A5         A9  A7  A8         A12 A9  A10 A11
..  ..         ..  ..  ..         ..  ..  ..  ..

[3]核心裡的幾個關鍵參數

Drivers/md/raid10.h

struct r10_private_data_s {
    ......
    /* geometry */
    int            near_copies;  /* number of copies layed out raid0 style */
    int             far_copies;   /* number of copies layed out
                           * at large strides across drives
                           */
    int            far_offset;   /* far_copies are offset by 1 stripe
                           * instead of many
                           */
    int            copies;          /* near_copies * far_copies.
                           * must be <= raid_disks
                           */
    sector_t        stride;          /* distance between far copies.
                           * This is size / far_copies unless
                           * far_offset, in which case it is
                           * 1 stripe.
                           */
   ......
};

near_copies: 每個chunk有near_copies份副本(含自己)

far_copies: 每個裝置被分成far_copies個section

far_offset: 如果offset為真,則offset模式被啟動,同一個chunk被存在相鄰裝置的不同位移量處。


參考資料:

[1]http://neil.brown.name/blog/20040827225440

[2]http://en.wikipedia.org/wiki/Non-standard_RAID_levels#Linux_MD_RAID_10

[3]man mdadm

[4]man md

[5]Linux-2.6.18kernel source code


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.