Lines Matching refs:rdev
224 mdk_rdev_t * rdev; in find_rdev_nr() local
227 ITERATE_RDEV(mddev,rdev,tmp) { in find_rdev_nr()
228 if (rdev->desc_nr == nr) in find_rdev_nr()
229 return rdev; in find_rdev_nr()
237 mdk_rdev_t *rdev; in find_rdev() local
239 ITERATE_RDEV(mddev,rdev,tmp) { in find_rdev()
240 if (rdev->dev == dev) in find_rdev()
241 return rdev; in find_rdev()
314 mdk_rdev_t * rdev; in zoned_raid_size() local
326 ITERATE_RDEV(mddev,rdev,tmp) { in zoned_raid_size()
327 rdev->size &= mask; in zoned_raid_size()
328 md_size[mdidx(mddev)] += rdev->size; in zoned_raid_size()
344 mdk_rdev_t *rdev; in md_check_ordering() local
350 ITERATE_RDEV(mddev,rdev,tmp) { in md_check_ordering()
351 if (rdev->faulty) { in md_check_ordering()
353 mdidx(mddev), partition_name(rdev->dev)); in md_check_ordering()
359 ITERATE_RDEV(mddev,rdev,tmp) { in md_check_ordering()
376 ITERATE_RDEV(mddev,rdev,tmp) { in md_check_ordering()
377 if (rdev->desc_nr == i) in md_check_ordering()
443 static int alloc_disk_sb(mdk_rdev_t * rdev) in alloc_disk_sb() argument
445 if (rdev->sb) in alloc_disk_sb()
448 rdev->sb_page = alloc_page(GFP_KERNEL); in alloc_disk_sb()
449 if (!rdev->sb_page) { in alloc_disk_sb()
453 rdev->sb = (mdp_super_t *) page_address(rdev->sb_page); in alloc_disk_sb()
458 static void free_disk_sb(mdk_rdev_t * rdev) in free_disk_sb() argument
460 if (rdev->sb_page) { in free_disk_sb()
461 page_cache_release(rdev->sb_page); in free_disk_sb()
462 rdev->sb = NULL; in free_disk_sb()
463 rdev->sb_page = NULL; in free_disk_sb()
464 rdev->sb_offset = 0; in free_disk_sb()
465 rdev->size = 0; in free_disk_sb()
467 if (!rdev->faulty) in free_disk_sb()
505 static int read_disk_sb(mdk_rdev_t * rdev) in read_disk_sb() argument
508 kdev_t dev = rdev->dev; in read_disk_sb()
511 if (!rdev->sb) { in read_disk_sb()
520 sb_offset = calc_dev_sboffset(rdev->dev, rdev->mddev, 1); in read_disk_sb()
521 rdev->sb_offset = sb_offset; in read_disk_sb()
523 if (!sync_page_io(dev, sb_offset<<1, MD_SB_BYTES, rdev->sb_page, READ)) { in read_disk_sb()
527 printk(KERN_INFO " [events: %08lx]\n", (unsigned long)rdev->sb->events_lo); in read_disk_sb()
548 static int check_disk_sb(mdk_rdev_t * rdev) in check_disk_sb() argument
553 sb = rdev->sb; in check_disk_sb()
560 printk(BAD_MAGIC, partition_name(rdev->dev)); in check_disk_sb()
565 printk(BAD_MINOR, partition_name(rdev->dev), sb->md_minor); in check_disk_sb()
570 printk(BAD_CSUM, partition_name(rdev->dev)); in check_disk_sb()
593 mdk_rdev_t *rdev; in match_dev_unit() local
595 ITERATE_RDEV(mddev,rdev,tmp) in match_dev_unit()
596 if (dev_unit(rdev->dev) == dev_unit(dev)) in match_dev_unit()
597 return rdev; in match_dev_unit()
605 mdk_rdev_t *rdev; in match_mddev_units() local
607 ITERATE_RDEV(mddev1,rdev,tmp) in match_mddev_units()
608 if (match_dev_unit(mddev2, rdev->dev)) in match_mddev_units()
617 static void bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) in bind_rdev_to_array() argument
621 if (rdev->mddev) { in bind_rdev_to_array()
625 same_pdev = match_dev_unit(mddev, rdev->dev); in bind_rdev_to_array()
630 mdidx(mddev), partition_name(rdev->dev), in bind_rdev_to_array()
633 md_list_add(&rdev->same_set, &mddev->disks); in bind_rdev_to_array()
634 rdev->mddev = mddev; in bind_rdev_to_array()
636 printk(KERN_INFO "md: bind<%s,%d>\n", partition_name(rdev->dev), mddev->nb_dev); in bind_rdev_to_array()
639 static void unbind_rdev_from_array(mdk_rdev_t * rdev) in unbind_rdev_from_array() argument
641 if (!rdev->mddev) { in unbind_rdev_from_array()
645 md_list_del(&rdev->same_set); in unbind_rdev_from_array()
646 MD_INIT_LIST_HEAD(&rdev->same_set); in unbind_rdev_from_array()
647 rdev->mddev->nb_dev--; in unbind_rdev_from_array()
648 printk(KERN_INFO "md: unbind<%s,%d>\n", partition_name(rdev->dev), in unbind_rdev_from_array()
649 rdev->mddev->nb_dev); in unbind_rdev_from_array()
650 rdev->mddev = NULL; in unbind_rdev_from_array()
660 static int lock_rdev(mdk_rdev_t *rdev) in lock_rdev() argument
665 bdev = bdget(rdev->dev); in lock_rdev()
670 rdev->bdev = bdev; in lock_rdev()
674 static void unlock_rdev(mdk_rdev_t *rdev) in unlock_rdev() argument
676 struct block_device *bdev = rdev->bdev; in unlock_rdev()
677 rdev->bdev = NULL; in unlock_rdev()
685 static void export_rdev(mdk_rdev_t * rdev) in export_rdev() argument
687 printk(KERN_INFO "md: export_rdev(%s)\n",partition_name(rdev->dev)); in export_rdev()
688 if (rdev->mddev) in export_rdev()
690 unlock_rdev(rdev); in export_rdev()
691 free_disk_sb(rdev); in export_rdev()
692 md_list_del(&rdev->all); in export_rdev()
693 MD_INIT_LIST_HEAD(&rdev->all); in export_rdev()
694 if (rdev->pending.next != &rdev->pending) { in export_rdev()
696 partition_name(rdev->dev)); in export_rdev()
697 md_list_del(&rdev->pending); in export_rdev()
698 MD_INIT_LIST_HEAD(&rdev->pending); in export_rdev()
701 md_autodetect_dev(rdev->dev); in export_rdev()
703 rdev->dev = 0; in export_rdev()
704 rdev->faulty = 0; in export_rdev()
705 kfree(rdev); in export_rdev()
708 static void kick_rdev_from_array(mdk_rdev_t * rdev) in kick_rdev_from_array() argument
710 unbind_rdev_from_array(rdev); in kick_rdev_from_array()
711 export_rdev(rdev); in kick_rdev_from_array()
717 mdk_rdev_t *rdev; in export_array() local
725 ITERATE_RDEV(mddev,rdev,tmp) { in export_array()
726 if (!rdev->mddev) { in export_array()
730 kick_rdev_from_array(rdev); in export_array()
807 static void print_rdev(mdk_rdev_t *rdev) in print_rdev() argument
810 partition_name(rdev->dev), partition_name(rdev->old_dev), in print_rdev()
811 rdev->size, rdev->faulty, rdev->desc_nr); in print_rdev()
812 if (rdev->sb) { in print_rdev()
814 print_sb(rdev->sb); in print_rdev()
822 mdk_rdev_t *rdev; in md_print_devices() local
832 ITERATE_RDEV(mddev,rdev,tmp2) in md_print_devices()
833 printk("<%s>", partition_name(rdev->dev)); in md_print_devices()
841 ITERATE_RDEV(mddev,rdev,tmp2) in md_print_devices()
842 print_rdev(rdev); in md_print_devices()
900 mdk_rdev_t *rdev; in find_rdev_all() local
904 rdev = md_list_entry(tmp, mdk_rdev_t, all); in find_rdev_all()
905 if (rdev->dev == dev) in find_rdev_all()
906 return rdev; in find_rdev_all()
915 static int write_disk_sb(mdk_rdev_t * rdev) in write_disk_sb() argument
920 if (!rdev->sb) { in write_disk_sb()
924 if (rdev->faulty) { in write_disk_sb()
928 if (rdev->sb->md_magic != MD_SB_MAGIC) { in write_disk_sb()
933 dev = rdev->dev; in write_disk_sb()
934 sb_offset = calc_dev_sboffset(dev, rdev->mddev, 1); in write_disk_sb()
935 if (rdev->sb_offset != sb_offset) { in write_disk_sb()
937 partition_name(dev), rdev->sb_offset, sb_offset); in write_disk_sb()
945 size = calc_dev_size(dev, rdev->mddev, 1); in write_disk_sb()
946 if (size != rdev->size) { in write_disk_sb()
948 partition_name(dev), rdev->size, size); in write_disk_sb()
954 if (!sync_page_io(dev, sb_offset<<1, MD_SB_BYTES, rdev->sb_page, WRITE)) { in write_disk_sb()
963 static void set_this_disk(mddev_t *mddev, mdk_rdev_t *rdev) in set_this_disk() argument
972 if (MKDEV(desc->major,desc->minor) == rdev->dev) in set_this_disk()
977 if (MKDEV(desc->major,desc->minor) == rdev->dev) { in set_this_disk()
978 rdev->sb->this_disk = *desc; in set_this_disk()
979 rdev->desc_nr = desc->number; in set_this_disk()
992 mdk_rdev_t *rdev; in sync_sbs() local
996 ITERATE_RDEV(mddev,rdev,tmp) { in sync_sbs()
997 if (rdev->faulty || rdev->alias_device) in sync_sbs()
999 sb = rdev->sb; in sync_sbs()
1001 set_this_disk(mddev, rdev); in sync_sbs()
1011 mdk_rdev_t *rdev; in md_update_sb() local
1045 ITERATE_RDEV(mddev,rdev,tmp) { in md_update_sb()
1047 if (rdev->faulty) in md_update_sb()
1049 if (rdev->alias_device) in md_update_sb()
1051 if (!rdev->faulty && disk_faulty(&rdev->sb->this_disk)) { in md_update_sb()
1053 partition_name(rdev->dev)); in md_update_sb()
1056 printk("%s ", partition_name(rdev->dev)); in md_update_sb()
1057 if (!rdev->faulty && !rdev->alias_device) { in md_update_sb()
1059 (unsigned long)rdev->sb->events_lo); in md_update_sb()
1060 err += write_disk_sb(rdev); in md_update_sb()
1086 mdk_rdev_t *rdev; in md_import_device() local
1092 rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL); in md_import_device()
1093 if (!rdev) { in md_import_device()
1097 memset(rdev, 0, sizeof(*rdev)); in md_import_device()
1106 if ((err = alloc_disk_sb(rdev))) in md_import_device()
1109 rdev->dev = newdev; in md_import_device()
1110 if (lock_rdev(rdev)) { in md_import_device()
1116 rdev->desc_nr = -1; in md_import_device()
1117 rdev->faulty = 0; in md_import_device()
1130 if ((err = read_disk_sb(rdev))) { in md_import_device()
1135 if ((err = check_disk_sb(rdev))) { in md_import_device()
1141 if (rdev->sb->level != -4) { in md_import_device()
1142 rdev->old_dev = MKDEV(rdev->sb->this_disk.major, in md_import_device()
1143 rdev->sb->this_disk.minor); in md_import_device()
1144 rdev->desc_nr = rdev->sb->this_disk.number; in md_import_device()
1146 rdev->old_dev = MKDEV(0, 0); in md_import_device()
1147 rdev->desc_nr = -1; in md_import_device()
1150 md_list_add(&rdev->all, &all_raid_disks); in md_import_device()
1151 MD_INIT_LIST_HEAD(&rdev->pending); in md_import_device()
1156 if (rdev->sb) { in md_import_device()
1157 if (rdev->bdev) in md_import_device()
1158 unlock_rdev(rdev); in md_import_device()
1159 free_disk_sb(rdev); in md_import_device()
1161 kfree(rdev); in md_import_device()
1188 mdk_rdev_t *rdev, *rdev2, *freshest; in analyze_sbs() local
1194 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1195 if (rdev->faulty) { in analyze_sbs()
1199 if (!rdev->sb) { in analyze_sbs()
1203 if (check_disk_sb(rdev)) in analyze_sbs()
1213 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1215 sb = rdev->sb; in analyze_sbs()
1218 if (!sb_equal(sb, rdev->sb)) { in analyze_sbs()
1219 printk(INCONSISTENT, partition_name(rdev->dev)); in analyze_sbs()
1220 kick_rdev_from_array(rdev); in analyze_sbs()
1236 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1243 if (calc_sb_csum(rdev->sb) != rdev->sb->sb_csum) { in analyze_sbs()
1244 if (rdev->sb->events_lo || rdev->sb->events_hi) in analyze_sbs()
1245 if ((rdev->sb->events_lo--)==0) in analyze_sbs()
1246 rdev->sb->events_hi--; in analyze_sbs()
1250 partition_name(rdev->dev), in analyze_sbs()
1251 (unsigned long)rdev->sb->events_lo); in analyze_sbs()
1253 freshest = rdev; in analyze_sbs()
1259 ev1 = md_event(rdev->sb); in analyze_sbs()
1264 freshest = rdev; in analyze_sbs()
1287 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1290 rdev->desc_nr=desc_nr; in analyze_sbs()
1292 desc = &sb->disks[rdev->desc_nr]; in analyze_sbs()
1295 desc->major = MAJOR(rdev->dev); in analyze_sbs()
1296 desc->minor = MINOR(rdev->dev); in analyze_sbs()
1304 memcpy(&rdev->sb->this_disk,desc,sizeof(*desc)); in analyze_sbs()
1320 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1325 ev1 = md_event(rdev->sb); in analyze_sbs()
1330 partition_name(rdev->dev)); in analyze_sbs()
1331 kick_rdev_from_array(rdev); in analyze_sbs()
1340 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1342 if (rdev->faulty || rdev->alias_device) { in analyze_sbs()
1346 ev1 = md_event(rdev->sb); in analyze_sbs()
1350 if ((rdev->dev != rdev->old_dev) && in analyze_sbs()
1355 partition_name(rdev->old_dev), partition_name(rdev->dev)); in analyze_sbs()
1356 if (rdev->desc_nr == -1) { in analyze_sbs()
1360 desc = &sb->disks[rdev->desc_nr]; in analyze_sbs()
1361 if (rdev->old_dev != MKDEV(desc->major, desc->minor)) { in analyze_sbs()
1365 desc->major = MAJOR(rdev->dev); in analyze_sbs()
1366 desc->minor = MINOR(rdev->dev); in analyze_sbs()
1367 desc = &rdev->sb->this_disk; in analyze_sbs()
1368 desc->major = MAJOR(rdev->dev); in analyze_sbs()
1369 desc->minor = MINOR(rdev->dev); in analyze_sbs()
1394 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1395 if (rdev->desc_nr != desc->number) in analyze_sbs()
1398 mdidx(mddev),partition_name(rdev->dev)); in analyze_sbs()
1399 kick_rdev_from_array(rdev); in analyze_sbs()
1419 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1420 if (rdev->desc_nr == desc->number) { in analyze_sbs()
1454 rdev = find_rdev(mddev, dev); in analyze_sbs()
1455 if (!rdev) { in analyze_sbs()
1466 if ((rdev->desc_nr != -1) && (rdev->desc_nr != i)) { in analyze_sbs()
1470 rdev->desc_nr = i; in analyze_sbs()
1472 rdev->alias_device = 1; in analyze_sbs()
1482 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1483 if (rdev->desc_nr == -1) in analyze_sbs()
1484 kick_rdev_from_array(rdev); in analyze_sbs()
1491 ITERATE_RDEV(mddev,rdev,tmp) { in analyze_sbs()
1492 if (rdev->desc_nr == -1) { in analyze_sbs()
1500 if ((rdev2 != rdev) && in analyze_sbs()
1501 (rdev2->desc_nr == rdev->desc_nr)) { in analyze_sbs()
1510 if ((rdev2 != rdev) && in analyze_sbs()
1511 (rdev2->dev == rdev->dev)) { in analyze_sbs()
1550 mdk_rdev_t *rdev; in device_size_calculation() local
1558 ITERATE_RDEV(mddev,rdev,tmp) { in device_size_calculation()
1559 if (rdev->faulty) in device_size_calculation()
1561 if (rdev->size) { in device_size_calculation()
1565 rdev->size = calc_dev_size(rdev->dev, mddev, persistent); in device_size_calculation()
1566 if (rdev->size < sb->chunk_size / 1024) { in device_size_calculation()
1569 partition_name(rdev->dev), in device_size_calculation()
1570 rdev->size, sb->chunk_size / 1024); in device_size_calculation()
1645 mdk_rdev_t *rdev; in do_md_run() local
1737 ITERATE_RDEV(mddev,rdev,tmp) { in do_md_run()
1738 if (rdev->faulty) in do_md_run()
1740 invalidate_device(rdev->dev, 1); in do_md_run()
1741 if (get_hardsect_size(rdev->dev) in do_md_run()
1744 get_hardsect_size(rdev->dev); in do_md_run()
1917 mdk_rdev_t *rdev; in autorun_array() local
1928 ITERATE_RDEV(mddev,rdev,tmp) { in autorun_array()
1929 printk("<%s>", partition_name(rdev->dev)); in autorun_array()
1960 mdk_rdev_t *rdev0, *rdev; in autorun_devices() local
1972 ITERATE_RDEV_PENDING(rdev,tmp) { in autorun_devices()
1973 if (uuid_equal(rdev0, rdev)) { in autorun_devices()
1974 if (!sb_equal(rdev0->sb, rdev->sb)) { in autorun_devices()
1977 partition_name(rdev->dev), partition_name(rdev0->dev)); in autorun_devices()
1980 printk(KERN_INFO "md: adding %s ...\n", partition_name(rdev->dev)); in autorun_devices()
1981 md_list_del(&rdev->pending); in autorun_devices()
1982 md_list_add(&rdev->pending, &candidates); in autorun_devices()
1995 ITERATE_RDEV_GENERIC(candidates,pending,rdev,tmp) in autorun_devices()
1996 export_rdev(rdev); in autorun_devices()
2007 ITERATE_RDEV_GENERIC(candidates,pending,rdev,tmp) { in autorun_devices()
2008 bind_rdev_to_array(rdev, mddev); in autorun_devices()
2009 md_list_del(&rdev->pending); in autorun_devices()
2010 MD_INIT_LIST_HEAD(&rdev->pending); in autorun_devices()
2053 mdk_rdev_t *start_rdev = NULL, *rdev; in autostart_array() local
2098 rdev = find_rdev_all(dev); in autostart_array()
2099 if (!rdev) { in autostart_array()
2103 md_list_add(&rdev->pending, &pending_raid_disks); in autostart_array()
2213 mdk_rdev_t *rdev; in add_new_disk() local
2230 rdev = find_rdev_all(dev); in add_new_disk()
2231 if (!rdev) { in add_new_disk()
2238 if (!uuid_equal(rdev0, rdev)) { in add_new_disk()
2240 partition_name(rdev->dev), partition_name(rdev0->dev)); in add_new_disk()
2241 export_rdev(rdev); in add_new_disk()
2244 if (!sb_equal(rdev0->sb, rdev->sb)) { in add_new_disk()
2246 partition_name(rdev->dev), partition_name(rdev0->dev)); in add_new_disk()
2247 export_rdev(rdev); in add_new_disk()
2251 bind_rdev_to_array(rdev, mddev); in add_new_disk()
2274 rdev = find_rdev_all(dev); in add_new_disk()
2275 if (!rdev) { in add_new_disk()
2280 rdev->old_dev = dev; in add_new_disk()
2281 rdev->desc_nr = info->number; in add_new_disk()
2283 bind_rdev_to_array(rdev, mddev); in add_new_disk()
2290 rdev->sb_offset = calc_dev_sboffset(dev, mddev, persistent); in add_new_disk()
2308 mdk_rdev_t *rdev; in hot_generate_error() local
2317 rdev = find_rdev(mddev, dev); in hot_generate_error()
2318 if (!rdev) { in hot_generate_error()
2323 if (rdev->desc_nr == -1) { in hot_generate_error()
2327 disk = &mddev->sb->disks[rdev->desc_nr]; in hot_generate_error()
2331 q = blk_get_queue(rdev->dev); in hot_generate_error()
2345 mdk_rdev_t *rdev; in hot_remove_disk() local
2360 rdev = find_rdev(mddev, dev); in hot_remove_disk()
2361 if (!rdev) in hot_remove_disk()
2364 if (rdev->desc_nr == -1) { in hot_remove_disk()
2368 disk = &mddev->sb->disks[rdev->desc_nr]; in hot_remove_disk()
2385 kick_rdev_from_array(rdev); in hot_remove_disk()
2400 mdk_rdev_t *rdev; in hot_add_disk() local
2417 rdev = find_rdev(mddev, dev); in hot_add_disk()
2418 if (rdev) in hot_add_disk()
2426 rdev = find_rdev_all(dev); in hot_add_disk()
2427 if (!rdev) { in hot_add_disk()
2431 if (rdev->faulty) { in hot_add_disk()
2445 bind_rdev_to_array(rdev, mddev); in hot_add_disk()
2451 rdev->old_dev = dev; in hot_add_disk()
2452 rdev->size = size; in hot_add_disk()
2453 rdev->sb_offset = calc_dev_sboffset(dev, mddev, persistent); in hot_add_disk()
2511 unbind_rdev_from_array(rdev); in hot_add_disk()
2514 export_rdev(rdev); in hot_add_disk()
3060 int md_error(mddev_t *mddev, kdev_t rdev) in md_error() argument
3065 MAJOR(dev),MINOR(dev),MAJOR(rdev),MINOR(rdev), in md_error()
3073 rrdev = find_rdev(mddev, rdev); in md_error()
3077 || mddev->pers->error_handler(mddev,rdev) <= 0) { in md_error()
3096 mdk_rdev_t *rdev; in status_unused() local
3101 ITERATE_RDEV_ALL(rdev,tmp) { in status_unused()
3102 if (!rdev->same_set.next && !rdev->same_set.prev) { in status_unused()
3108 partition_name(rdev->dev)); in status_unused()
3231 mdk_rdev_t *rdev; in md_seq_show() local
3262 ITERATE_RDEV(mddev,rdev,tmp2) { in md_seq_show()
3264 partition_name(rdev->dev), rdev->desc_nr); in md_seq_show()
3265 if (rdev->faulty) { in md_seq_show()
3269 size += rdev->size; in md_seq_show()
3354 mdk_rdev_t *rdev; in get_spare() local
3357 ITERATE_RDEV(mddev,rdev,tmp) { in get_spare()
3358 if (rdev->faulty) in get_spare()
3360 if (!rdev->sb) { in get_spare()
3364 disk = &sb->disks[rdev->desc_nr]; in get_spare()
3391 mdk_rdev_t * rdev; in is_mddev_idle() local
3397 ITERATE_RDEV(mddev,rdev,tmp) { in is_mddev_idle()
3398 int major = MAJOR(rdev->dev); in is_mddev_idle()
3399 int idx = disk_index(rdev->dev); in is_mddev_idle()
3407 if ((curr_events - rdev->last_events) > 32) { in is_mddev_idle()
3408 rdev->last_events = curr_events; in is_mddev_idle()
3819 mdk_rdev_t *rdev; in autostart_arrays() local
3835 rdev = find_rdev_all(dev); in autostart_arrays()
3836 if (!rdev) { in autostart_arrays()
3840 if (rdev->faulty) { in autostart_arrays()
3844 md_list_add(&rdev->pending, &pending_raid_disks); in autostart_arrays()