From 913dcd6d6c5f6796081ce50e333624e8fb8df5b7 Mon Sep 17 00:00:00 2001
From: Lars Ellenberg <lars.ellenberg@linbit.com>
Date: Tue, 15 May 2018 17:38:02 +0200
Subject: [PATCH] drbd: rename tl_clear, tl_restart to tl_walk

tl_clear was an obfuscation wrapper around tl_restart,
and nowadays both do neither clear nor restart,
but actually "just" walk the transfer log.

No functional change.
---
 drbd/drbd_int.h      |  1 -
 drbd/drbd_main.c     | 26 ++++++--------------------
 drbd/drbd_nl.c       |  8 +++-----
 drbd/drbd_receiver.c |  4 ++--
 drbd/drbd_req.c      |  5 +++--
 drbd/drbd_req.h      |  4 ++--
 drbd/drbd_state.c    |  4 ++--
 7 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h
index 6cc41254..9f543585 100644
--- a/drbd/drbd_int.h
+++ b/drbd/drbd_int.h
@@ -1442,7 +1442,6 @@ extern void drbd_thread_current_set_cpu(struct drbd_thread *thi);
 #endif
 extern void tl_release(struct drbd_connection *, unsigned int barrier_nr,
 		       unsigned int set_size);
-extern void tl_clear(struct drbd_connection *);
 extern void drbd_free_sock(struct drbd_connection *connection);
 
 extern int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cmd);
diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c
index 300b6848..14fdd017 100644
--- a/drbd/drbd_main.c
+++ b/drbd/drbd_main.c
@@ -58,7 +58,7 @@
 #include <linux/drbd_limits.h>
 #include "drbd_int.h"
 #include "drbd_protocol.h"
-#include "drbd_req.h" /* only for _req_mod in tl_release and tl_clear */
+#include "drbd_req.h" /* only for _req_mod in tl_release */
 #include "drbd_vli.h"
 #include "drbd_debugfs.h"
 #include "drbd_meta_data.h"
@@ -454,15 +454,15 @@ bail:
 
 
 /**
- * _tl_restart() - Walks the transfer log, and applies an action to all requests
+ * _tl_walk() - Walks the transfer log, and applies an action to all requests
  * @connection:	DRBD connection to operate on.
  * @what:       The action/event to perform with all request objects
  *
  * @what might be one of CONNECTION_LOST_WHILE_PENDING, RESEND, FAIL_FROZEN_DISK_IO,
- * RESTART_FROZEN_DISK_IO.
+ * RESTART_FROZEN_DISK_IO, COMPLETION_RESUMED.
  */
 /* must hold resource->req_lock */
-void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
+void _tl_walk(struct drbd_connection *connection, enum drbd_req_event what)
 {
 	struct drbd_resource *resource = connection->resource;
 	struct drbd_peer_device *peer_device;
@@ -474,30 +474,16 @@ void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
 	}
 }
 
-void tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
+void tl_walk(struct drbd_connection *connection, enum drbd_req_event what)
 {
 	struct drbd_resource *resource = connection->resource;
 
 	del_timer_sync(&resource->peer_ack_timer);
 	spin_lock_irq(&resource->req_lock);
-	_tl_restart(connection, what);
+	_tl_walk(connection, what);
 	spin_unlock_irq(&resource->req_lock);
 }
 
-
-/**
- * tl_clear() - Clears all requests and &struct drbd_tl_epoch objects out of the TL
- * @device:	DRBD device.
- *
- * This is called after the connection to the peer was lost. The storage covered
- * by the requests on the transfer gets marked as our of sync. Called from the
- * receiver thread and the sender thread.
- */
-void tl_clear(struct drbd_connection *connection)
-{
-	tl_restart(connection, CONNECTION_LOST_WHILE_PENDING);
-}
-
 /**
  * tl_abort_disk_io() - Abort disk I/O for all requests for a certain device in the TL
  * @device:     DRBD device.
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
index eb2ee95c..99f09b12 100644
--- a/drbd/drbd_nl.c
+++ b/drbd/drbd_nl.c
@@ -781,7 +781,7 @@ bool conn_try_outdate_peer(struct drbd_connection *connection)
 		 * We may still be suspended due to the on-no-data-accessible policy.
 		 * If that was OND_IO_ERROR, fail pending requests. */
 		if (!resource_is_suspended(resource, NOW))
-			_tl_restart(connection, CONNECTION_LOST_WHILE_PENDING);
+			_tl_walk(connection, CONNECTION_LOST_WHILE_PENDING);
 		end_state_change_locked(resource);
 		spin_unlock_irq(&resource->req_lock);
 		return false;
