Lines Matching refs:mddev

35 	return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";  in bmname()
145 static int read_sb_page(struct mddev *mddev, loff_t offset, in read_sb_page() argument
154 rdev_for_each(rdev, mddev) { in read_sb_page()
171 static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mddev) in next_active_rdev() argument
189 rdev = list_entry(&mddev->disks, struct md_rdev, same_set); in next_active_rdev()
192 rdev_dec_pending(rdev, mddev); in next_active_rdev()
194 list_for_each_entry_continue_rcu(rdev, &mddev->disks, same_set) { in next_active_rdev()
211 struct mddev *mddev = bitmap->mddev; in write_sb_page() local
215 if (mddev_is_clustered(bitmap->mddev)) in write_sb_page()
218 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { in write_sb_page()
220 loff_t offset = mddev->bitmap_info.offset; in write_sb_page()
234 if (mddev->external) { in write_sb_page()
241 < (rdev->data_offset + mddev->dev_sectors in write_sb_page()
251 if (rdev->data_offset + mddev->dev_sectors in write_sb_page()
266 md_super_write(mddev, rdev, in write_sb_page()
274 md_super_wait(mddev); in write_sb_page()
426 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */ in bitmap_update_sb()
428 if (bitmap->mddev->bitmap_info.external) in bitmap_update_sb()
433 sb->events = cpu_to_le64(bitmap->mddev->events); in bitmap_update_sb()
434 if (bitmap->mddev->events < bitmap->events_cleared) in bitmap_update_sb()
436 bitmap->events_cleared = bitmap->mddev->events; in bitmap_update_sb()
440 sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ); in bitmap_update_sb()
441 sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind); in bitmap_update_sb()
443 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in bitmap_update_sb()
444 sb->chunksize = cpu_to_le32(bitmap->mddev->bitmap_info.chunksize); in bitmap_update_sb()
445 sb->nodes = cpu_to_le32(bitmap->mddev->bitmap_info.nodes); in bitmap_update_sb()
446 sb->sectors_reserved = cpu_to_le32(bitmap->mddev-> in bitmap_update_sb()
507 chunksize = bitmap->mddev->bitmap_info.chunksize; in bitmap_new_disk_sb()
516 daemon_sleep = bitmap->mddev->bitmap_info.daemon_sleep; in bitmap_new_disk_sb()
523 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; in bitmap_new_disk_sb()
529 write_behind = bitmap->mddev->bitmap_info.max_write_behind; in bitmap_new_disk_sb()
533 bitmap->mddev->bitmap_info.max_write_behind = write_behind; in bitmap_new_disk_sb()
536 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in bitmap_new_disk_sb()
538 memcpy(sb->uuid, bitmap->mddev->uuid, 16); in bitmap_new_disk_sb()
542 bitmap->events_cleared = bitmap->mddev->events; in bitmap_new_disk_sb()
543 sb->events_cleared = cpu_to_le64(bitmap->mddev->events); in bitmap_new_disk_sb()
544 bitmap->mddev->bitmap_info.nodes = 0; in bitmap_new_disk_sb()
562 loff_t offset = bitmap->mddev->bitmap_info.offset; in bitmap_read_sb()
564 if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { in bitmap_read_sb()
581 sector_t bm_blocks = bitmap->mddev->resync_max_sectors; in bitmap_read_sb()
584 bitmap->mddev->bitmap_info.chunksize >> 9); in bitmap_read_sb()
589 offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3)); in bitmap_read_sb()
601 err = read_sb_page(bitmap->mddev, in bitmap_read_sb()
621 strlcpy(bitmap->mddev->bitmap_info.cluster_name, in bitmap_read_sb()
646 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors); in bitmap_read_sb()
648 if (bitmap->mddev->persistent) { in bitmap_read_sb()
653 if (memcmp(sb->uuid, bitmap->mddev->uuid, 16)) { in bitmap_read_sb()
660 if (!nodes && (events < bitmap->mddev->events)) { in bitmap_read_sb()
665 (unsigned long long) bitmap->mddev->events); in bitmap_read_sb()
675 strlcpy(bitmap->mddev->bitmap_info.cluster_name, sb->cluster_name, 64); in bitmap_read_sb()
681 bitmap->mddev->bitmap_info.chunksize = chunksize; in bitmap_read_sb()
683 err = md_setup_cluster(bitmap->mddev, nodes); in bitmap_read_sb()
689 bitmap->cluster_slot = md_cluster_ops->slot_number(bitmap->mddev); in bitmap_read_sb()
696 bitmap->events_cleared = bitmap->mddev->events; in bitmap_read_sb()
697 bitmap->mddev->bitmap_info.chunksize = chunksize; in bitmap_read_sb()
698 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; in bitmap_read_sb()
699 bitmap->mddev->bitmap_info.max_write_behind = write_behind; in bitmap_read_sb()
700 bitmap->mddev->bitmap_info.nodes = nodes; in bitmap_read_sb()
701 if (bitmap->mddev->bitmap_info.space == 0 || in bitmap_read_sb()
702 bitmap->mddev->bitmap_info.space > sectors_reserved) in bitmap_read_sb()
703 bitmap->mddev->bitmap_info.space = sectors_reserved; in bitmap_read_sb()
707 md_cluster_stop(bitmap->mddev); in bitmap_read_sb()
1001 md_super_wait(bitmap->mddev); in bitmap_unplug()
1035 if (!file && !bitmap->mddev->bitmap_info.offset) { in bitmap_init_from_disk()
1065 if (!bitmap->mddev->bitmap_info.external) in bitmap_init_from_disk()
1068 if (mddev_is_clustered(bitmap->mddev)) in bitmap_init_from_disk()
1088 bitmap->mddev, in bitmap_init_from_disk()
1089 bitmap->mddev->bitmap_info.offset, in bitmap_init_from_disk()
1193 void bitmap_daemon_work(struct mddev *mddev) in bitmap_daemon_work() argument
1204 mutex_lock(&mddev->bitmap_info.mutex); in bitmap_daemon_work()
1205 bitmap = mddev->bitmap; in bitmap_daemon_work()
1207 mutex_unlock(&mddev->bitmap_info.mutex); in bitmap_daemon_work()
1211 + mddev->bitmap_info.daemon_sleep)) in bitmap_daemon_work()
1216 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; in bitmap_daemon_work()
1232 mddev->bitmap_info.external == 0) { in bitmap_daemon_work()
1309 mddev->thread->timeout = in bitmap_daemon_work()
1310 mddev->bitmap_info.daemon_sleep; in bitmap_daemon_work()
1311 mutex_unlock(&mddev->bitmap_info.mutex); in bitmap_daemon_work()
1369 bw, bitmap->mddev->bitmap_info.max_write_behind); in bitmap_startwrite()
1430 bitmap->mddev->bitmap_info.max_write_behind); in bitmap_endwrite()
1445 if (success && !bitmap->mddev->degraded && in bitmap_endwrite()
1446 bitmap->events_cleared < bitmap->mddev->events) { in bitmap_endwrite()
1447 bitmap->events_cleared = bitmap->mddev->events; in bitmap_endwrite()
1566 while (sector < bitmap->mddev->resync_max_sectors) { in bitmap_close_sync()
1585 + bitmap->mddev->bitmap_info.daemon_sleep))) in bitmap_cond_end_sync()
1587 wait_event(bitmap->mddev->recovery_wait, in bitmap_cond_end_sync()
1588 atomic_read(&bitmap->mddev->recovery_active) == 0); in bitmap_cond_end_sync()
1590 bitmap->mddev->curr_resync_completed = sector; in bitmap_cond_end_sync()
1591 set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags); in bitmap_cond_end_sync()
1594 while (s < sector && s < bitmap->mddev->resync_max_sectors) { in bitmap_cond_end_sync()
1599 sysfs_notify(&bitmap->mddev->kobj, NULL, "sync_completed"); in bitmap_cond_end_sync()
1638 if (sec < bitmap->mddev->recovery_cp) in bitmap_dirty_bits()
1643 bitmap->mddev->recovery_cp = sec; in bitmap_dirty_bits()
1650 void bitmap_flush(struct mddev *mddev) in bitmap_flush() argument
1652 struct bitmap *bitmap = mddev->bitmap; in bitmap_flush()
1661 sleep = mddev->bitmap_info.daemon_sleep * 2; in bitmap_flush()
1663 bitmap_daemon_work(mddev); in bitmap_flush()
1665 bitmap_daemon_work(mddev); in bitmap_flush()
1667 bitmap_daemon_work(mddev); in bitmap_flush()
1682 if (mddev_is_clustered(bitmap->mddev) && bitmap->mddev->cluster_info && in bitmap_free()
1683 bitmap->cluster_slot == md_cluster_ops->slot_number(bitmap->mddev)) in bitmap_free()
1684 md_cluster_stop(bitmap->mddev); in bitmap_free()
1706 void bitmap_destroy(struct mddev *mddev) in bitmap_destroy() argument
1708 struct bitmap *bitmap = mddev->bitmap; in bitmap_destroy()
1713 mutex_lock(&mddev->bitmap_info.mutex); in bitmap_destroy()
1714 spin_lock(&mddev->lock); in bitmap_destroy()
1715 mddev->bitmap = NULL; /* disconnect from the md device */ in bitmap_destroy()
1716 spin_unlock(&mddev->lock); in bitmap_destroy()
1717 mutex_unlock(&mddev->bitmap_info.mutex); in bitmap_destroy()
1718 if (mddev->thread) in bitmap_destroy()
1719 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; in bitmap_destroy()
1731 struct bitmap *bitmap_create(struct mddev *mddev, int slot) in bitmap_create() argument
1734 sector_t blocks = mddev->resync_max_sectors; in bitmap_create()
1735 struct file *file = mddev->bitmap_info.file; in bitmap_create()
1741 BUG_ON(file && mddev->bitmap_info.offset); in bitmap_create()
1753 bitmap->mddev = mddev; in bitmap_create()
1756 if (mddev->kobj.sd) in bitmap_create()
1757 bm = sysfs_get_dirent(mddev->kobj.sd, "bitmap"); in bitmap_create()
1774 if (!mddev->bitmap_info.external) { in bitmap_create()
1779 if (test_and_clear_bit(MD_ARRAY_FIRST_USE, &mddev->flags)) in bitmap_create()
1785 if (mddev->bitmap_info.chunksize == 0 || in bitmap_create()
1786 mddev->bitmap_info.daemon_sleep == 0) in bitmap_create()
1795 err = bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1); in bitmap_create()
1812 int bitmap_load(struct mddev *mddev) in bitmap_load() argument
1817 struct bitmap *bitmap = mddev->bitmap; in bitmap_load()
1827 while (sector < mddev->resync_max_sectors) { in bitmap_load()
1834 if (mddev->degraded == 0 in bitmap_load()
1835 || bitmap->events_cleared == mddev->events) in bitmap_load()
1838 start = mddev->recovery_cp; in bitmap_load()
1840 mutex_lock(&mddev->bitmap_info.mutex); in bitmap_load()
1842 mutex_unlock(&mddev->bitmap_info.mutex); in bitmap_load()
1849 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); in bitmap_load()
1851 mddev->thread->timeout = mddev->bitmap_info.daemon_sleep; in bitmap_load()
1852 md_wakeup_thread(mddev->thread); in bitmap_load()
1866 int bitmap_copy_from_slot(struct mddev *mddev, int slot, in bitmap_copy_from_slot() argument
1872 struct bitmap *bitmap = bitmap_create(mddev, slot); in bitmap_copy_from_slot()
1889 bitmap_set_memory_bits(mddev->bitmap, block, 1); in bitmap_copy_from_slot()
1890 bitmap_file_set_bit(mddev->bitmap, block); in bitmap_copy_from_slot()
1923 chunk_kb = bitmap->mddev->bitmap_info.chunksize >> 10; in bitmap_status()
1930 chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize, in bitmap_status()
1968 long space = bitmap->mddev->bitmap_info.space; in bitmap_resize()
1975 if (!bitmap->mddev->bitmap_info.external) in bitmap_resize()
1978 bitmap->mddev->bitmap_info.space = space; in bitmap_resize()
1987 if (!bitmap->mddev->bitmap_info.external) in bitmap_resize()
1995 if (bitmap->mddev->bitmap_info.offset || bitmap->mddev->bitmap_info.file) in bitmap_resize()
1997 !bitmap->mddev->bitmap_info.external, in bitmap_resize()
1998 mddev_is_clustered(bitmap->mddev) in bitmap_resize()
2013 bitmap->mddev->pers->quiesce(bitmap->mddev, 1); in bitmap_resize()
2031 bitmap->mddev->bitmap_info.chunksize = 1 << (chunkshift + in bitmap_resize()
2098 bitmap->mddev->pers->quiesce(bitmap->mddev, 0); in bitmap_resize()
2107 location_show(struct mddev *mddev, char *page) in location_show() argument
2110 if (mddev->bitmap_info.file) in location_show()
2112 else if (mddev->bitmap_info.offset) in location_show()
2113 len = sprintf(page, "%+lld", (long long)mddev->bitmap_info.offset); in location_show()
2121 location_store(struct mddev *mddev, const char *buf, size_t len) in location_store() argument
2124 if (mddev->pers) { in location_store()
2125 if (!mddev->pers->quiesce) in location_store()
2127 if (mddev->recovery || mddev->sync_thread) in location_store()
2131 if (mddev->bitmap || mddev->bitmap_info.file || in location_store()
2132 mddev->bitmap_info.offset) { in location_store()
2136 if (mddev->pers) { in location_store()
2137 mddev->pers->quiesce(mddev, 1); in location_store()
2138 bitmap_destroy(mddev); in location_store()
2139 mddev->pers->quiesce(mddev, 0); in location_store()
2141 mddev->bitmap_info.offset = 0; in location_store()
2142 if (mddev->bitmap_info.file) { in location_store()
2143 struct file *f = mddev->bitmap_info.file; in location_store()
2144 mddev->bitmap_info.file = NULL; in location_store()
2165 if (mddev->bitmap_info.external == 0 && in location_store()
2166 mddev->major_version == 0 && in location_store()
2167 offset != mddev->bitmap_info.default_offset) in location_store()
2169 mddev->bitmap_info.offset = offset; in location_store()
2170 if (mddev->pers) { in location_store()
2172 mddev->pers->quiesce(mddev, 1); in location_store()
2173 bitmap = bitmap_create(mddev, -1); in location_store()
2177 mddev->bitmap = bitmap; in location_store()
2178 rv = bitmap_load(mddev); in location_store()
2180 bitmap_destroy(mddev); in location_store()
2181 mddev->bitmap_info.offset = 0; in location_store()
2184 mddev->pers->quiesce(mddev, 0); in location_store()
2190 if (!mddev->external) { in location_store()
2194 set_bit(MD_CHANGE_DEVS, &mddev->flags); in location_store()
2195 md_wakeup_thread(mddev->thread); in location_store()
2208 space_show(struct mddev *mddev, char *page) in space_show() argument
2210 return sprintf(page, "%lu\n", mddev->bitmap_info.space); in space_show()
2214 space_store(struct mddev *mddev, const char *buf, size_t len) in space_store() argument
2226 if (mddev->bitmap && in space_store()
2227 sectors < (mddev->bitmap->storage.bytes + 511) >> 9) in space_store()
2233 mddev->bitmap_info.space = sectors; in space_store()
2241 timeout_show(struct mddev *mddev, char *page) in timeout_show() argument
2244 unsigned long secs = mddev->bitmap_info.daemon_sleep / HZ; in timeout_show()
2245 unsigned long jifs = mddev->bitmap_info.daemon_sleep % HZ; in timeout_show()
2255 timeout_store(struct mddev *mddev, const char *buf, size_t len) in timeout_store() argument
2273 mddev->bitmap_info.daemon_sleep = timeout; in timeout_store()
2274 if (mddev->thread) { in timeout_store()
2279 if (mddev->thread->timeout < MAX_SCHEDULE_TIMEOUT) { in timeout_store()
2280 mddev->thread->timeout = timeout; in timeout_store()
2281 md_wakeup_thread(mddev->thread); in timeout_store()
2291 backlog_show(struct mddev *mddev, char *page) in backlog_show() argument
2293 return sprintf(page, "%lu\n", mddev->bitmap_info.max_write_behind); in backlog_show()
2297 backlog_store(struct mddev *mddev, const char *buf, size_t len) in backlog_store() argument
2305 mddev->bitmap_info.max_write_behind = backlog; in backlog_store()
2313 chunksize_show(struct mddev *mddev, char *page) in chunksize_show() argument
2315 return sprintf(page, "%lu\n", mddev->bitmap_info.chunksize); in chunksize_show()
2319 chunksize_store(struct mddev *mddev, const char *buf, size_t len) in chunksize_store() argument
2324 if (mddev->bitmap) in chunksize_store()
2332 mddev->bitmap_info.chunksize = csize; in chunksize_store()
2339 static ssize_t metadata_show(struct mddev *mddev, char *page) in metadata_show() argument
2341 if (mddev_is_clustered(mddev)) in metadata_show()
2343 return sprintf(page, "%s\n", (mddev->bitmap_info.external in metadata_show()
2347 static ssize_t metadata_store(struct mddev *mddev, const char *buf, size_t len) in metadata_store() argument
2349 if (mddev->bitmap || in metadata_store()
2350 mddev->bitmap_info.file || in metadata_store()
2351 mddev->bitmap_info.offset) in metadata_store()
2354 mddev->bitmap_info.external = 1; in metadata_store()
2357 mddev->bitmap_info.external = 0; in metadata_store()
2366 static ssize_t can_clear_show(struct mddev *mddev, char *page) in can_clear_show() argument
2369 spin_lock(&mddev->lock); in can_clear_show()
2370 if (mddev->bitmap) in can_clear_show()
2371 len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ? in can_clear_show()
2375 spin_unlock(&mddev->lock); in can_clear_show()
2379 static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len) in can_clear_store() argument
2381 if (mddev->bitmap == NULL) in can_clear_store()
2384 mddev->bitmap->need_sync = 1; in can_clear_store()
2386 if (mddev->degraded) in can_clear_store()
2388 mddev->bitmap->need_sync = 0; in can_clear_store()
2398 behind_writes_used_show(struct mddev *mddev, char *page) in behind_writes_used_show() argument
2401 spin_lock(&mddev->lock); in behind_writes_used_show()
2402 if (mddev->bitmap == NULL) in behind_writes_used_show()
2406 mddev->bitmap->behind_writes_used); in behind_writes_used_show()
2407 spin_unlock(&mddev->lock); in behind_writes_used_show()
2412 behind_writes_used_reset(struct mddev *mddev, const char *buf, size_t len) in behind_writes_used_reset() argument
2414 if (mddev->bitmap) in behind_writes_used_reset()
2415 mddev->bitmap->behind_writes_used = 0; in behind_writes_used_reset()