Lines Matching refs:conf
39 #define R5C_FULL_STRIPE_FLUSH_BATCH(conf) (conf->max_nr_stripes / 4) argument
195 static inline sector_t r5c_tree_index(struct r5conf *conf, in r5c_tree_index() argument
200 offset = sector_div(sect, conf->chunk_sectors); in r5c_tree_index()
294 r5c_return_dev_pending_writes(struct r5conf *conf, struct r5dev *dev) in r5c_return_dev_pending_writes() argument
303 md_write_end(conf->mddev); in r5c_return_dev_pending_writes()
309 void r5c_handle_cached_data_endio(struct r5conf *conf, in r5c_handle_cached_data_endio() argument
317 r5c_return_dev_pending_writes(conf, &sh->dev[i]); in r5c_handle_cached_data_endio()
318 md_bitmap_endwrite(conf->mddev->bitmap, sh->sector, in r5c_handle_cached_data_endio()
329 void r5c_check_stripe_cache_usage(struct r5conf *conf) in r5c_check_stripe_cache_usage() argument
333 if (!r5c_is_writeback(conf->log)) in r5c_check_stripe_cache_usage()
336 total_cached = atomic_read(&conf->r5c_cached_partial_stripes) + in r5c_check_stripe_cache_usage()
337 atomic_read(&conf->r5c_cached_full_stripes); in r5c_check_stripe_cache_usage()
347 if (total_cached > conf->min_nr_stripes * 1 / 2 || in r5c_check_stripe_cache_usage()
348 atomic_read(&conf->empty_inactive_list_nr) > 0) in r5c_check_stripe_cache_usage()
349 r5l_wake_reclaim(conf->log, 0); in r5c_check_stripe_cache_usage()
356 void r5c_check_cached_full_stripe(struct r5conf *conf) in r5c_check_cached_full_stripe() argument
358 if (!r5c_is_writeback(conf->log)) in r5c_check_cached_full_stripe()
365 if (atomic_read(&conf->r5c_cached_full_stripes) >= in r5c_check_cached_full_stripe()
366 min(R5C_FULL_STRIPE_FLUSH_BATCH(conf), in r5c_check_cached_full_stripe()
367 conf->chunk_sectors >> STRIPE_SHIFT)) in r5c_check_cached_full_stripe()
368 r5l_wake_reclaim(conf->log, 0); in r5c_check_cached_full_stripe()
399 static sector_t r5c_log_required_to_flush_cache(struct r5conf *conf) in r5c_log_required_to_flush_cache() argument
401 struct r5l_log *log = conf->log; in r5c_log_required_to_flush_cache()
407 ((conf->max_degraded + 1) * atomic_read(&log->stripe_in_journal_count) + in r5c_log_required_to_flush_cache()
408 (conf->raid_disks - conf->max_degraded) * (conf->group_cnt + 1)); in r5c_log_required_to_flush_cache()
420 struct r5conf *conf = log->rdev->mddev->private; in r5c_update_log_state() local
430 reclaim_space = r5c_log_required_to_flush_cache(conf); in r5c_update_log_state()
432 set_bit(R5C_LOG_CRITICAL, &conf->cache_state); in r5c_update_log_state()
434 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state)) in r5c_update_log_state()
436 clear_bit(R5C_LOG_CRITICAL, &conf->cache_state); in r5c_update_log_state()
439 set_bit(R5C_LOG_TIGHT, &conf->cache_state); in r5c_update_log_state()
441 clear_bit(R5C_LOG_TIGHT, &conf->cache_state); in r5c_update_log_state()
453 struct r5conf *conf = sh->raid_conf; in r5c_make_stripe_write_out() local
454 struct r5l_log *log = conf->log; in r5c_make_stripe_write_out()
462 atomic_inc(&conf->preread_active_stripes); in r5c_make_stripe_write_out()
687 struct r5conf *conf = mddev->private; in r5c_disable_writeback_async() local
697 conf->log == NULL || in r5c_disable_writeback_async()
867 struct r5conf *conf = mddev->private; in r5l_append_flush_payload() local
877 if (conf->quiesce) in r5l_append_flush_payload()
996 struct r5conf *conf = sh->raid_conf; in r5l_write_stripe() local
1065 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) && in r5l_write_stripe()
1154 static sector_t r5c_calculate_new_cp(struct r5conf *conf) in r5c_calculate_new_cp() argument
1157 struct r5l_log *log = conf->log; in r5c_calculate_new_cp()
1165 if (list_empty(&conf->log->stripe_in_journal_list)) { in r5c_calculate_new_cp()
1170 sh = list_first_entry(&conf->log->stripe_in_journal_list, in r5c_calculate_new_cp()
1179 struct r5conf *conf = log->rdev->mddev->private; in r5l_reclaimable_space() local
1182 r5c_calculate_new_cp(conf)); in r5l_reclaimable_space()
1227 struct r5conf *conf = log->rdev->mddev->private; in __r5l_stripe_write_finished() local
1239 test_bit(R5C_LOG_TIGHT, &conf->cache_state)) in __r5l_stripe_write_finished()
1366 static void r5c_flush_stripe(struct r5conf *conf, struct stripe_head *sh) in r5c_flush_stripe() argument
1377 lockdep_assert_held(&conf->device_lock); in r5c_flush_stripe()
1383 atomic_inc(&conf->active_stripes); in r5c_flush_stripe()
1387 atomic_inc(&conf->r5c_flushing_partial_stripes); in r5c_flush_stripe()
1389 atomic_inc(&conf->r5c_flushing_full_stripes); in r5c_flush_stripe()
1399 void r5c_flush_cache(struct r5conf *conf, int num) in r5c_flush_cache() argument
1404 lockdep_assert_held(&conf->device_lock); in r5c_flush_cache()
1405 if (!conf->log) in r5c_flush_cache()
1409 list_for_each_entry_safe(sh, next, &conf->r5c_full_stripe_list, lru) { in r5c_flush_cache()
1410 r5c_flush_stripe(conf, sh); in r5c_flush_cache()
1417 &conf->r5c_partial_stripe_list, lru) { in r5c_flush_cache()
1418 r5c_flush_stripe(conf, sh); in r5c_flush_cache()
1424 static void r5c_do_reclaim(struct r5conf *conf) in r5c_do_reclaim() argument
1426 struct r5l_log *log = conf->log; in r5c_do_reclaim()
1437 flushing_partial = atomic_read(&conf->r5c_flushing_partial_stripes); in r5c_do_reclaim()
1438 flushing_full = atomic_read(&conf->r5c_flushing_full_stripes); in r5c_do_reclaim()
1439 total_cached = atomic_read(&conf->r5c_cached_partial_stripes) + in r5c_do_reclaim()
1440 atomic_read(&conf->r5c_cached_full_stripes) - in r5c_do_reclaim()
1443 if (total_cached > conf->min_nr_stripes * 3 / 4 || in r5c_do_reclaim()
1444 atomic_read(&conf->empty_inactive_list_nr) > 0) in r5c_do_reclaim()
1450 else if (total_cached > conf->min_nr_stripes * 1 / 2 || in r5c_do_reclaim()
1451 atomic_read(&conf->r5c_cached_full_stripes) - flushing_full > in r5c_do_reclaim()
1452 R5C_FULL_STRIPE_FLUSH_BATCH(conf)) in r5c_do_reclaim()
1463 spin_lock_irqsave(&conf->device_lock, flags); in r5c_do_reclaim()
1464 r5c_flush_cache(conf, stripes_to_flush); in r5c_do_reclaim()
1465 spin_unlock_irqrestore(&conf->device_lock, flags); in r5c_do_reclaim()
1469 if (test_bit(R5C_LOG_TIGHT, &conf->cache_state)) { in r5c_do_reclaim()
1471 spin_lock(&conf->device_lock); in r5c_do_reclaim()
1484 r5c_flush_stripe(conf, sh); in r5c_do_reclaim()
1489 spin_unlock(&conf->device_lock); in r5c_do_reclaim()
1493 if (!test_bit(R5C_LOG_CRITICAL, &conf->cache_state)) in r5c_do_reclaim()
1496 md_wakeup_thread(conf->mddev->thread); in r5c_do_reclaim()
1501 struct r5conf *conf = log->rdev->mddev->private; in r5l_do_reclaim() local
1530 next_checkpoint = r5c_calculate_new_cp(conf); in r5l_do_reclaim()
1554 struct r5conf *conf = mddev->private; in r5l_reclaim_thread() local
1555 struct r5l_log *log = conf->log; in r5l_reclaim_thread()
1559 r5c_do_reclaim(conf); in r5l_reclaim_thread()
1593 bool r5l_log_disk_error(struct r5conf *conf) in r5l_log_disk_error() argument
1599 log = rcu_dereference(conf->log); in r5l_log_disk_error()
1602 ret = test_bit(MD_HAS_JOURNAL, &conf->mddev->flags); in r5l_log_disk_error()
1819 struct r5conf *conf = mddev->private; in r5l_recovery_load_data() local
1822 raid5_compute_sector(conf, in r5l_recovery_load_data()
1841 struct r5conf *conf = mddev->private; in r5l_recovery_load_parity() local
1843 ctx->meta_total_blocks += BLOCK_SECTORS * conf->max_degraded; in r5l_recovery_load_parity()
1871 r5l_recovery_replay_one_stripe(struct r5conf *conf, in r5l_recovery_replay_one_stripe() argument
1901 rdev = rcu_dereference(conf->disks[disk_index].rdev); in r5l_recovery_replay_one_stripe()
1911 rrdev = rcu_dereference(conf->disks[disk_index].replacement); in r5l_recovery_replay_one_stripe()
1930 struct r5conf *conf, in r5c_recovery_alloc_stripe() argument
1936 sh = raid5_get_active_stripe(conf, stripe_sect, 0, noblock, 0); in r5c_recovery_alloc_stripe()
2009 struct r5conf *conf = mddev->private; in r5l_recovery_verify_data_checksum_for_mb() local
2035 if (conf->max_degraded == 2 && /* q for RAID 6 */ in r5l_recovery_verify_data_checksum_for_mb()
2083 struct r5conf *conf = mddev->private; in r5c_recovery_analyze_meta_block() local
2138 conf, le64_to_cpu(payload->location), 0, &dd, in r5c_recovery_analyze_meta_block()
2146 sh = r5c_recovery_alloc_stripe(conf, stripe_sect, 1); in r5c_recovery_analyze_meta_block()
2155 conf, stripe_sect, 1); in r5c_recovery_analyze_meta_block()
2158 int new_size = conf->min_nr_stripes * 2; in r5c_recovery_analyze_meta_block()
2163 if (conf->min_nr_stripes <= new_size / 2) { in r5c_recovery_analyze_meta_block()
2168 conf->min_nr_stripes, in r5c_recovery_analyze_meta_block()
2169 conf->max_nr_stripes); in r5c_recovery_analyze_meta_block()
2173 conf, stripe_sect, 0); in r5c_recovery_analyze_meta_block()
2186 r5l_recovery_replay_one_stripe(conf, sh, ctx); in r5c_recovery_analyze_meta_block()
2431 struct r5conf *conf = mddev->private; in r5c_recovery_flush_data_only_stripes() local
2447 wait_event(conf->wait_for_quiescent, in r5c_recovery_flush_data_only_stripes()
2448 atomic_read(&conf->active_stripes) == 0); in r5c_recovery_flush_data_only_stripes()
2532 struct r5conf *conf; in r5c_journal_mode_show() local
2539 conf = mddev->private; in r5c_journal_mode_show()
2540 if (!conf || !conf->log) { in r5c_journal_mode_show()
2545 switch (conf->log->r5c_journal_mode) { in r5c_journal_mode_show()
2573 struct r5conf *conf; in r5c_journal_mode_set() local
2579 conf = mddev->private; in r5c_journal_mode_set()
2580 if (!conf || !conf->log) in r5c_journal_mode_set()
2583 if (raid5_calc_degraded(conf) > 0 && in r5c_journal_mode_set()
2588 conf->log->r5c_journal_mode = mode; in r5c_journal_mode_set()
2634 int r5c_try_caching_write(struct r5conf *conf, in r5c_try_caching_write() argument
2639 struct r5l_log *log = conf->log; in r5c_try_caching_write()
2697 tree_index = r5c_tree_index(conf, sh->sector); in r5c_try_caching_write()
2729 atomic_inc(&conf->r5c_cached_partial_stripes); in r5c_try_caching_write()
2760 struct r5conf *conf = sh->raid_conf; in r5c_release_extra_page() local
2765 sh->dev[0].orig_page == conf->disks[0].extra_page; in r5c_release_extra_page()
2779 clear_bit(R5C_EXTRA_PAGE_IN_USE, &conf->cache_state); in r5c_release_extra_page()
2780 md_wakeup_thread(conf->mddev->thread); in r5c_release_extra_page()
2786 struct r5conf *conf = sh->raid_conf; in r5c_use_extra_page() local
2794 dev->orig_page = conf->disks[i].extra_page; in r5c_use_extra_page()
2802 void r5c_finish_stripe_write_out(struct r5conf *conf, in r5c_finish_stripe_write_out() argument
2806 struct r5l_log *log = conf->log; in r5c_finish_stripe_write_out()
2835 if (atomic_dec_and_test(&conf->pending_full_writes)) in r5c_finish_stripe_write_out()
2836 md_wakeup_thread(conf->mddev->thread); in r5c_finish_stripe_write_out()
2839 wake_up(&conf->wait_for_overlap); in r5c_finish_stripe_write_out()
2852 tree_index = r5c_tree_index(conf, sh->sector); in r5c_finish_stripe_write_out()
2870 BUG_ON(atomic_read(&conf->r5c_cached_partial_stripes) == 0); in r5c_finish_stripe_write_out()
2871 atomic_dec(&conf->r5c_flushing_partial_stripes); in r5c_finish_stripe_write_out()
2872 atomic_dec(&conf->r5c_cached_partial_stripes); in r5c_finish_stripe_write_out()
2876 BUG_ON(atomic_read(&conf->r5c_cached_full_stripes) == 0); in r5c_finish_stripe_write_out()
2877 atomic_dec(&conf->r5c_flushing_full_stripes); in r5c_finish_stripe_write_out()
2878 atomic_dec(&conf->r5c_cached_full_stripes); in r5c_finish_stripe_write_out()
2889 struct r5conf *conf = sh->raid_conf; in r5c_cache_data() local
2921 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) && in r5c_cache_data()
2943 bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect) in r5c_big_stripe_cached() argument
2945 struct r5l_log *log = conf->log; in r5c_big_stripe_cached()
2953 tree_index = r5c_tree_index(conf, sect); in r5c_big_stripe_cached()
3043 struct r5conf *conf = mddev->private; in r5l_start() local
3045 r5l_exit_log(conf); in r5l_start()
3052 struct r5conf *conf = mddev->private; in r5c_update_on_rdev_error() local
3053 struct r5l_log *log = conf->log; in r5c_update_on_rdev_error()
3058 if ((raid5_calc_degraded(conf) > 0 || in r5c_update_on_rdev_error()
3060 conf->log->r5c_journal_mode == R5C_JOURNAL_MODE_WRITE_BACK) in r5c_update_on_rdev_error()
3064 int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) in r5l_init_log() argument
3072 mdname(conf->mddev), bdevname(rdev->bdev, b)); in r5l_init_log()
3086 conf->raid_disks) > PAGE_SIZE) { in r5l_init_log()
3088 mdname(conf->mddev), conf->raid_disks); in r5l_init_log()
3151 rcu_assign_pointer(conf->log, log); in r5l_init_log()
3153 set_bit(MD_HAS_JOURNAL, &conf->mddev->flags); in r5l_init_log()
3169 void r5l_exit_log(struct r5conf *conf) in r5l_exit_log() argument
3171 struct r5l_log *log = conf->log; in r5l_exit_log()
3173 conf->log = NULL; in r5l_exit_log()
3177 wake_up(&conf->mddev->sb_wait); in r5l_exit_log()