mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 18/27] drbd: Turn conn_flush_workqueue() into drbd_flush_workqueue()
Date: Mon, 23 Dec 2013 22:50:47 +0100	[thread overview]
Message-ID: <1387835456-29695-19-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1387835456-29695-1-git-send-email-philipp.reisner@linbit.com>

From: Andreas Gruenbacher <agruen@linbit.com>

The new function can flush any work queue, not just the work queue of the data
socket of a connection.

Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
---
 drivers/block/drbd/drbd_int.h      |   12 ++----------
 drivers/block/drbd/drbd_main.c     |   24 ++++++++++++++++++++++++
 drivers/block/drbd/drbd_nl.c       |   10 +++++-----
 drivers/block/drbd/drbd_receiver.c |   22 ++--------------------
 4 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index eb2bc90..7185c98 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -346,11 +346,6 @@ enum epoch_event {
 	EV_CLEANUP = 32, /* used as flag */
 };
 
-struct drbd_wq_barrier {
-	struct drbd_work w;
-	struct completion done;
-};
-
 struct digest_info {
 	int digest_size;
 	void *digest;
@@ -1349,12 +1344,7 @@ extern void __drbd_free_peer_req(struct drbd_device *, struct drbd_peer_request
 extern struct page *drbd_alloc_pages(struct drbd_peer_device *, unsigned int, bool);
 extern void drbd_set_recv_tcq(struct drbd_device *device, int tcq_enabled);
 extern void _drbd_clear_done_ee(struct drbd_device *device, struct list_head *to_be_freed);
-extern void conn_flush_workqueue(struct drbd_connection *connection);
 extern int drbd_connected(struct drbd_peer_device *);
-static inline void drbd_flush_workqueue(struct drbd_device *device)
-{
-	conn_flush_workqueue(first_peer_device(device)->connection);
-}
 
 /* Yes, there is kernel_setsockopt, but only since 2.6.18.
  * So we have our own copy of it here. */
@@ -1709,6 +1699,8 @@ drbd_queue_work(struct drbd_work_queue *q, struct drbd_work *w)
 	wake_up(&q->q_wait);
 }
 
+extern void drbd_flush_workqueue(struct drbd_work_queue *work_queue);
+
 static inline void wake_asender(struct drbd_connection *connection)
 {
 	if (test_bit(SIGNAL_ASENDER, &connection->flags))
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 0500b56..e11f606 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2397,6 +2397,30 @@ static void drbd_init_workqueue(struct drbd_work_queue* wq)
 	init_waitqueue_head(&wq->q_wait);
 }
 
+struct completion_work {
+	struct drbd_work w;
+	struct completion done;
+};
+
+static int w_complete(struct drbd_work *w, int cancel)
+{
+	struct completion_work *completion_work =
+		container_of(w, struct completion_work, w);
+
+	complete(&completion_work->done);
+	return 0;
+}
+
+void drbd_flush_workqueue(struct drbd_work_queue *work_queue)
+{
+	struct completion_work completion_work;
+
+	completion_work.w.cb = w_complete;
+	init_completion(&completion_work.done);
+	drbd_queue_work(work_queue, &completion_work.w);
+	wait_for_completion(&completion_work.done);
+}
+
 struct drbd_resource *drbd_find_resource(const char *name)
 {
 	struct drbd_resource *resource;
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index f613ba9..b202cdb 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1181,7 +1181,7 @@ void drbd_reconsider_max_bio_size(struct drbd_device *device)
 static void conn_reconfig_start(struct drbd_connection *connection)
 {
 	drbd_thread_start(&connection->worker);
-	conn_flush_workqueue(connection);
+	drbd_flush_workqueue(&connection->sender_work);
 }
 
 /* if still unconfigured, stops worker again. */
@@ -1600,7 +1600,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
 	 */
 	wait_event(device->misc_wait, !atomic_read(&device->ap_pending_cnt) || drbd_suspended(device));
 	/* and for any other previously queued work */
-	drbd_flush_workqueue(device);
+	drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
 
 	rv = _drbd_request_state(device, NS(disk, D_ATTACHING), CS_VERBOSE);
 	retcode = rv;  /* FIXME: Type mismatch. */
@@ -2249,7 +2249,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
 
 	((char *)new_net_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0;
 
-	conn_flush_workqueue(connection);
+	drbd_flush_workqueue(&connection->sender_work);
 
 	mutex_lock(&adm_ctx.resource->conf_update);
 	old_net_conf = connection->net_conf;
@@ -2589,7 +2589,7 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info)
 	 * Also wait for it's after_state_ch(). */
 	drbd_suspend_io(device);
 	wait_event(device->misc_wait, !test_bit(BITMAP_IO, &device->flags));
-	drbd_flush_workqueue(device);
+	drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
 
 	/* If we happen to be C_STANDALONE R_SECONDARY, just change to
 	 * D_INCONSISTENT, and set all bits in the bitmap.  Otherwise,
@@ -2655,7 +2655,7 @@ int drbd_adm_invalidate_peer(struct sk_buff *skb, struct genl_info *info)
 	 * Also wait for it's after_state_ch(). */
 	drbd_suspend_io(device);
 	wait_event(device->misc_wait, !test_bit(BITMAP_IO, &device->flags));
-	drbd_flush_workqueue(device);
+	drbd_flush_workqueue(&first_peer_device(device)->connection->sender_work);
 
 	/* If we happen to be C_STANDALONE R_PRIMARY, just set all bits
 	 * in the bitmap.  Otherwise, try to start a resync handshake
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 3c88efa..c99f252 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -4484,24 +4484,6 @@ static void drbdd(struct drbd_connection *connection)
 	conn_request_state(connection, NS(conn, C_PROTOCOL_ERROR), CS_HARD);
 }
 
-static int w_complete(struct drbd_work *w, int cancel)
-{
-	struct drbd_wq_barrier *b = container_of(w, struct drbd_wq_barrier, w);
-
-	complete(&b->done);
-	return 0;
-}
-
-void conn_flush_workqueue(struct drbd_connection *connection)
-{
-	struct drbd_wq_barrier barr;
-
-	barr.w.cb = w_complete;
-	init_completion(&barr.done);
-	drbd_queue_work(&connection->sender_work, &barr.w);
-	wait_for_completion(&barr.done);
-}
-
 static void conn_disconnect(struct drbd_connection *connection)
 {
 	struct drbd_peer_device *peer_device;
@@ -4589,14 +4571,14 @@ static int drbd_disconnected(struct drbd_peer_device *peer_device)
 	/* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier,
 	 * w_make_resync_request etc. which may still be on the worker queue
 	 * to be "canceled" */
-	drbd_flush_workqueue(device);
+	drbd_flush_workqueue(&peer_device->connection->sender_work);
 
 	drbd_finish_peer_reqs(device);
 
 	/* This second workqueue flush is necessary, since drbd_finish_peer_reqs()
 	   might have issued a work again. The one before drbd_finish_peer_reqs() is
 	   necessary to reclain net_ee in drbd_finish_peer_reqs(). */
-	drbd_flush_workqueue(device);
+	drbd_flush_workqueue(&peer_device->connection->sender_work);
 
 	/* need to do it again, drbd_finish_peer_reqs() may have populated it
 	 * again via drbd_try_clear_on_disk_bm(). */
-- 
1.7.9.5


  parent reply	other threads:[~2013-12-23 22:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 21:50 [PATCH 00/27] DRBD code reorganization Philipp Reisner
2013-12-23 21:50 ` [PATCH 01/27] drbd: Rename net_conf variables old_conf -> old_net_conf and new_conf -> new_net_conf Philipp Reisner
2013-12-23 21:50 ` [PATCH 02/27] drbd: Iterate over all connections Philipp Reisner
2013-12-23 21:50 ` [PATCH 03/27] drbd: drbd_adm_prepare(): Only set adm_ctx.connection when a connection is requested Philipp Reisner
2013-12-23 21:50 ` [PATCH 04/27] drbd: Move conf_mutex from connection to resource Philipp Reisner
2013-12-23 21:50 ` [PATCH 05/27] drbd: Move susp, susp_nod, susp_fen " Philipp Reisner
2013-12-23 21:50 ` [PATCH 06/27] drbd: Define the size of res_opts->cpu_mask in a single place Philipp Reisner
2013-12-23 21:50 ` [PATCH 07/27] drbd: Move cpu_mask from connection to resource Philipp Reisner
2013-12-23 21:50 ` [PATCH 08/27] drbd: Rename drbdd_init() -> drbd_receiver() Philipp Reisner
2013-12-23 21:50 ` [PATCH 09/27] drbd: Function prototype cleanups Philipp Reisner
2013-12-23 21:50 ` [PATCH 10/27] drbd: drbd_csum_bio(), drbd_csum_ee(): Remove unused device argument Philipp Reisner
2013-12-23 21:50 ` [PATCH 11/27] drbd: Replace vnr_to_mdev() with conn_peer_device() Philipp Reisner
2013-12-23 21:50 ` [PATCH 12/27] drbd: Pass a peer device to a number of fuctions Philipp Reisner
2013-12-23 21:50 ` [PATCH 13/27] drbd: Kill drbd_task_to_thread_name() Philipp Reisner
2013-12-23 21:50 ` [PATCH 14/27] drbd: Remove useless assertion Philipp Reisner
2013-12-23 21:50 ` [PATCH 15/27] drbd: Move string function prototypes from linux/drbd.h to drbd_string.h Philipp Reisner
2013-12-23 21:50 ` [PATCH 16/27] drbd: Rename w_prev_work_done -> w_complete Philipp Reisner
2013-12-23 21:50 ` [PATCH 17/27] drbd: Create a dedicated struct drbd_device_work Philipp Reisner
2013-12-23 21:50 ` Philipp Reisner [this message]
2013-12-23 21:50 ` [PATCH 19/27] drbd: struct after_conn_state_chg_work: Use drbd_work instead of drbd_device_work Philipp Reisner
2013-12-23 21:50 ` [PATCH 20/27] drbd: struct drbd_peer_request: " Philipp Reisner
2013-12-23 21:50 ` [PATCH 21/27] drbd: Make w_make_resync_request() static Philipp Reisner
2013-12-23 21:50 ` [PATCH 22/27] drbd: Turn w_make_ov_request and make_resync_request into "normal" functions Philipp Reisner
2013-12-23 21:50 ` [PATCH 23/27] drbd: In the worker thread, process drbd_work instead of drbd_device_work items Philipp Reisner
2013-12-23 21:50 ` [PATCH 24/27] drbd: Get rid of first_peer_device() in handle_write_conflicts() Philipp Reisner
2013-12-23 21:50 ` [PATCH 25/27] drbd: Remove unused parameter of wire_flags_to_bio() Philipp Reisner
2013-12-23 21:50 ` [PATCH 26/27] drbd: Use the right peer device Philipp Reisner
2013-12-23 21:50 ` [PATCH 27/27] drbd: Add drbd_thread->resource and make drbd_thread->connection optional Philipp Reisner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387835456-29695-19-git-send-email-philipp.reisner@linbit.com \
    --to=philipp.reisner@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®