drbd: Fixes to the new delay_probes code
authorPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 6 May 2010 13:19:30 +0000 (15:19 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 17 May 2010 23:28:08 +0000 (01:28 +0200)
* Only send delay_probes with protocol 93 or newer
* drbd_send_delay_probes() is called only from worker context,
  no atomic_t needed for delay_seq

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_proc.c

index 37380d2c869de516da6edc084838c2e82bd3a545..45d9a4534c4058451bc9094e45cf9c753dfde860 100644 (file)
@@ -552,7 +552,7 @@ struct p_delay_probe {
 
 struct delay_probe {
        struct list_head list;
-       int seq_num;
+       unsigned int seq_num;
        struct timeval time;
 };
 
@@ -1048,9 +1048,9 @@ struct drbd_conf {
        char congestion_reason;  /* Why we where congested... */
        struct list_head delay_probes; /* protected by peer_seq_lock */
        int data_delay;   /* Delay of packets on the data-sock behind meta-sock */
-       atomic_t delay_seq; /* To generate sequence numbers of delay probes */
+       unsigned int delay_seq; /* To generate sequence numbers of delay probes */
        struct timeval dps_time; /* delay-probes-start-time */
-       int dp_volume_last;  /* send_cnt of last delay probe */
+       unsigned int dp_volume_last;  /* send_cnt of last delay probe */
        int c_sync_rate; /* current resync rate after delay_probe magic */
 };
 
index 44cc7b415ed4e8f4ecec1010bfb2a38c1f8c5f12..3aa0add1c2304128b511c2c6a3e8c1afd34be8be 100644 (file)
@@ -2199,7 +2199,7 @@ static int drbd_send_delay_probe(struct drbd_conf *mdev, struct drbd_socket *ds)
                do_gettimeofday(&now);
                offset = now.tv_usec - mdev->dps_time.tv_usec +
                         (now.tv_sec - mdev->dps_time.tv_sec) * 1000000;
-               dp.seq_num  = cpu_to_be32(atomic_read(&mdev->delay_seq));
+               dp.seq_num  = cpu_to_be32(mdev->delay_seq);
                dp.offset   = cpu_to_be32(offset);
 
                ok = _drbd_send_cmd(mdev, ds->socket, P_DELAY_PROBE,
@@ -2213,7 +2213,8 @@ static int drbd_send_delay_probe(struct drbd_conf *mdev, struct drbd_socket *ds)
 static int drbd_send_delay_probes(struct drbd_conf *mdev)
 {
        int ok;
-       atomic_inc(&mdev->delay_seq);
+
+       mdev->delay_seq++;
        do_gettimeofday(&mdev->dps_time);
        ok = drbd_send_delay_probe(mdev, &mdev->meta);
        ok = ok && drbd_send_delay_probe(mdev, &mdev->data);
@@ -2355,7 +2356,7 @@ static int _drbd_send_zc_bio(struct drbd_conf *mdev, struct bio *bio)
 
 static void consider_delay_probes(struct drbd_conf *mdev)
 {
-       if (mdev->state.conn != C_SYNC_SOURCE)
+       if (mdev->state.conn != C_SYNC_SOURCE || mdev->agreed_pro_version < 93)
                return;
 
        if (mdev->dp_volume_last + mdev->sync_conf.dp_volume * 2 < mdev->send_cnt)
@@ -2677,7 +2678,6 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
        atomic_set(&mdev->net_cnt, 0);
        atomic_set(&mdev->packet_seq, 0);
        atomic_set(&mdev->pp_in_use, 0);
-       atomic_set(&mdev->delay_seq, 0);
 
        mutex_init(&mdev->md_io_mutex);
        mutex_init(&mdev->data.mutex);
index 81dea0a8593365c8005629587e8b2013c997ff16..d0f1767ea4c30d95bd33d48cfbffbf87c4db14fe 100644 (file)
@@ -86,8 +86,7 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
                           mdev->data_delay / 1000,
                           (mdev->data_delay % 1000) / 100);
        else if (mdev->state.conn == C_SYNC_SOURCE)
-               seq_printf(seq, " delay_probe: %d\n\t",
-                          atomic_read(&mdev->delay_seq));
+               seq_printf(seq, " delay_probe: %u\n\t", mdev->delay_seq);
 
        /* see drivers/md/md.c
         * We do not want to overflow, so the order of operands and