@@ -4694,8 +4694,6 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
 
 	if (resource->res_opts.on_no_quorum == ONQ_SUSPEND_IO)
 		__change_have_quorum(device, true);
-
-	/* TODO: Throw away queued IO requests... */
 	retcode = end_state_change(resource, &irq_flags);
 	if (retcode == SS_SUCCESS) {
 		struct drbd_peer_device *peer_device;
@@ -4704,11 +4702,11 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
 			struct drbd_connection *connection = peer_device->connection;
 
 			if (peer_device->repl_state[NOW] < L_ESTABLISHED)
-				tl_clear(connection);
+				tl_walk(connection, CONNECTION_LOST_WHILE_PENDING);
 			if (device->disk_state[NOW] == D_DISKLESS ||
 			    device->disk_state[NOW] == D_FAILED ||
 			    device->disk_state[NOW] == D_DETACHING)
-				tl_restart(connection, FAIL_FROZEN_DISK_IO);
+				tl_walk(connection, FAIL_FROZEN_DISK_IO);
 		}
 	}
 	drbd_resume_io(device);
diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
index e7526b02..b6b82a14 100644
--- a/drbd/drbd_receiver.c
+++ b/drbd/drbd_receiver.c
@@ -6645,7 +6645,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info
 		spin_unlock_irq(&resource->req_lock);
 
 		drbd_err(device, "Aborting Connect, can not thaw IO with an only Consistent peer\n");
-		tl_clear(connection);
+		tl_walk(connection, CONNECTION_LOST_WHILE_PENDING);
 		mutex_lock(&resource->conf_update);
 		drbd_uuid_new_current(device, false);
 		mutex_unlock(&resource->conf_update);
@@ -7489,7 +7489,7 @@ static void peer_device_disconnected(struct drbd_peer_device *peer_device)
 			drbd_uuid_new_current(device, false);
 			mutex_unlock(&resource->conf_update);
 		}
-		tl_clear(peer_device->connection);
+		tl_walk(peer_device->connection, CONNECTION_LOST_WHILE_PENDING);
 	}
 
 	drbd_md_sync(device);
diff --git a/drbd/drbd_req.c b/drbd/drbd_req.c
index 91227c14..b19b8591 100644
--- a/drbd/drbd_req.c
+++ b/drbd/drbd_req.c
@@ -972,8 +972,9 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
 	case READ_RETRY_REMOTE_CANCELED:
 	case SEND_CANCELED:
 	case SEND_FAILED:
-		/* real cleanup will be done from tl_clear.  just update flags
-		 * so it is no longer marked as on the sender queue */
+		/* Just update flags so it is no longer marked as on the sender
+		 * queue; real cleanup will be done from
+		 * tl_walk(,CONNECTION_LOST_WHILE_PENDING). */
 		mod_rq_state(req, m, peer_device, RQ_NET_QUEUED, 0);
 		break;
 
diff --git a/drbd/drbd_req.h b/drbd/drbd_req.h
index ffca360a..c4bb0d31 100644
--- a/drbd/drbd_req.h
+++ b/drbd/drbd_req.h
@@ -322,8 +322,8 @@ extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
 extern void complete_master_bio(struct drbd_device *device,
 		struct bio_and_error *m);
 extern void request_timer_fn(DRBD_TIMER_FN_ARG);
-extern void tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
-extern void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
+extern void tl_walk(struct drbd_connection *connection, enum drbd_req_event what);
+extern void _tl_walk(struct drbd_connection *connection, enum drbd_req_event what);
 extern void drbd_queue_peer_ack(struct drbd_resource *resource, struct drbd_request *req);
 extern bool drbd_should_do_remote(struct drbd_peer_device *, enum which_state);
 
diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index ccbc1091..90f380f6 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -2923,7 +2923,7 @@ static void check_may_resume_io_after_fencing(struct drbd_state_change *state_ch
 		}
 		mutex_unlock(&resource->conf_update);
 		begin_state_change(resource, &irq_flags, CS_VERBOSE);
-		_tl_restart(connection, CONNECTION_LOST_WHILE_PENDING);
+		_tl_walk(connection, CONNECTION_LOST_WHILE_PENDING);
 		__change_io_susp_fencing(connection, false);
 		end_state_change(resource, &irq_flags);
 	}
@@ -2936,7 +2936,7 @@ static void check_may_resume_io_after_fencing(struct drbd_state_change *state_ch
 		}
 		rcu_read_unlock();
 		begin_state_change(resource, &irq_flags, CS_VERBOSE);
-		_tl_restart(connection, RESEND);
+		_tl_walk(connection, RESEND);
 		__change_io_susp_fencing(connection, false);
 		end_state_change(resource, &irq_flags);
 	}
-- 
2.34.1

