Lines Matching refs:mddev
37 return bitmap->mddev ? mdname(bitmap->mddev) : "mdX"; in bmname()
149 static int read_sb_page(struct mddev *mddev, loff_t offset, in read_sb_page() argument
158 rdev_for_each(rdev, mddev) { in read_sb_page()
176 static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mddev) in next_active_rdev() argument
194 rdev = list_entry(&mddev->disks, struct md_rdev, same_set); in next_active_rdev()
197 rdev_dec_pending(rdev, mddev); in next_active_rdev()
199 list_for_each_entry_continue_rcu(rdev, &mddev->disks, same_set) { in next_active_rdev()
216 struct mddev *mddev = bitmap->mddev; in write_sb_page() local
221 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { in write_sb_page()
223 loff_t offset = mddev->bitmap_info.offset; in write_sb_page()
237 if (mddev->external) { in write_sb_page()
244 < (rdev->data_offset + mddev->dev_sectors in write_sb_page()
254 if (rdev->data_offset + mddev->dev_sectors in write_sb_page()
269 md_super_write(mddev, rdev, in write_sb_page()
276 if (wait && md_super_wait(mddev) < 0) in write_sb_page()
439 md_super_wait(bitmap->mddev); in md_bitmap_wait_writes()
448 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */ in md_bitmap_update_sb()
450 if (bitmap->mddev->bitmap_info.external) in md_bitmap_update_sb()
455 sb->events = cpu_to_le64(bitmap->mddev->events); in md_bitmap_update_sb()
456 if (bitmap->mddev->events < bitmap->events_cleared) in md_bitmap_update_sb()
458 bitmap->events_cleared = bitmap->mddev->events; in md_bitmap_update_sb()
466 sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); in md_bitmap_update_sb()
467 sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); in md_bitmap_update_sb()
469 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in md_bitmap_update_sb()
470 sb->chunksize = cpu_to_le32(bitmap->mddev->bitmap_info.chunksize); in md_bitmap_update_sb()
471 sb->nodes = cpu_to_le32(bitmap->mddev->bitmap_info.nodes); in md_bitmap_update_sb()
472 sb->sectors_reserved = cpu_to_le32(bitmap->mddev-> in md_bitmap_update_sb()
534 chunksize = bitmap->mddev->bitmap_info.chunksize; in md_bitmap_new_disk_sb()
543 daemon_sleep = bitmap->mddev->bitmap_info.daemon_sleep; in md_bitmap_new_disk_sb()
549 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; in md_bitmap_new_disk_sb()
555 write_behind = bitmap->mddev->bitmap_info.max_write_behind; in md_bitmap_new_disk_sb()
559 bitmap->mddev->bitmap_info.max_write_behind = write_behind; in md_bitmap_new_disk_sb()
562 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in md_bitmap_new_disk_sb()
564 memcpy(sb->uuid, bitmap->mddev->uuid, 16); in md_bitmap_new_disk_sb()
568 bitmap->events_cleared = bitmap->mddev->events; in md_bitmap_new_disk_sb()
569 sb->events_cleared = cpu_to_le64(bitmap->mddev->events); in md_bitmap_new_disk_sb()
570 bitmap->mddev->bitmap_info.nodes = 0; in md_bitmap_new_disk_sb()
588 loff_t offset = bitmap->mddev->bitmap_info.offset; in md_bitmap_read_sb()
590 if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { in md_bitmap_read_sb()
607 sector_t bm_blocks = bitmap->mddev->resync_max_sectors; in md_bitmap_read_sb()
610 (bitmap->mddev->bitmap_info.chunksize >> 9)); in md_bitmap_read_sb()
615 offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3)); in md_bitmap_read_sb()
627 err = read_sb_page(bitmap->mddev, in md_bitmap_read_sb()
669 strscpy(bitmap->mddev->bitmap_info.cluster_name, in md_bitmap_read_sb()
674 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in md_bitmap_read_sb()
676 if (bitmap->mddev->persistent) { in md_bitmap_read_sb()
681 if (memcmp(sb->uuid, bitmap->mddev->uuid, 16)) { in md_bitmap_read_sb()
687 if (!nodes && (events < bitmap->mddev->events)) { in md_bitmap_read_sb()
690 (unsigned long long) bitmap->mddev->events); in md_bitmap_read_sb()
706 bitmap->mddev->bitmap_info.chunksize = chunksize; in md_bitmap_read_sb()
707 err = md_setup_cluster(bitmap->mddev, nodes); in md_bitmap_read_sb()
713 bitmap->cluster_slot = md_cluster_ops->slot_number(bitmap->mddev); in md_bitmap_read_sb()
720 bitmap->events_cleared = bitmap->mddev->events; in md_bitmap_read_sb()
721 bitmap->mddev->bitmap_info.chunksize = chunksize; in md_bitmap_read_sb()
722 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; in md_bitmap_read_sb()
723 bitmap->mddev->bitmap_info.max_write_behind = write_behind; in md_bitmap_read_sb()
724 bitmap->mddev->bitmap_info.nodes = nodes; in md_bitmap_read_sb()
725 if (bitmap->mddev->bitmap_info.space == 0 || in md_bitmap_read_sb()
726 bitmap->mddev->bitmap_info.space > sectors_reserved) in md_bitmap_read_sb()
727 bitmap->mddev->bitmap_info.space = sectors_reserved; in md_bitmap_read_sb()
731 md_cluster_stop(bitmap->mddev); in md_bitmap_read_sb()
934 if (mddev_is_clustered(bitmap->mddev)) in md_bitmap_file_set_bit()
963 if (mddev_is_clustered(bitmap->mddev)) in md_bitmap_file_clear_bit()
1026 if (bitmap->mddev->queue) in md_bitmap_unplug()
1027 blk_add_trace_msg(bitmap->mddev->queue, in md_bitmap_unplug()
1070 if (!file && !bitmap->mddev->bitmap_info.offset) { in md_bitmap_init_from_disk()
1099 if (!bitmap->mddev->bitmap_info.external) in md_bitmap_init_from_disk()
1102 if (mddev_is_clustered(bitmap->mddev)) in md_bitmap_init_from_disk()
1122 bitmap->mddev, in md_bitmap_init_from_disk()
1123 bitmap->mddev->bitmap_info.offset, in md_bitmap_init_from_disk()
1226 void md_bitmap_daemon_work(struct mddev *mddev) in md_bitmap_daemon_work() argument
1237 mutex_lock(&mddev->bitmap_info.mutex); in md_bitmap_daemon_work()
1238 bitmap = mddev->bitmap; in md_bitmap_daemon_work()
1240 mutex_unlock(&mddev->bitmap_info.mutex); in md_bitmap_daemon_work()
1244 + mddev->bitmap_info.daemon_sleep)) in md_bitmap_daemon_work()
1249 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; in md_bitmap_daemon_work()
1254 if (bitmap->mddev->queue) in md_bitmap_daemon_work()
1255 blk_add_trace_msg(bitmap->mddev->queue, in md_bitmap_daemon_work()
1269 mddev->bitmap_info.external == 0) { in md_bitmap_daemon_work()
1346 mddev->thread->timeout = in md_bitmap_daemon_work()
1347 mddev->bitmap_info.daemon_sleep; in md_bitmap_daemon_work()
1348 mutex_unlock(&mddev->bitmap_info.mutex); in md_bitmap_daemon_work()
1406 bw, bitmap->mddev->bitmap_info.max_write_behind); in md_bitmap_startwrite()
1467 bitmap->mddev->bitmap_info.max_write_behind); in md_bitmap_endwrite()
1482 if (success && !bitmap->mddev->degraded && in md_bitmap_endwrite()
1483 bitmap->events_cleared < bitmap->mddev->events) { in md_bitmap_endwrite()
1484 bitmap->events_cleared = bitmap->mddev->events; in md_bitmap_endwrite()
1603 while (sector < bitmap->mddev->resync_max_sectors) { in md_bitmap_close_sync()
1622 + bitmap->mddev->bitmap_info.daemon_sleep))) in md_bitmap_cond_end_sync()
1624 wait_event(bitmap->mddev->recovery_wait, in md_bitmap_cond_end_sync()
1625 atomic_read(&bitmap->mddev->recovery_active) == 0); in md_bitmap_cond_end_sync()
1627 bitmap->mddev->curr_resync_completed = sector; in md_bitmap_cond_end_sync()
1628 set_bit(MD_SB_CHANGE_CLEAN, &bitmap->mddev->sb_flags); in md_bitmap_cond_end_sync()
1631 while (s < sector && s < bitmap->mddev->resync_max_sectors) { in md_bitmap_cond_end_sync()
1636 sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed); in md_bitmap_cond_end_sync()
1640 void md_bitmap_sync_with_cluster(struct mddev *mddev, in md_bitmap_sync_with_cluster() argument
1644 struct bitmap *bitmap = mddev->bitmap; in md_bitmap_sync_with_cluster()
1696 if (sec < bitmap->mddev->recovery_cp) in md_bitmap_dirty_bits()
1701 bitmap->mddev->recovery_cp = sec; in md_bitmap_dirty_bits()
1708 void md_bitmap_flush(struct mddev *mddev) in md_bitmap_flush() argument
1710 struct bitmap *bitmap = mddev->bitmap; in md_bitmap_flush()
1719 sleep = mddev->bitmap_info.daemon_sleep * 2; in md_bitmap_flush()
1721 md_bitmap_daemon_work(mddev); in md_bitmap_flush()
1723 md_bitmap_daemon_work(mddev); in md_bitmap_flush()
1725 md_bitmap_daemon_work(mddev); in md_bitmap_flush()
1726 if (mddev->bitmap_info.external) in md_bitmap_flush()
1727 md_super_wait(mddev); in md_bitmap_flush()
1745 if (mddev_is_clustered(bitmap->mddev) && bitmap->mddev->cluster_info && in md_bitmap_free()
1746 bitmap->cluster_slot == md_cluster_ops->slot_number(bitmap->mddev)) in md_bitmap_free()
1747 md_cluster_stop(bitmap->mddev); in md_bitmap_free()
1770 void md_bitmap_wait_behind_writes(struct mddev *mddev) in md_bitmap_wait_behind_writes() argument
1772 struct bitmap *bitmap = mddev->bitmap; in md_bitmap_wait_behind_writes()
1777 mdname(mddev)); in md_bitmap_wait_behind_writes()
1784 void md_bitmap_destroy(struct mddev *mddev) in md_bitmap_destroy() argument
1786 struct bitmap *bitmap = mddev->bitmap; in md_bitmap_destroy()
1791 md_bitmap_wait_behind_writes(mddev); in md_bitmap_destroy()
1792 if (!mddev->serialize_policy) in md_bitmap_destroy()
1793 mddev_destroy_serial_pool(mddev, NULL, true); in md_bitmap_destroy()
1795 mutex_lock(&mddev->bitmap_info.mutex); in md_bitmap_destroy()
1796 spin_lock(&mddev->lock); in md_bitmap_destroy()
1797 mddev->bitmap = NULL; /* disconnect from the md device */ in md_bitmap_destroy()
1798 spin_unlock(&mddev->lock); in md_bitmap_destroy()
1799 mutex_unlock(&mddev->bitmap_info.mutex); in md_bitmap_destroy()
1800 if (mddev->thread) in md_bitmap_destroy()
1801 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; in md_bitmap_destroy()
1811 struct bitmap *md_bitmap_create(struct mddev *mddev, int slot) in md_bitmap_create() argument
1814 sector_t blocks = mddev->resync_max_sectors; in md_bitmap_create()
1815 struct file *file = mddev->bitmap_info.file; in md_bitmap_create()
1821 BUG_ON(file && mddev->bitmap_info.offset); in md_bitmap_create()
1823 if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) { in md_bitmap_create()
1825 mdname(mddev)); in md_bitmap_create()
1839 bitmap->mddev = mddev; in md_bitmap_create()
1842 if (mddev->kobj.sd) in md_bitmap_create()
1843 bm = sysfs_get_dirent(mddev->kobj.sd, "bitmap"); in md_bitmap_create()
1860 if (!mddev->bitmap_info.external) { in md_bitmap_create()
1865 if (test_and_clear_bit(MD_ARRAY_FIRST_USE, &mddev->flags)) in md_bitmap_create()
1871 if (mddev->bitmap_info.chunksize == 0 || in md_bitmap_create()
1872 mddev->bitmap_info.daemon_sleep == 0) in md_bitmap_create()
1881 err = md_bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1); in md_bitmap_create()
1898 int md_bitmap_load(struct mddev *mddev) in md_bitmap_load() argument
1903 struct bitmap *bitmap = mddev->bitmap; in md_bitmap_load()
1909 rdev_for_each(rdev, mddev) in md_bitmap_load()
1910 mddev_create_serial_pool(mddev, rdev, true); in md_bitmap_load()
1912 if (mddev_is_clustered(mddev)) in md_bitmap_load()
1913 md_cluster_ops->load_bitmaps(mddev, mddev->bitmap_info.nodes); in md_bitmap_load()
1920 while (sector < mddev->resync_max_sectors) { in md_bitmap_load()
1927 if (mddev->degraded == 0 in md_bitmap_load()
1928 || bitmap->events_cleared == mddev->events) in md_bitmap_load()
1931 start = mddev->recovery_cp; in md_bitmap_load()
1933 mutex_lock(&mddev->bitmap_info.mutex); in md_bitmap_load()
1935 mutex_unlock(&mddev->bitmap_info.mutex); in md_bitmap_load()
1942 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); in md_bitmap_load()
1944 mddev->thread->timeout = mddev->bitmap_info.daemon_sleep; in md_bitmap_load()
1945 md_wakeup_thread(mddev->thread); in md_bitmap_load()
1957 struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) in get_bitmap_from_slot() argument
1962 bitmap = md_bitmap_create(mddev, slot); in get_bitmap_from_slot()
1981 int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, in md_bitmap_copy_from_slot() argument
1989 bitmap = get_bitmap_from_slot(mddev, slot); in md_bitmap_copy_from_slot()
2003 md_bitmap_set_memory_bits(mddev->bitmap, block, 1); in md_bitmap_copy_from_slot()
2004 md_bitmap_file_set_bit(mddev->bitmap, block); in md_bitmap_copy_from_slot()
2017 md_bitmap_unplug(mddev->bitmap); in md_bitmap_copy_from_slot()
2037 chunk_kb = bitmap->mddev->bitmap_info.chunksize >> 10; in md_bitmap_status()
2044 chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize, in md_bitmap_status()
2087 long space = bitmap->mddev->bitmap_info.space; in md_bitmap_resize()
2094 if (!bitmap->mddev->bitmap_info.external) in md_bitmap_resize()
2097 bitmap->mddev->bitmap_info.space = space; in md_bitmap_resize()
2106 if (!bitmap->mddev->bitmap_info.external) in md_bitmap_resize()
2115 if (bitmap->mddev->bitmap_info.offset || bitmap->mddev->bitmap_info.file) in md_bitmap_resize()
2117 !bitmap->mddev->bitmap_info.external, in md_bitmap_resize()
2118 mddev_is_clustered(bitmap->mddev) in md_bitmap_resize()
2135 bitmap->mddev->pers->quiesce(bitmap->mddev, 1); in md_bitmap_resize()
2154 bitmap->mddev->bitmap_info.chunksize = 1UL << (chunkshift + in md_bitmap_resize()
2161 if (mddev_is_clustered(bitmap->mddev)) { in md_bitmap_resize()
2180 bitmap->mddev->bitmap_info.chunksize = in md_bitmap_resize()
2254 bitmap->mddev->pers->quiesce(bitmap->mddev, 0); in md_bitmap_resize()
2263 location_show(struct mddev *mddev, char *page) in location_show() argument
2266 if (mddev->bitmap_info.file) in location_show()
2268 else if (mddev->bitmap_info.offset) in location_show()
2269 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset); in location_show()
2277 location_store(struct mddev *mddev, const char *buf, size_t len) in location_store() argument
2281 rv = mddev_lock(mddev); in location_store()
2284 if (mddev->pers) { in location_store()
2285 if (!mddev->pers->quiesce) { in location_store()
2289 if (mddev->recovery || mddev->sync_thread) { in location_store()
2295 if (mddev->bitmap || mddev->bitmap_info.file || in location_store()
2296 mddev->bitmap_info.offset) { in location_store()
2302 if (mddev->pers) { in location_store()
2303 mddev_suspend(mddev); in location_store()
2304 md_bitmap_destroy(mddev); in location_store()
2305 mddev_resume(mddev); in location_store()
2307 mddev->bitmap_info.offset = 0; in location_store()
2308 if (mddev->bitmap_info.file) { in location_store()
2309 struct file *f = mddev->bitmap_info.file; in location_store()
2310 mddev->bitmap_info.file = NULL; in location_store()
2333 if (mddev->bitmap_info.external == 0 && in location_store()
2334 mddev->major_version == 0 && in location_store()
2335 offset != mddev->bitmap_info.default_offset) { in location_store()
2339 mddev->bitmap_info.offset = offset; in location_store()
2340 if (mddev->pers) { in location_store()
2342 bitmap = md_bitmap_create(mddev, -1); in location_store()
2343 mddev_suspend(mddev); in location_store()
2347 mddev->bitmap = bitmap; in location_store()
2348 rv = md_bitmap_load(mddev); in location_store()
2350 mddev->bitmap_info.offset = 0; in location_store()
2353 md_bitmap_destroy(mddev); in location_store()
2354 mddev_resume(mddev); in location_store()
2357 mddev_resume(mddev); in location_store()
2361 if (!mddev->external) { in location_store()
2365 set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); in location_store()
2366 md_wakeup_thread(mddev->thread); in location_store()
2370 mddev_unlock(mddev); in location_store()
2384 space_show(struct mddev *mddev, char *page) in space_show() argument
2386 return sprintf(page, "%lu\n", mddev->bitmap_info.space); in space_show()
2390 space_store(struct mddev *mddev, const char *buf, size_t len) in space_store() argument
2402 if (mddev->bitmap && in space_store()
2403 sectors < (mddev->bitmap->storage.bytes + 511) >> 9) in space_store()
2409 mddev->bitmap_info.space = sectors; in space_store()
2417 timeout_show(struct mddev *mddev, char *page) in timeout_show() argument
2420 unsigned long secs = mddev->bitmap_info.daemon_sleep / HZ; in timeout_show()
2421 unsigned long jifs = mddev->bitmap_info.daemon_sleep % HZ; in timeout_show()
2431 timeout_store(struct mddev *mddev, const char *buf, size_t len) in timeout_store() argument
2449 mddev->bitmap_info.daemon_sleep = timeout; in timeout_store()
2450 if (mddev->thread) { in timeout_store()
2455 if (mddev->thread->timeout < MAX_SCHEDULE_TIMEOUT) { in timeout_store()
2456 mddev->thread->timeout = timeout; in timeout_store()
2457 md_wakeup_thread(mddev->thread); in timeout_store()
2467 backlog_show(struct mddev *mddev, char *page) in backlog_show() argument
2469 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind); in backlog_show()
2473 backlog_store(struct mddev *mddev, const char *buf, size_t len) in backlog_store() argument
2476 unsigned long old_mwb = mddev->bitmap_info.max_write_behind; in backlog_store()
2489 rdev_for_each(rdev, mddev) { in backlog_store()
2497 mdname(mddev)); in backlog_store()
2501 mddev->bitmap_info.max_write_behind = backlog; in backlog_store()
2502 if (!backlog && mddev->serial_info_pool) { in backlog_store()
2504 if (!mddev->serialize_policy) in backlog_store()
2505 mddev_destroy_serial_pool(mddev, NULL, false); in backlog_store()
2506 } else if (backlog && !mddev->serial_info_pool) { in backlog_store()
2510 rdev_for_each(rdev, mddev) in backlog_store()
2511 mddev_create_serial_pool(mddev, rdev, false); in backlog_store()
2514 md_bitmap_update_sb(mddev->bitmap); in backlog_store()
2522 chunksize_show(struct mddev *mddev, char *page) in chunksize_show() argument
2524 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize); in chunksize_show()
2528 chunksize_store(struct mddev *mddev, const char *buf, size_t len) in chunksize_store() argument
2533 if (mddev->bitmap) in chunksize_store()
2544 mddev->bitmap_info.chunksize = csize; in chunksize_store()
2551 static ssize_t metadata_show(struct mddev *mddev, char *page) in metadata_show() argument
2553 if (mddev_is_clustered(mddev)) in metadata_show()
2555 return sprintf(page, "%s\n", (mddev->bitmap_info.external in metadata_show()
2559 static ssize_t metadata_store(struct mddev *mddev, const char *buf, size_t len) in metadata_store() argument
2561 if (mddev->bitmap || in metadata_store()
2562 mddev->bitmap_info.file || in metadata_store()
2563 mddev->bitmap_info.offset) in metadata_store()
2566 mddev->bitmap_info.external = 1; in metadata_store()
2569 mddev->bitmap_info.external = 0; in metadata_store()
2578 static ssize_t can_clear_show(struct mddev *mddev, char *page) in can_clear_show() argument
2581 spin_lock(&mddev->lock); in can_clear_show()
2582 if (mddev->bitmap) in can_clear_show()
2583 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ? in can_clear_show()
2587 spin_unlock(&mddev->lock); in can_clear_show()
2591 static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len) in can_clear_store() argument
2593 if (mddev->bitmap == NULL) in can_clear_store()
2596 mddev->bitmap->need_sync = 1; in can_clear_store()
2598 if (mddev->degraded) in can_clear_store()
2600 mddev->bitmap->need_sync = 0; in can_clear_store()
2610 behind_writes_used_show(struct mddev *mddev, char *page) in behind_writes_used_show() argument
2613 spin_lock(&mddev->lock); in behind_writes_used_show()
2614 if (mddev->bitmap == NULL) in behind_writes_used_show()
2618 mddev->bitmap->behind_writes_used); in behind_writes_used_show()
2619 spin_unlock(&mddev->lock); in behind_writes_used_show()
2624 behind_writes_used_reset(struct mddev *mddev, const char *buf, size_t len) in behind_writes_used_reset() argument
2626 if (mddev->bitmap) in behind_writes_used_reset()
2627 mddev->bitmap->behind_writes_used = 0; in behind_writes_used_reset()