drbd: only restart frozen disk io when D_UP_TO_DATE
[cascardo/linux.git] / drivers / block / drbd / drbd_state.c
index 5a7ef78..24422e8 100644 (file)
@@ -1675,7 +1675,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
                        what = RESEND;
 
                if ((os.disk == D_ATTACHING || os.disk == D_NEGOTIATING) &&
-                   conn_lowest_disk(connection) > D_NEGOTIATING)
+                   conn_lowest_disk(connection) == D_UP_TO_DATE)
                        what = RESTART_FROZEN_DISK_IO;
 
                if (resource->susp_nod && what != NOTHING) {
@@ -1934,12 +1934,17 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
 
        /* This triggers bitmap writeout of potentially still unwritten pages
         * if the resync finished cleanly, or aborted because of peer disk
-        * failure, or because of connection loss.
+        * failure, or on transition from resync back to AHEAD/BEHIND.
+        *
+        * Connection loss is handled in drbd_disconnected() by the receiver.
+        *
         * For resync aborted because of local disk failure, we cannot do
         * any bitmap writeout anymore.
+        *
         * No harm done if some bits change during this phase.
         */
-       if (os.conn > C_CONNECTED && ns.conn <= C_CONNECTED && get_ldev(device)) {
+       if ((os.conn > C_CONNECTED && os.conn < C_AHEAD) &&
+           (ns.conn == C_CONNECTED || ns.conn >= C_AHEAD) && get_ldev(device)) {
                drbd_queue_bitmap_io(device, &drbd_bm_write_copy_pages, NULL,
                        "write from resync_finished", BM_LOCKED_CHANGE_ALLOWED);
                put_ldev(device);