linux核心md原始碼解讀 六 介紹raid10陣列的運行

來源:互聯網
上載者:User

raid10的run函數與raid5的run函數最大區別在於setup_conf,那就直接深入核心:

3540 static struct r10conf *setup_conf(struct mddev *mddev)  3541 {  3542         struct r10conf *conf = NULL;  3543         int err = -EINVAL;  3544         struct geom geo;  3545         int copies;  3546   3547         copies = setup_geo(&geo, mddev, geo_new);  3548   3549         if (copies == -2) {  3550                 printk(KERN_ERR "md/raid10:%s: chunk size must be "3551                        "at least PAGE_SIZE(%ld) and be a power of 2.\n",  3552                        mdname(mddev), PAGE_SIZE);  3553                 goto out;  3554         }  3555   3556         if (copies < 2 || copies > mddev->raid_disks) {  3557                 printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",  3558                        mdname(mddev), mddev->new_layout);  3559                 goto out;  3560         }  3561   3562         err = -ENOMEM;  3563         conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL);  3564         if (!conf)  3565                 goto out;  3566   3567         /* FIXME calc properly */3568         conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks +  3569                                                             max(0,-mddev->delta_disks)),  3570                                 GFP_KERNEL);  3571         if (!conf->mirrors)  3572                 goto out;  3573   3574         conf->tmppage = alloc_page(GFP_KERNEL);  3575         if (!conf->tmppage)  3576                 goto out;  3577   3578         conf->geo = geo;  3579         conf->copies = copies;  3580         conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc,  3581                                            r10bio_pool_free, conf);  3582         if (!conf->r10bio_pool)  3583                 goto out;  3584   3585         calc_sectors(conf, mddev->dev_sectors);  3586         if (mddev->reshape_position == MaxSector) {  3587                 conf->prev = conf->geo;  3588                 conf->reshape_progress = MaxSector;  3589         } else {  3590                 if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) {  3591                         err = -EINVAL;  3592                         goto out;  3593                 }  3594                 conf->reshape_progress = mddev->reshape_position;  3595                 if (conf->prev.far_offset)  3596                         conf->prev.stride = 1 << conf->prev.chunk_shift;  3597                 else3598                         /* far_copies must be 1 */3599                         conf->prev.stride = conf->dev_sectors;  3600         }  3601         spin_lock_init(&conf->device_lock);  3602         INIT_LIST_HEAD(&conf->retry_list);  3603   3604         spin_lock_init(&conf->resync_lock);  3605         init_waitqueue_head(&conf->wait_barrier);  3606   3607         conf->thread = md_register_thread(raid10d, mddev, "raid10");  3608         if (!conf->thread)  3609                 goto out;  3610   3611         conf->mddev = mddev;  3612         return conf;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.