Lines Matching defs:conf
39 #define R5C_FULL_STRIPE_FLUSH_BATCH(conf) (conf->max_nr_stripes / 4)
195 static inline sector_t r5c_tree_index(struct r5conf *conf,
198 sector_div(sect, conf->chunk_sectors);
292 r5c_return_dev_pending_writes(struct r5conf *conf, struct r5dev *dev)
299 dev->sector + RAID5_STRIPE_SECTORS(conf)) {
300 wbi2 = r5_next_bio(conf, wbi, dev->sector);
301 md_write_end(conf->mddev);
307 void r5c_handle_cached_data_endio(struct r5conf *conf,
315 r5c_return_dev_pending_writes(conf, &sh->dev[i]);
316 md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
317 RAID5_STRIPE_SECTORS(conf),
327 void r5c_check_stripe_cache_usage(struct r5conf *conf)
331 if (!r5c_is_writeback(conf->log))
334 total_cached = atomic_read(&conf->r5c_cached_partial_stripes) +
335 atomic_read(&conf->r5c_cached_full_stripes);
345 if (total_cached > conf->min_nr_stripes * 1 / 2 ||
346 atomic_read(&conf->empty_inactive_list_nr) > 0)
347 r5l_wake_reclaim(conf->log, 0);
354 void r5c_check_cached_full_stripe(struct r5conf *conf)
356 if (!r5c_is_writeback(conf->log))
363 if (atomic_read(&conf->r5c_cached_full_stripes) >=
364 min(R5C_FULL_STRIPE_FLUSH_BATCH(conf),
365 conf->chunk_sectors >> RAID5_STRIPE_SHIFT(conf)))
366 r5l_wake_reclaim(conf->log, 0);
385 * already passed 1, flushing it requires at most (conf->max_degraded + 1)
387 * requires (conf->raid_disks + 1) pages of journal space. There are at
388 * most (conf->group_cnt + 1) stripe that passed 1. So total journal space
397 static sector_t r5c_log_required_to_flush_cache(struct r5conf *conf)
399 struct r5l_log *log = conf->log;
405 ((conf->max_degraded + 1) * atomic_read(&log->stripe_in_journal_count) +
406 (conf->raid_disks - conf->max_degraded) * (conf->group_cnt + 1));
418 struct r5conf *conf = log->rdev->mddev->private;
428 reclaim_space = r5c_log_required_to_flush_cache(conf);
430 set_bit(R5C_LOG_CRITICAL, &conf->cache_state);
432 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state))
434 clear_bit(R5C_LOG_CRITICAL, &conf->cache_state);
437 set_bit(R5C_LOG_TIGHT, &conf->cache_state);
439 clear_bit(R5C_LOG_TIGHT, &conf->cache_state);
451 struct r5conf *conf = sh->raid_conf;
452 struct r5l_log *log = conf->log;
460 atomic_inc(&conf->preread_active_stripes);
685 struct r5conf *conf = mddev->private;
695 conf->log == NULL ||
865 struct r5conf *conf = mddev->private;
875 if (conf->quiesce)
994 struct r5conf *conf = sh->raid_conf;
1063 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) &&
1152 static sector_t r5c_calculate_new_cp(struct r5conf *conf)
1155 struct r5l_log *log = conf->log;
1163 if (list_empty(&conf->log->stripe_in_journal_list)) {
1168 sh = list_first_entry(&conf->log->stripe_in_journal_list,
1177 struct r5conf *conf = log->rdev->mddev->private;
1180 r5c_calculate_new_cp(conf));
1225 struct r5conf *conf = log->rdev->mddev->private;
1237 test_bit(R5C_LOG_TIGHT, &conf->cache_state))
1362 * must hold conf->device_lock
1364 static void r5c_flush_stripe(struct r5conf *conf, struct stripe_head *sh)
1372 * raid5_release_stripe() while holding conf->device_lock
1375 lockdep_assert_held(&conf->device_lock);
1381 atomic_inc(&conf->active_stripes);
1385 atomic_inc(&conf->r5c_flushing_partial_stripes);
1387 atomic_inc(&conf->r5c_flushing_full_stripes);
1397 void r5c_flush_cache(struct r5conf *conf, int num)
1402 lockdep_assert_held(&conf->device_lock);
1403 if (!conf->log)
1407 list_for_each_entry_safe(sh, next, &conf->r5c_full_stripe_list, lru) {
1408 r5c_flush_stripe(conf, sh);
1415 &conf->r5c_partial_stripe_list, lru) {
1416 r5c_flush_stripe(conf, sh);
1422 static void r5c_do_reclaim(struct r5conf *conf)
1424 struct r5l_log *log = conf->log;
1435 flushing_partial = atomic_read(&conf->r5c_flushing_partial_stripes);
1436 flushing_full = atomic_read(&conf->r5c_flushing_full_stripes);
1437 total_cached = atomic_read(&conf->r5c_cached_partial_stripes) +
1438 atomic_read(&conf->r5c_cached_full_stripes) -
1441 if (total_cached > conf->min_nr_stripes * 3 / 4 ||
1442 atomic_read(&conf->empty_inactive_list_nr) > 0)
1448 else if (total_cached > conf->min_nr_stripes * 1 / 2 ||
1449 atomic_read(&conf->r5c_cached_full_stripes) - flushing_full >
1450 R5C_FULL_STRIPE_FLUSH_BATCH(conf))
1461 spin_lock_irqsave(&conf->device_lock, flags);
1462 r5c_flush_cache(conf, stripes_to_flush);
1463 spin_unlock_irqrestore(&conf->device_lock, flags);
1467 if (test_bit(R5C_LOG_TIGHT, &conf->cache_state)) {
1469 spin_lock(&conf->device_lock);
1482 r5c_flush_stripe(conf, sh);
1487 spin_unlock(&conf->device_lock);
1491 if (!test_bit(R5C_LOG_CRITICAL, &conf->cache_state))
1494 md_wakeup_thread(conf->mddev->thread);
1499 struct r5conf *conf = log->rdev->mddev->private;
1528 next_checkpoint = r5c_calculate_new_cp(conf);
1552 struct r5conf *conf = mddev->private;
1553 struct r5l_log *log = conf->log;
1557 r5c_do_reclaim(conf);
1591 bool r5l_log_disk_error(struct r5conf *conf)
1597 log = rcu_dereference(conf->log);
1600 ret = test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
1817 struct r5conf *conf = mddev->private;
1820 raid5_compute_sector(conf,
1839 struct r5conf *conf = mddev->private;
1841 ctx->meta_total_blocks += BLOCK_SECTORS * conf->max_degraded;
1869 r5l_recovery_replay_one_stripe(struct r5conf *conf,
1899 rdev = rcu_dereference(conf->disks[disk_index].rdev);
1909 rrdev = rcu_dereference(conf->disks[disk_index].replacement);
1928 struct r5conf *conf,
1934 sh = raid5_get_active_stripe(conf, stripe_sect, 0, noblock, 0);
2007 struct r5conf *conf = mddev->private;
2033 if (conf->max_degraded == 2 && /* q for RAID 6 */
2081 struct r5conf *conf = mddev->private;
2136 conf, le64_to_cpu(payload->location), 0, &dd,
2144 sh = r5c_recovery_alloc_stripe(conf, stripe_sect, 1);
2153 conf, stripe_sect, 1);
2156 int new_size = conf->min_nr_stripes * 2;
2161 if (conf->min_nr_stripes <= new_size / 2) {
2166 conf->min_nr_stripes,
2167 conf->max_nr_stripes);
2171 conf, stripe_sect, 0);
2184 r5l_recovery_replay_one_stripe(conf, sh, ctx);
2429 struct r5conf *conf = mddev->private;
2449 /* reuse conf->wait_for_quiescent in recovery */
2450 wait_event(conf->wait_for_quiescent,
2451 atomic_read(&conf->active_stripes) == 0);
2537 struct r5conf *conf;
2541 conf = mddev->private;
2542 if (!conf || !conf->log) {
2547 switch (conf->log->r5c_journal_mode) {
2575 struct r5conf *conf;
2581 conf = mddev->private;
2582 if (!conf || !conf->log)
2585 if (raid5_calc_degraded(conf) > 0 &&
2590 conf->log->r5c_journal_mode = mode;
2636 int r5c_try_caching_write(struct r5conf *conf,
2641 struct r5l_log *log = conf->log;
2699 tree_index = r5c_tree_index(conf, sh->sector);
2731 atomic_inc(&conf->r5c_cached_partial_stripes);
2762 struct r5conf *conf = sh->raid_conf;
2767 sh->dev[0].orig_page == conf->disks[0].extra_page;
2781 clear_bit(R5C_EXTRA_PAGE_IN_USE, &conf->cache_state);
2782 md_wakeup_thread(conf->mddev->thread);
2788 struct r5conf *conf = sh->raid_conf;
2796 dev->orig_page = conf->disks[i].extra_page;
2804 void r5c_finish_stripe_write_out(struct r5conf *conf,
2808 struct r5l_log *log = conf->log;
2837 if (atomic_dec_and_test(&conf->pending_full_writes))
2838 md_wakeup_thread(conf->mddev->thread);
2841 wake_up(&conf->wait_for_overlap);
2854 tree_index = r5c_tree_index(conf, sh->sector);
2872 BUG_ON(atomic_read(&conf->r5c_cached_partial_stripes) == 0);
2873 atomic_dec(&conf->r5c_flushing_partial_stripes);
2874 atomic_dec(&conf->r5c_cached_partial_stripes);
2878 BUG_ON(atomic_read(&conf->r5c_cached_full_stripes) == 0);
2879 atomic_dec(&conf->r5c_flushing_full_stripes);
2880 atomic_dec(&conf->r5c_cached_full_stripes);
2891 struct r5conf *conf = sh->raid_conf;
2923 if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) &&
2945 bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect)
2947 struct r5l_log *log = conf->log;
2955 tree_index = r5c_tree_index(conf, sect);
3045 struct r5conf *conf = mddev->private;
3047 r5l_exit_log(conf);
3054 struct r5conf *conf = mddev->private;
3055 struct r5l_log *log = conf->log;
3060 if ((raid5_calc_degraded(conf) > 0 ||
3062 conf->log->r5c_journal_mode == R5C_JOURNAL_MODE_WRITE_BACK)
3066 int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
3074 mdname(conf->mddev), bdevname(rdev->bdev, b));
3088 conf->raid_disks) > PAGE_SIZE) {
3090 mdname(conf->mddev), conf->raid_disks);
3153 rcu_assign_pointer(conf->log, log);
3155 set_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
3171 void r5l_exit_log(struct r5conf *conf)
3173 struct r5l_log *log = conf->log;
3175 conf->log = NULL;
3179 wake_up(&conf->mddev->sb_wait);