aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2010-05-04 06:33:58 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2010-05-17 19:25:28 -0400
commitbd26bfc5b4253425d17aa49648ae1f3e976041c4 (patch)
treef4e052f417333ad045772f2aff52c56e8401ce60 /drivers/block/drbd
parent67c7ddd055c794f0d8e9466ca2d6b5cc0b73d4df (diff)
drbd: Actually send delay probes
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd')
-rw-r--r--drivers/block/drbd/drbd_int.h6
-rw-r--r--drivers/block/drbd/drbd_main.c43
2 files changed, 47 insertions, 2 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 3e4d8b574fef..210870ed8a79 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -925,9 +925,11 @@ struct drbd_conf {
925 unsigned int ko_count; 925 unsigned int ko_count;
926 struct drbd_work resync_work, 926 struct drbd_work resync_work,
927 unplug_work, 927 unplug_work,
928 md_sync_work; 928 md_sync_work,
929 delay_probe_work;
929 struct timer_list resync_timer; 930 struct timer_list resync_timer;
930 struct timer_list md_sync_timer; 931 struct timer_list md_sync_timer;
932 struct timer_list delay_probe_timer;
931 933
932 /* Used after attach while negotiating new disk state. */ 934 /* Used after attach while negotiating new disk state. */
933 union drbd_state new_state_tmp; 935 union drbd_state new_state_tmp;
@@ -1047,6 +1049,8 @@ struct drbd_conf {
1047 int data_delay; /* Delay of packets on the data-sock behind meta-sock */ 1049 int data_delay; /* Delay of packets on the data-sock behind meta-sock */
1048 atomic_t delay_seq; /* To generate sequence numbers of delay probes */ 1050 atomic_t delay_seq; /* To generate sequence numbers of delay probes */
1049 struct timeval dps_time; /* delay-probes-start-time */ 1051 struct timeval dps_time; /* delay-probes-start-time */
1052 int dp_volume_last; /* send_cnt of last delay probe */
1053 int c_sync_rate; /* current resync rate after delay_probe magic */
1050}; 1054};
1051 1055
1052static inline struct drbd_conf *minor_to_mdev(unsigned int minor) 1056static inline struct drbd_conf *minor_to_mdev(unsigned int minor)
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 710bfebb7b63..98785d08cf70 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2207,10 +2207,13 @@ static int drbd_send_delay_probe(struct drbd_conf *mdev, struct drbd_socket *ds)
2207 } 2207 }
2208 mutex_unlock(&ds->mutex); 2208 mutex_unlock(&ds->mutex);
2209 2209
2210 mdev->dp_volume_last = mdev->send_cnt;
2211 mod_timer(&mdev->delay_probe_timer, jiffies + mdev->sync_conf.dp_interval * HZ / 10);
2212
2210 return ok; 2213 return ok;
2211} 2214}
2212 2215
2213static int drbd_send_dalay_probes(struct drbd_conf *mdev) 2216static int drbd_send_delay_probes(struct drbd_conf *mdev)
2214{ 2217{
2215 int ok; 2218 int ok;
2216 atomic_inc(&mdev->delay_seq); 2219 atomic_inc(&mdev->delay_seq);
@@ -2350,6 +2353,30 @@ static int _drbd_send_zc_bio(struct drbd_conf *mdev, struct bio *bio)
2350 return 1; 2353 return 1;
2351} 2354}
2352 2355
2356static void consider_delay_probes(struct drbd_conf *mdev)
2357{
2358 if (mdev->state.conn != C_SYNC_SOURCE)
2359 return;
2360
2361 if (mdev->dp_volume_last + mdev->sync_conf.dp_volume * 2 < mdev->send_cnt)
2362 drbd_send_delay_probes(mdev);
2363}
2364
2365static int w_delay_probes(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
2366{
2367 if (!cancel && mdev->state.conn == C_SYNC_SOURCE)
2368 drbd_send_delay_probes(mdev);
2369
2370 return 1;
2371}
2372
2373static void delay_probe_timer_fn(unsigned long data)
2374{
2375 struct drbd_conf *mdev = (struct drbd_conf *) data;
2376
2377 drbd_queue_work(&mdev->data.work, &mdev->delay_probe_work);
2378}
2379
2353/* Used to send write requests 2380/* Used to send write requests
2354 * R_PRIMARY -> Peer (P_DATA) 2381 * R_PRIMARY -> Peer (P_DATA)
2355 */ 2382 */
@@ -2412,6 +2439,10 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
2412 } 2439 }
2413 2440
2414 drbd_put_data_sock(mdev); 2441 drbd_put_data_sock(mdev);
2442
2443 if (ok)
2444 consider_delay_probes(mdev);
2445
2415 return ok; 2446 return ok;
2416} 2447}
2417 2448
@@ -2457,6 +2488,10 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd,
2457 ok = _drbd_send_zc_bio(mdev, e->private_bio); 2488 ok = _drbd_send_zc_bio(mdev, e->private_bio);
2458 2489
2459 drbd_put_data_sock(mdev); 2490 drbd_put_data_sock(mdev);
2491
2492 if (ok)
2493 consider_delay_probes(mdev);
2494
2460 return ok; 2495 return ok;
2461} 2496}
2462 2497
@@ -2671,17 +2706,23 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
2671 INIT_LIST_HEAD(&mdev->md_sync_work.list); 2706 INIT_LIST_HEAD(&mdev->md_sync_work.list);
2672 INIT_LIST_HEAD(&mdev->bm_io_work.w.list); 2707 INIT_LIST_HEAD(&mdev->bm_io_work.w.list);
2673 INIT_LIST_HEAD(&mdev->delay_probes); 2708 INIT_LIST_HEAD(&mdev->delay_probes);
2709 INIT_LIST_HEAD(&mdev->delay_probe_work.list);
2674 2710
2675 mdev->resync_work.cb = w_resync_inactive; 2711 mdev->resync_work.cb = w_resync_inactive;
2676 mdev->unplug_work.cb = w_send_write_hint; 2712 mdev->unplug_work.cb = w_send_write_hint;
2677 mdev->md_sync_work.cb = w_md_sync; 2713 mdev->md_sync_work.cb = w_md_sync;
2678 mdev->bm_io_work.w.cb = w_bitmap_io; 2714 mdev->bm_io_work.w.cb = w_bitmap_io;
2715 mdev->delay_probe_work.cb = w_delay_probes;
2679 init_timer(&mdev->resync_timer); 2716 init_timer(&mdev->resync_timer);
2680 init_timer(&mdev->md_sync_timer); 2717 init_timer(&mdev->md_sync_timer);
2718 init_timer(&mdev->delay_probe_timer);
2681 mdev->resync_timer.function = resync_timer_fn; 2719 mdev->resync_timer.function = resync_timer_fn;
2682 mdev->resync_timer.data = (unsigned long) mdev; 2720 mdev->resync_timer.data = (unsigned long) mdev;
2683 mdev->md_sync_timer.function = md_sync_timer_fn; 2721 mdev->md_sync_timer.function = md_sync_timer_fn;
2684 mdev->md_sync_timer.data = (unsigned long) mdev; 2722 mdev->md_sync_timer.data = (unsigned long) mdev;
2723 mdev->delay_probe_timer.function = delay_probe_timer_fn;
2724 mdev->delay_probe_timer.data = (unsigned long) mdev;
2725
2685 2726
2686 init_waitqueue_head(&mdev->misc_wait); 2727 init_waitqueue_head(&mdev->misc_wait);
2687 init_waitqueue_head(&mdev->state_wait); 2728 init_waitqueue_head(&mdev->state_wait);