From patchwork Thu Sep 28 09:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_B=C3=B6hmwalder?= X-Patchwork-Id: 13402408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFA6ECE7B10 for ; Thu, 28 Sep 2023 09:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbjI1Jjf (ORCPT ); Thu, 28 Sep 2023 05:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbjI1JjV (ORCPT ); Thu, 28 Sep 2023 05:39:21 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979A7195 for ; Thu, 28 Sep 2023 02:39:01 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-32487efc319so385292f8f.1 for ; Thu, 28 Sep 2023 02:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1695893940; x=1696498740; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+Cc+2VEHzN0gMI8y9yXBlUhBR5rjsljwvYfnnw0yDtQ=; b=iKeQoNSH3WGg7Effj8D3FWRIoyQznedJwrhz+EXrZcDekHGkS+muP2ZWjqx2nQtzmR vgBoQRt1sHYc46jF042FBLrC6JLeJkrg8IZd2XDfoxKXnCH5WIP/odBX4Oe65v5B/goI y3895+U8su30ITl86UuSr/yCRIegukQVqRPtS8uny6awnIT9Ie7Kis20LWF/zxjadMWZ 8krQc1ZJRH7BystIJAaLtaZblkrEpN6y67kWCU9UbluvHl08wKLmN/EgIiLkDuNZljSD ZpE7oUtVeEdZspOdWEEfZ6uN7mjRDWPOAtP9PHrl2i6TBKFzEJmsCF7ig+p5qU6ABgsP ZxJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695893940; x=1696498740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Cc+2VEHzN0gMI8y9yXBlUhBR5rjsljwvYfnnw0yDtQ=; b=saTduyEDWvZjGjD2fUr4g/R42nUFSkI2fTpok1qIbFj6P9yWcoBnItxJN4GPFz5jzt p0G6g7w9ibGv8k6iuzZWD6XKR8YAfF3pjx8c9K4jaFNVZJ0wz2d5nnppojUDStMjeTkl SukLPY/gb722+9ku8XuvK1un3Gt0cqavJNeUO1vWAK4DJiM4MsKWos6RTSCK3gRebChX J1a/eu9fOBPeIFqpH/r0nVS5MBS1s5LYdrGHS871buDo1if28Wd5bn+OcRD9LldVs4FO YOgEydpj27lMrxxHHAdZT3bFnKtFA89NEGf9l9Z22G2QkyoFbSPM7OT0rjarsdjrfHRv 9s1Q== X-Gm-Message-State: AOJu0YxyhWE6M7vYnvKLMFEL9Se0GMrNs2veBHTw+UVC31FUhYEGES8Q KRdi0vkWNmJkdXEOxotM09RCKg== X-Google-Smtp-Source: AGHT+IFknNEfUixX3PQogMUw9mOrpiqCWyEZVq5mQjEtWqL1IBLZaQ8qOmr4WiiuSUiiNWsOBK2q/w== X-Received: by 2002:a5d:64c6:0:b0:324:884a:5cd0 with SMTP id f6-20020a5d64c6000000b00324884a5cd0mr905273wri.47.1695893939636; Thu, 28 Sep 2023 02:38:59 -0700 (PDT) Received: from localhost.localdomain (213-225-13-130.nat.highway.a1.net. [213.225.13.130]) by smtp.gmail.com with ESMTPSA id f4-20020a5d50c4000000b0031fa870d4b3sm18931449wrt.60.2023.09.28.02.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:38:59 -0700 (PDT) From: =?utf-8?q?Christoph_B=C3=B6hmwalder?= To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Joel Colledge , =?utf-8?q?Christoph_B=C3=B6hmwalder?= Subject: [PATCH 1/5] drbd: Rename per-connection "worker" thread to "sender" Date: Thu, 28 Sep 2023 11:38:48 +0200 Message-ID: <20230928093852.676786-2-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> References: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Originally-from: Andreas Gruenbacher Reviewed-by: Joel Colledge Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/Makefile | 2 +- drivers/block/drbd/drbd_int.h | 10 +++++----- drivers/block/drbd/drbd_main.c | 16 ++++++++-------- drivers/block/drbd/drbd_nl.c | 16 ++++++++-------- drivers/block/drbd/drbd_req.c | 4 +++- .../drbd/{drbd_worker.c => drbd_sender.c} | 18 +++++++++--------- drivers/block/drbd/drbd_state.c | 10 +++++----- 7 files changed, 39 insertions(+), 37 deletions(-) rename drivers/block/drbd/{drbd_worker.c => drbd_sender.c} (99%) diff --git a/drivers/block/drbd/Makefile b/drivers/block/drbd/Makefile index 67a8b352a1d5..cddece877b25 100644 --- a/drivers/block/drbd/Makefile +++ b/drivers/block/drbd/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only drbd-y := drbd_buildtag.o drbd_bitmap.o drbd_proc.o -drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o +drbd-y += drbd_sender.o drbd_receiver.o drbd_req.o drbd_actlog.o drbd-y += drbd_main.o drbd_strings.o drbd_nl.o drbd-y += drbd_interval.o drbd_state.o drbd-y += drbd_nla.o diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index a30a5ed811be..a53e63af23f1 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -665,7 +665,7 @@ struct drbd_connection { /* empty member on older kernels without blk_start_plug() */ struct blk_plug receiver_plug; struct drbd_thread receiver; - struct drbd_thread worker; + struct drbd_thread sender; struct drbd_thread ack_receiver; struct workqueue_struct *ack_sender; @@ -1075,7 +1075,7 @@ extern int drbd_bitmap_io(struct drbd_device *device, int (*io_fn)(struct drbd_device *, struct drbd_peer_device *), char *why, enum bm_flag flags, struct drbd_peer_device *peer_device); -extern int drbd_bitmap_io_from_worker(struct drbd_device *device, +extern int drbd_bitmap_io_from_sender(struct drbd_device *device, int (*io_fn)(struct drbd_device *, struct drbd_peer_device *), char *why, enum bm_flag flags, struct drbd_peer_device *peer_device); @@ -1422,12 +1422,12 @@ extern void conn_try_outdate_peer_async(struct drbd_connection *connection); extern enum drbd_peer_state conn_khelper(struct drbd_connection *connection, char *cmd); extern int drbd_khelper(struct drbd_device *device, char *cmd); -/* drbd_worker.c */ +/* drbd_sender.c */ /* bi_end_io handlers */ extern void drbd_md_endio(struct bio *bio); extern void drbd_peer_request_endio(struct bio *bio); extern void drbd_request_endio(struct bio *bio); -extern int drbd_worker(struct drbd_thread *thi); +extern int drbd_sender(struct drbd_thread *thi); enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); void drbd_resync_after_changed(struct drbd_device *device); extern void drbd_start_resync(struct drbd_device *device, enum drbd_conns side); @@ -1912,7 +1912,7 @@ static inline void drbd_thread_restart_nowait(struct drbd_thread *thi) * w_send_barrier * _req_mod(req, QUEUE_FOR_NET_WRITE or QUEUE_FOR_NET_READ); * it is much easier and equally valid to count what we queue for the - * worker, even before it actually was queued or send. + * sender, even before it actually was queued or send. * (drbd_make_request_common; recovery path on read io-error) * decreased: * got_BarrierAck (respective tl_clear, tl_clear_barrier) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 6bc86106c7b2..a14c1e9ee327 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -279,7 +279,7 @@ void tl_restart(struct drbd_connection *connection, enum drbd_req_event what) * * 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 worker thread. + * receiver thread and the sender thread. */ void tl_clear(struct drbd_connection *connection) { @@ -2533,7 +2533,7 @@ int set_resource_options(struct drbd_resource *resource, struct res_opts *res_op for_each_connection_rcu(connection, resource) { connection->receiver.reset_cpu_mask = 1; connection->ack_receiver.reset_cpu_mask = 1; - connection->worker.reset_cpu_mask = 1; + connection->sender.reset_cpu_mask = 1; } } err = 0; @@ -2619,8 +2619,8 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) drbd_thread_init(resource, &connection->receiver, drbd_receiver, "receiver"); connection->receiver.connection = connection; - drbd_thread_init(resource, &connection->worker, drbd_worker, "worker"); - connection->worker.connection = connection; + drbd_thread_init(resource, &connection->sender, drbd_sender, "sender"); + connection->sender.connection = connection; drbd_thread_init(resource, &connection->ack_receiver, drbd_ack_receiver, "ack_recv"); connection->ack_receiver.connection = connection; @@ -3497,7 +3497,7 @@ static int w_bitmap_io(struct drbd_work *w, int unused) * * While IO on the bitmap happens we freeze application IO thus we ensure * that drbd_set_out_of_sync() can not be called. This function MAY ONLY be - * called from worker context. It MUST NOT be used while a previous such + * called from sender context. It MUST NOT be used while a previous such * work is still pending! * * Its worker function encloses the call of io_fn() by get_ldev() and @@ -3509,7 +3509,7 @@ void drbd_queue_bitmap_io(struct drbd_device *device, char *why, enum bm_flag flags, struct drbd_peer_device *peer_device) { - D_ASSERT(device, current == peer_device->connection->worker.task); + D_ASSERT(device, current == peer_device->connection->sender.task); D_ASSERT(device, !test_bit(BITMAP_IO_QUEUED, &device->flags)); D_ASSERT(device, !test_bit(BITMAP_IO, &device->flags)); @@ -3544,7 +3544,7 @@ void drbd_queue_bitmap_io(struct drbd_device *device, * @flags: Bitmap flags * * freezes application IO while that the actual IO operations runs. This - * functions MAY NOT be called from worker context. + * functions MAY NOT be called from sender context. */ int drbd_bitmap_io(struct drbd_device *device, int (*io_fn)(struct drbd_device *, struct drbd_peer_device *), @@ -3555,7 +3555,7 @@ int drbd_bitmap_io(struct drbd_device *device, const bool do_suspend_io = flags & (BM_DONT_CLEAR|BM_DONT_SET|BM_DONT_TEST); int rv; - D_ASSERT(device, current != first_peer_device(device)->connection->worker.task); + D_ASSERT(device, current != first_peer_device(device)->connection->sender.task); if (do_suspend_io) drbd_suspend_io(device); diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index d3538bd83fb3..a5844819d1c3 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -365,7 +365,7 @@ int drbd_khelper(struct drbd_device *device, char *cmd) struct sib_info sib; int ret; - if (current == connection->worker.task) + if (current == connection->sender.task) set_bit(CALLBACK_PENDING, &connection->flags); snprintf(mb, 14, "minor-%d", device_to_minor(device)); @@ -394,7 +394,7 @@ int drbd_khelper(struct drbd_device *device, char *cmd) drbd_bcast_event(device, &sib); notify_helper(NOTIFY_RESPONSE, device, connection, cmd, ret); - if (current == connection->worker.task) + if (current == connection->sender.task) clear_bit(CALLBACK_PENDING, &connection->flags); if (ret < 0) /* Ignore any ERRNOs we got. */ @@ -1349,14 +1349,14 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_ba drbd_setup_queue_param(device, bdev, new, o); } -/* Starts the worker thread */ +/* Starts the sender thread */ static void conn_reconfig_start(struct drbd_connection *connection) { - drbd_thread_start(&connection->worker); + drbd_thread_start(&connection->sender); drbd_flush_workqueue(&connection->sender_work); } -/* if still unconfigured, stops worker again. */ +/* if still unconfigured, stops sender again. */ static void conn_reconfig_done(struct drbd_connection *connection) { bool stop_threads; @@ -1368,7 +1368,7 @@ static void conn_reconfig_done(struct drbd_connection *connection) /* ack_receiver thread and ack_sender workqueue are implicitly * stopped by receiver in conn_disconnect() */ drbd_thread_stop(&connection->receiver); - drbd_thread_stop(&connection->worker); + drbd_thread_stop(&connection->sender); } } @@ -4362,7 +4362,7 @@ static enum drbd_ret_code adm_del_minor(struct drbd_device *device) /* If the state engine hasn't stopped the sender thread yet, we * need to flush the sender work queue before generating the * DESTROY events here. */ - if (get_t_state(&connection->worker) == RUNNING) + if (get_t_state(&connection->sender) == RUNNING) drbd_flush_workqueue(&connection->sender_work); mutex_lock(¬ification_mutex); @@ -4424,7 +4424,7 @@ static int adm_del_resource(struct drbd_resource *resource) /* Make sure all threads have actually stopped: state handling only * does drbd_thread_stop_nowait(). */ list_for_each_entry(connection, &resource->connections, connections) - drbd_thread_stop(&connection->worker); + drbd_thread_stop(&connection->sender); synchronize_rcu(); drbd_free_resource(resource); return NO_ERROR; diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 380e6584a4ee..cd56fd0f3b06 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -202,6 +202,7 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m) * not yet completed by the local io subsystem * these flags may get cleared in any order by * the worker, + * the sender, * the receiver, * the bio_endio completion callbacks. */ @@ -717,7 +718,8 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, 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 worker queue */ + * so it is no longer marked as on the sender queue + */ mod_rq_state(req, m, RQ_NET_QUEUED, 0); break; diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_sender.c similarity index 99% rename from drivers/block/drbd/drbd_worker.c rename to drivers/block/drbd/drbd_sender.c index 4352a50fbb3f..fcc8a43efdca 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_sender.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - drbd_worker.c + drbd_sender.c This file is part of DRBD by Philipp Reisner and Lars Ellenberg. @@ -865,7 +865,7 @@ int drbd_resync_finished(struct drbd_peer_device *peer_device) * resync LRU would be wrong. */ if (drbd_rs_del_all(device)) { /* In case this is not possible now, most probably because - * there are P_RS_DATA_REPLY Packets lingering on the worker's + * there are P_RS_DATA_REPLY Packets lingering on the sender's * queue (or even the read operations for those packets * is not finished by now). Retry in 100ms. */ @@ -1587,7 +1587,7 @@ static bool drbd_pause_after(struct drbd_device *device) * drbd_resume_next() - Resume resync on all devices that may resync now * @device: DRBD device. * - * Called from process context only (admin command and worker). + * Called from process context only (admin command and sender). */ static bool drbd_resume_next(struct drbd_device *device) { @@ -1783,8 +1783,8 @@ void drbd_start_resync(struct drbd_device *device, enum drbd_conns side) } } - if (current == connection->worker.task) { - /* The worker should not sleep waiting for state_mutex, + if (current == connection->sender.task) { + /* The sender should not sleep waiting for state_mutex, that can take long */ if (!mutex_trylock(device->state_mutex)) { set_bit(B_RS_H_DONE, &device->flags); @@ -1977,7 +1977,7 @@ static void go_diskless(struct drbd_device *device) * while we detach. * Any modifications would not be expected anymore, though. */ - if (drbd_bitmap_io_from_worker(device, drbd_bm_write, + if (drbd_bitmap_io_from_sender(device, drbd_bm_write, "detach", BM_LOCKED_TEST_ALLOWED, peer_device)) { if (test_bit(WAS_READ_ERROR, &device->flags)) { drbd_md_set_flag(device, MDF_FULL_SYNC); @@ -2142,7 +2142,7 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head * break; /* drbd_send() may have called flush_signals() */ - if (get_t_state(&connection->worker) != RUNNING) + if (get_t_state(&connection->sender) != RUNNING) break; schedule(); @@ -2167,7 +2167,7 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head * mutex_unlock(&connection->data.mutex); } -int drbd_worker(struct drbd_thread *thi) +int drbd_sender(struct drbd_thread *thi) { struct drbd_connection *connection = thi->connection; struct drbd_work *w = NULL; @@ -2191,7 +2191,7 @@ int drbd_worker(struct drbd_thread *thi) if (signal_pending(current)) { flush_signals(current); if (get_t_state(thi) == RUNNING) { - drbd_warn(connection, "Worker got an unexpected signal\n"); + drbd_warn(connection, "Sender got an unexpected signal\n"); continue; } break; diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index 287a8d1d3f70..c623769abc1a 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -622,7 +622,7 @@ drbd_req_state(struct drbd_device *device, union drbd_state mask, spin_unlock_irqrestore(&device->resource->req_lock, flags); if (f & CS_WAIT_COMPLETE && rv == SS_SUCCESS) { - D_ASSERT(device, current != first_peer_device(device)->connection->worker.task); + D_ASSERT(device, current != first_peer_device(device)->connection->sender.task); wait_for_completion(&done); } @@ -1519,14 +1519,14 @@ static void abw_start_sync(struct drbd_device *device, int rv) } } -int drbd_bitmap_io_from_worker(struct drbd_device *device, +int drbd_bitmap_io_from_sender(struct drbd_device *device, int (*io_fn)(struct drbd_device *, struct drbd_peer_device *), char *why, enum bm_flag flags, struct drbd_peer_device *peer_device) { int rv; - D_ASSERT(device, current == first_peer_device(device)->connection->worker.task); + D_ASSERT(device, current == first_peer_device(device)->connection->sender.task); /* open coded non-blocking drbd_suspend_io(device); */ atomic_inc(&device->suspend_cnt); @@ -1841,7 +1841,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, /* We may still be Primary ourselves. * No harm done if the bitmap still changes, * redirtied pages will follow later. */ - drbd_bitmap_io_from_worker(device, &drbd_bm_write, + drbd_bitmap_io_from_sender(device, &drbd_bm_write, "demote diskless peer", BM_LOCKED_SET_ALLOWED, peer_device); put_ldev(device); } @@ -1853,7 +1853,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, device->state.conn <= C_CONNECTED && get_ldev(device)) { /* No changes to the bitmap expected this time, so assert that, * even though no harm was done if it did change. */ - drbd_bitmap_io_from_worker(device, &drbd_bm_write, + drbd_bitmap_io_from_sender(device, &drbd_bm_write, "demote", BM_LOCKED_TEST_ALLOWED, peer_device); put_ldev(device); } From patchwork Thu Sep 28 09:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_B=C3=B6hmwalder?= X-Patchwork-Id: 13402411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCFAFCE7B12 for ; Thu, 28 Sep 2023 09:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231817AbjI1Jjn (ORCPT ); Thu, 28 Sep 2023 05:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbjI1JjV (ORCPT ); Thu, 28 Sep 2023 05:39:21 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB1871B6 for ; Thu, 28 Sep 2023 02:39:02 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-32336a30d18so4738219f8f.2 for ; Thu, 28 Sep 2023 02:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1695893941; x=1696498741; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DjqSRzwtcmbZCSdKBG680ING+E16TFEDXl3yu9hsx/4=; b=C8M0DdeXPslPvE2nDGk1T6oVddJq0OD10kcrqDGNu7AEzn3VKwgw/N2JL8t2Oazj60 DYz0MAh1+2PoNkVNK3IuowcCZ3+nAUi9jvLlVQM0r7zsOb5CqxRcaJTjKYEADq37DNeS lf0ly9rWlXyHxvqRiUuVAW0mPvwoRLSqc6nuYDYk8qBPBqWDTVft0e2Xsz0+1K1MllFq 8wtJlqyoC6+mcjhHiKx7Dc4DDEsTMPdMgxR/nEmVEzO+LCpOtCWFkx84vtgnHBlSHV+x w9lGMMf57GBh5lVof3OxqQqyQJQqERyhZxelnkSB/HZWZcnGSzCizQABp/wjTVrVdh6G nsKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695893941; x=1696498741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DjqSRzwtcmbZCSdKBG680ING+E16TFEDXl3yu9hsx/4=; b=RV2OOapJeKoYGA7OXeznn4HThpR849iSdIK0zhOyyE28pA/GaPHzBUxLdvoLIoCxrh 8I0/prrCVi7CEjnDzMOD3k8Dbi92KB85GnhP2vx+aH/gFqs0yGyvWDlgw0xJWwJTUZ26 Exd3vb/9pNDiWis5pYiWxRmspDgEdQboNojlkI4J43jIhWZov2z3vrvpBoqG+cx7ucpY KzRqoD88BavmDquu2+kSBimLnHO3FmxsQASpuoMGrgVyxt1uH3mE5/rmh1eScYvMF7U9 bvYyH2/vZGNVALsmaU4ScHdEe1mlNjFCTd/qjcN/SPmWlQMVw7LPm1WKcjzUQQHGrIN1 x76Q== X-Gm-Message-State: AOJu0YwfKOARbZtOKnoZYsiDNZinSKg3wG+8Ki0XNuSjiXA7R2pxzzaI 5idFpmkfCpo6IpK0OoLYvfL+2Q== X-Google-Smtp-Source: AGHT+IGdEtds9yfynzz07vsuk4Ka5Y1yzotz4oFQqFgtVM7Pp6z4PO00hby8WHdz4jdco6WcaLK5Aw== X-Received: by 2002:adf:dc90:0:b0:319:7134:a3cf with SMTP id r16-20020adfdc90000000b003197134a3cfmr617107wrj.31.1695893941024; Thu, 28 Sep 2023 02:39:01 -0700 (PDT) Received: from localhost.localdomain (213-225-13-130.nat.highway.a1.net. [213.225.13.130]) by smtp.gmail.com with ESMTPSA id f4-20020a5d50c4000000b0031fa870d4b3sm18931449wrt.60.2023.09.28.02.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:39:00 -0700 (PDT) From: =?utf-8?q?Christoph_B=C3=B6hmwalder?= To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Joel Colledge , =?utf-8?q?Christoph_B=C3=B6hmwalder?= Subject: [PATCH 2/5] drbd: Add new per-resource "worker" thread Date: Thu, 28 Sep 2023 11:38:49 +0200 Message-ID: <20230928093852.676786-3-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> References: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Out-of-tree fixes folded in: - drbd: allow to dequeue batches of work at a time (partial backport) - drbd: Keep "worker" alive while resource exists - Flush the work queue before stopping the worker thread Originally-from: Andreas Gruenbacher Reviewed-by: Joel Colledge Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/drbd_int.h | 4 +++ drivers/block/drbd/drbd_main.c | 5 ++++ drivers/block/drbd/drbd_nl.c | 2 +- drivers/block/drbd/drbd_sender.c | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index a53e63af23f1..fe7e93a4dfa6 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -603,6 +603,9 @@ struct drbd_resource { enum write_ordering_e write_ordering; cpumask_var_t cpu_mask; + + struct drbd_work_queue work; + struct drbd_thread worker; }; struct drbd_thread_timing_details @@ -1428,6 +1431,7 @@ extern void drbd_md_endio(struct bio *bio); extern void drbd_peer_request_endio(struct bio *bio); extern void drbd_request_endio(struct bio *bio); extern int drbd_sender(struct drbd_thread *thi); +extern int drbd_worker(struct drbd_thread *thi); enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); void drbd_resync_after_changed(struct drbd_device *device); extern void drbd_start_resync(struct drbd_device *device, enum drbd_conns side); diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index a14c1e9ee327..bb5de1e1ca9f 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2329,6 +2329,8 @@ void drbd_free_resource(struct drbd_resource *resource) { struct drbd_connection *connection, *tmp; + drbd_flush_workqueue(&resource->work); + drbd_thread_stop(&resource->worker); for_each_connection_safe(connection, tmp, resource) { list_del(&connection->connections); drbd_debugfs_connection_cleanup(connection); @@ -2564,6 +2566,9 @@ struct drbd_resource *drbd_create_resource(const char *name) mutex_init(&resource->conf_update); mutex_init(&resource->adm_mutex); spin_lock_init(&resource->req_lock); + drbd_init_workqueue(&resource->work); + drbd_thread_init(resource, &resource->worker, drbd_worker, "worker"); + drbd_thread_start(&resource->worker); drbd_debugfs_resource_add(resource); return resource; diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index a5844819d1c3..9d9ced46f968 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1900,7 +1900,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(&connection->sender_work); + drbd_flush_workqueue(&device->resource->work); rv = _drbd_request_state(device, NS(disk, D_ATTACHING), CS_VERBOSE); retcode = (enum drbd_ret_code)rv; diff --git a/drivers/block/drbd/drbd_sender.c b/drivers/block/drbd/drbd_sender.c index fcc8a43efdca..0c482d45a52a 100644 --- a/drivers/block/drbd/drbd_sender.c +++ b/drivers/block/drbd/drbd_sender.c @@ -2239,3 +2239,49 @@ int drbd_sender(struct drbd_thread *thi) return 0; } + +int drbd_worker(struct drbd_thread *thi) +{ + LIST_HEAD(work_list); + struct drbd_resource *resource = thi->resource; + struct drbd_work *w; + + while (get_t_state(thi) == RUNNING) { + drbd_thread_current_set_cpu(thi); + + if (list_empty(&work_list)) { + wait_event_interruptible(resource->work.q_wait, + dequeue_work_batch(&resource->work, &work_list)); + } + + if (signal_pending(current)) { + flush_signals(current); + if (get_t_state(thi) == RUNNING) { + drbd_warn(resource, "Worker got an unexpected signal\n"); + continue; + } + break; + } + + if (get_t_state(thi) != RUNNING) + break; + + + while (!list_empty(&work_list)) { + w = list_first_entry(&work_list, struct drbd_work, list); + list_del_init(&w->list); + w->cb(w, 0); + } + } + + do { + while (!list_empty(&work_list)) { + w = list_first_entry(&work_list, struct drbd_work, list); + list_del_init(&w->list); + w->cb(w, 1); + } + dequeue_work_batch(&resource->work, &work_list); + } while (!list_empty(&work_list)); + + return 0; +} From patchwork Thu Sep 28 09:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_B=C3=B6hmwalder?= X-Patchwork-Id: 13402407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19590CE7B12 for ; Thu, 28 Sep 2023 09:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbjI1Jjd (ORCPT ); Thu, 28 Sep 2023 05:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbjI1JjV (ORCPT ); Thu, 28 Sep 2023 05:39:21 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C926ECE2 for ; Thu, 28 Sep 2023 02:39:03 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3248e90f032so172363f8f.1 for ; Thu, 28 Sep 2023 02:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1695893942; x=1696498742; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FxdqCPbXhmzZcYHHWzAs1Pz189GcHmpMYCt/LIrBVmA=; b=defPPbsL31qtr6Fegpk+sAyp/swDW33q+GGjJfm2HTUJBv1BXu4Yz/obKNEjhlODV3 FhWVgZyPQfTjtl/IfBLB0ay4Vr4hvmNUeyp3zgWJloAIymdu8BsIayJlOPkhtuD1cium e0LOnSuwZCLSaz7I0euNIkAmht+SDP3LBF2w0d4q9jYUbujT40YXccUKDdnr3Mwka+x6 +4Stdr0uux2cHqTe/trKh6Yu0nUcYjr8Jtes6b3D/0f4Z3cewVQTrBFEc7oGmrVs7CJf bT5LZFeJ08cYFkqP5GVSRszrsq32sjQ8O2xJ2gb6mbA0ZaGIQMpDtls3SnsQHmFF8WFl xKrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695893942; x=1696498742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FxdqCPbXhmzZcYHHWzAs1Pz189GcHmpMYCt/LIrBVmA=; b=D6RQsAt4N9y5/qZUmNfr9qolOHJrvCe6UEL6xQZNnunyJS6WXjCAywOdZYXZ2sYZcU ZvXfYuRGK/RhXvcF1xz5Qb+2WKBFFHWsBdNQAqtmthdaDtKPu7XmyvCsIarJk1QY8hUM zuwr+22Y7C5OSAF7W5gyLLE+2B2MzyyDdIg4pxvpZZgRDnT3wHX4ei58MTQXnbffnrxV wMH9l3XwMUJZ6dOlVrczadakGxZ7oiIp6NRm4Q7Zcc3CgoEFizO/xoIzbbBp5di9LZKn /d+Vw3NHAl13Wk/jAAnXUfb1JVj3EPyvJiMK0fC2SdyQCdtyF/mF9mvVy5xfviRts2xh XxuA== X-Gm-Message-State: AOJu0YwDB9dkenl4kh9Y2wYxAFs0Qfs0Un3MfpWjcn0HqCYO+F1aTqrz qt+S//ayUJh8+oVwQZQ1AdEyUQ== X-Google-Smtp-Source: AGHT+IFXErMwVQh26NX4Lo+CN3tqVv9eERZaRoI/iWHEjF+72aA0bMsuVLkXufdDKwDB+VZd3qOeDQ== X-Received: by 2002:a05:6000:10c4:b0:319:77dd:61f9 with SMTP id b4-20020a05600010c400b0031977dd61f9mr668384wrx.35.1695893942239; Thu, 28 Sep 2023 02:39:02 -0700 (PDT) Received: from localhost.localdomain (213-225-13-130.nat.highway.a1.net. [213.225.13.130]) by smtp.gmail.com with ESMTPSA id f4-20020a5d50c4000000b0031fa870d4b3sm18931449wrt.60.2023.09.28.02.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:39:01 -0700 (PDT) From: =?utf-8?q?Christoph_B=C3=B6hmwalder?= To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Joel Colledge , =?utf-8?q?Christoph_B=C3=B6hmwalder?= Subject: [PATCH 3/5] drbd: Move connection independent work from "sender" to "worker" Date: Thu, 28 Sep 2023 11:38:50 +0200 Message-ID: <20230928093852.676786-4-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> References: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Originally-from: Andreas Gruenbacher Reviewed-by: Joel Colledge Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/drbd_receiver.c | 2 +- drivers/block/drbd/drbd_req.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 0c9f54197768..6e21df44b5aa 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -5890,7 +5890,7 @@ static int got_OVResult(struct drbd_connection *connection, struct packet_info * if (dw) { dw->w.cb = w_ov_finished; dw->device = device; - drbd_queue_work(&peer_device->connection->sender_work, &dw->w); + drbd_queue_work(&device->resource->work, &dw->w); } else { drbd_err(device, "kmalloc(dw) failed."); ov_out_of_sync_print(peer_device); diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index cd56fd0f3b06..fbb47138a52b 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -823,8 +823,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, get_ldev(device); /* always succeeds in this call path */ req->w.cb = w_restart_disk_io; - drbd_queue_work(&connection->sender_work, - &req->w); + drbd_queue_work(&device->resource->work, &req->w); break; case RESEND: From patchwork Thu Sep 28 09:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_B=C3=B6hmwalder?= X-Patchwork-Id: 13402410 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C64DCE7B15 for ; Thu, 28 Sep 2023 09:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231857AbjI1Jjk (ORCPT ); Thu, 28 Sep 2023 05:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbjI1JjX (ORCPT ); Thu, 28 Sep 2023 05:39:23 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31801CE5 for ; Thu, 28 Sep 2023 02:39:05 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3215f19a13aso12528640f8f.3 for ; Thu, 28 Sep 2023 02:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1695893943; x=1696498743; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nGK+HdR6obbUDfw8jsEAQzDJzPR9njsPrKQpwnxwsJU=; b=CqtslHtvLU9LFCqlrfUd8D6vR4EEvquMYBMfTlzM+JGw3xd5NV2y4H4zwhnEnz3GG+ 2Tw5ofJnuzip07M358UcS+zxTMKSr2oY3KbLZp6Val9ykb+FbeZrUYov7AZpXgTI9Y17 uc4O4H7AQZ0ADkg4zWABOoMJ/z1RRl3Vy8vA1QiBlB7OWIwAB/R8YnGDSYLNMkWaS7Uv YutChMpHRTqTzF6vsx0jrzq3unt9bYEa5+cj5ugFAU+DjlwlwIFaZ3/lahk8JCb64msG zI7cGndBSMP9EntXlkrdyZWIADvqo1ReoFx19qzhXB9dnNbbmIJd13XW2emhwZlybltg gWBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695893943; x=1696498743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nGK+HdR6obbUDfw8jsEAQzDJzPR9njsPrKQpwnxwsJU=; b=bfGhr8XCDQnh9yX6i6y6ALrQ77y3GAPjtZYZ7wVEWas4A/SakWpCXYOSNJJqS05JL3 r64OKzHaDYBmyvdPmu3C2N2U779movToL09QiO/4QrzY5JvSlklKIHP8TPpW92S+x+X+ c+oJOx3+sBFCtOtzyi/fETAGDIaAEmbn1tf++QeZVF5iBjor7NvULlCjukSwWXwllCQ3 W46mPoIWLX1kCbqHxbyj3Cj/wVTUiKHAtYPD8kMp0a1eHhVlIM67HF8yajB3epXJgbtK j0NFtRx2zrd1psyL3bA9c8hirC3+XmB0OzP51yz4uZKKDJ1bHuquBtIBhCd8qbnAeVFI 8KiA== X-Gm-Message-State: AOJu0YzKxe30tJgiB/LqQwxcn3r/XDHN0r62WWPgWJi9uqUIz7UB+KRl H8BALhWystqavs3by3tP8hMwbQ== X-Google-Smtp-Source: AGHT+IEs9yBVflEyi8aWeeB2xlHf8uw7cl5KRIXN78um42kIokcnqkm/4b1KHILhnLQXF/9X9WINbA== X-Received: by 2002:adf:d0cc:0:b0:31d:da10:e471 with SMTP id z12-20020adfd0cc000000b0031dda10e471mr696646wrh.69.1695893943541; Thu, 28 Sep 2023 02:39:03 -0700 (PDT) Received: from localhost.localdomain (213-225-13-130.nat.highway.a1.net. [213.225.13.130]) by smtp.gmail.com with ESMTPSA id f4-20020a5d50c4000000b0031fa870d4b3sm18931449wrt.60.2023.09.28.02.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:39:03 -0700 (PDT) From: =?utf-8?q?Christoph_B=C3=B6hmwalder?= To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Joel Colledge , =?utf-8?q?Christoph_B=C3=B6hmwalder?= Subject: [PATCH 4/5] drbd: Keep connection threads running while connection is up only Date: Thu, 28 Sep 2023 11:38:51 +0200 Message-ID: <20230928093852.676786-5-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> References: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Connection independent work has been moved from the connection "sender" to the resource "worker", so there no longer is a need to keep the "sender" running when the connection is down. Originally-from: Andreas Gruenbacher Reviewed-by: Joel Colledge Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/drbd_nl.c | 6 +----- drivers/block/drbd/drbd_state.c | 21 --------------------- drivers/block/drbd/drbd_state.h | 1 - 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 9d9ced46f968..85ab6f0f9d87 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1361,8 +1361,7 @@ static void conn_reconfig_done(struct drbd_connection *connection) { bool stop_threads; spin_lock_irq(&connection->resource->req_lock); - stop_threads = conn_all_vols_unconf(connection) && - connection->cstate == C_STANDALONE; + stop_threads = connection->cstate == C_STANDALONE; spin_unlock_irq(&connection->resource->req_lock); if (stop_threads) { /* ack_receiver thread and ack_sender workqueue are implicitly @@ -1749,7 +1748,6 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) mutex_lock(&adm_ctx.resource->adm_mutex); peer_device = first_peer_device(device); connection = peer_device->connection; - conn_reconfig_start(connection); /* if you want to reconfigure, please tear down first */ if (device->state.disk > D_DISKLESS) { @@ -2117,7 +2115,6 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) kobject_uevent(&disk_to_dev(device->vdisk)->kobj, KOBJ_CHANGE); put_ldev(device); - conn_reconfig_done(connection); mutex_unlock(&adm_ctx.resource->adm_mutex); drbd_adm_finish(&adm_ctx, info, retcode); return 0; @@ -2128,7 +2125,6 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) drbd_force_state(device, NS(disk, D_DISKLESS)); drbd_md_sync(device); fail: - conn_reconfig_done(connection); if (nbc) { close_backing_dev(device, nbc->md_bdev, nbc->disk_conf->meta_dev_idx < 0 ? diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index c623769abc1a..0a901e5aca0a 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -291,27 +291,6 @@ static inline bool is_susp(union drbd_state s) return s.susp || s.susp_nod || s.susp_fen; } -bool conn_all_vols_unconf(struct drbd_connection *connection) -{ - struct drbd_peer_device *peer_device; - bool rv = true; - int vnr; - - rcu_read_lock(); - idr_for_each_entry(&connection->peer_devices, peer_device, vnr) { - struct drbd_device *device = peer_device->device; - if (device->state.disk != D_DISKLESS || - device->state.conn != C_STANDALONE || - device->state.role != R_SECONDARY) { - rv = false; - break; - } - } - rcu_read_unlock(); - - return rv; -} - /* Unfortunately the states where not correctly ordered, when they where defined. therefore can not use max_t() here. */ static enum drbd_role max_role(enum drbd_role role1, enum drbd_role role2) diff --git a/drivers/block/drbd/drbd_state.h b/drivers/block/drbd/drbd_state.h index cbaeb8018dbf..67371bd563e4 100644 --- a/drivers/block/drbd/drbd_state.h +++ b/drivers/block/drbd/drbd_state.h @@ -142,7 +142,6 @@ conn_request_state(struct drbd_connection *connection, union drbd_state mask, un enum chg_state_flags flags); extern void drbd_resume_al(struct drbd_device *device); -extern bool conn_all_vols_unconf(struct drbd_connection *connection); /** * drbd_request_state() - Request a state change From patchwork Thu Sep 28 09:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_B=C3=B6hmwalder?= X-Patchwork-Id: 13402409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E5D4CE7B11 for ; Thu, 28 Sep 2023 09:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbjI1Jjf (ORCPT ); Thu, 28 Sep 2023 05:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbjI1JjX (ORCPT ); Thu, 28 Sep 2023 05:39:23 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7817DCE8 for ; Thu, 28 Sep 2023 02:39:06 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31f7400cb74so11513089f8f.2 for ; Thu, 28 Sep 2023 02:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20230601.gappssmtp.com; s=20230601; t=1695893945; x=1696498745; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RUAvpHbZIlJDAymrC3wO69unj3kyTMzvS96nKCkH42g=; b=QCw8itSkMqpC5Prk0VPaoql/XSrWr14r5OHinGiKdig7dubkSVYoFamSqilNgisdx5 0kwunV7CjHNNCPp56sMJiFlODTk0YUjN4yLCCMGo4D2RRGj8i/AzGjyPzUOqt/BwuUJ/ VxplwlXtJGxeBvOzNhI45xMl3X8NQVWZirvU6d3UfK5PKV3JrbQZU19luk2vuaykZQcc TQIkgJgOEgByhapcL+g6gH2pENMFUmOSkETV2uIDUTrZJ3HWIqTt+WyHMGB39mRarVdq z3lSMzh5Igj3YBPngkprUem45GgW/L8CFwfeZdGfSaialid5MLfNktX8kNGezalImPwc qHQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695893945; x=1696498745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RUAvpHbZIlJDAymrC3wO69unj3kyTMzvS96nKCkH42g=; b=UEVune10t4cakCxZkFmBSl06GWlS+HNHwx+Q8XUXBa8FmeVqKms547V7nFrLWzVLX1 lCQkQOz4Y3JEGfG+2j4L3x292uXucFCJvZ7CVEPB6hT4Lgh2TbV1ti2uHnzgxQTRQWVi R2DzsmiGMj5CTvX4266xradD42kl18pHruhUIRcQueHN1/rTcW6tuM1gMmzGueqHkU/B qqJVArmTEjCteslkANpSbjTkjdWVnABmcmZtGyIH4l3yKOVXVCq3pFGURIzI0Ry5jqux dUiQ4mczUMiClq7Uhpf9WsKjUP8aE71wICl9hX4u8z1zjAgeo0VUg6T3c/UfcDlSDPLQ m7gA== X-Gm-Message-State: AOJu0YxGFfGCRWXPLhMC7LBr4TVAmZAQBo8hAiRBU0BOL/vDyth9yJ0x wjRwWcrWtkindbTfUaqulZzelA== X-Google-Smtp-Source: AGHT+IFOh1UVdUIHYK2shBxIs9apOwc+4FRG5zqxR/3bZCY1dSSV3c0K6NkS/zzqRscr/ae10XfuIw== X-Received: by 2002:a5d:4985:0:b0:320:10c:37a4 with SMTP id r5-20020a5d4985000000b00320010c37a4mr712514wrq.21.1695893944947; Thu, 28 Sep 2023 02:39:04 -0700 (PDT) Received: from localhost.localdomain (213-225-13-130.nat.highway.a1.net. [213.225.13.130]) by smtp.gmail.com with ESMTPSA id f4-20020a5d50c4000000b0031fa870d4b3sm18931449wrt.60.2023.09.28.02.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:39:04 -0700 (PDT) From: =?utf-8?q?Christoph_B=C3=B6hmwalder?= To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Joel Colledge , =?utf-8?q?Christoph_B=C3=B6hmwalder?= Subject: [PATCH 5/5] drbd: Get rid of conn_reconfig_start() and conn_reconfig_done() Date: Thu, 28 Sep 2023 11:38:52 +0200 Message-ID: <20230928093852.676786-6-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> References: <20230928093852.676786-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Originally-from: Andreas Gruenbacher Reviewed-by: Joel Colledge Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/drbd_nl.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 85ab6f0f9d87..5de8a6641253 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -1349,28 +1349,6 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_ba drbd_setup_queue_param(device, bdev, new, o); } -/* Starts the sender thread */ -static void conn_reconfig_start(struct drbd_connection *connection) -{ - drbd_thread_start(&connection->sender); - drbd_flush_workqueue(&connection->sender_work); -} - -/* if still unconfigured, stops sender again. */ -static void conn_reconfig_done(struct drbd_connection *connection) -{ - bool stop_threads; - spin_lock_irq(&connection->resource->req_lock); - stop_threads = connection->cstate == C_STANDALONE; - spin_unlock_irq(&connection->resource->req_lock); - if (stop_threads) { - /* ack_receiver thread and ack_sender workqueue are implicitly - * stopped by receiver in conn_disconnect() */ - drbd_thread_stop(&connection->receiver); - drbd_thread_stop(&connection->sender); - } -} - /* Make sure IO is suspended before calling this function(). */ static void drbd_suspend_al(struct drbd_device *device) { @@ -2382,7 +2360,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) goto out; } - conn_reconfig_start(connection); + drbd_flush_workqueue(&connection->sender_work); mutex_lock(&connection->data.mutex); mutex_lock(&connection->resource->conf_update); @@ -2461,15 +2439,13 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) drbd_send_sync_param(peer_device); } - goto done; + goto out; fail: mutex_unlock(&connection->resource->conf_update); mutex_unlock(&connection->data.mutex); free_crypto(&crypto); kfree(new_net_conf); - done: - conn_reconfig_done(connection); out: mutex_unlock(&adm_ctx.resource->adm_mutex); finish: @@ -2548,7 +2524,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) mutex_lock(&adm_ctx.resource->adm_mutex); connection = first_connection(adm_ctx.resource); - conn_reconfig_start(connection); if (connection->cstate > C_STANDALONE) { retcode = ERR_NET_CONFIGURED; @@ -2581,8 +2556,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) ((char *)new_net_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0; - drbd_flush_workqueue(&connection->sender_work); - mutex_lock(&adm_ctx.resource->conf_update); old_net_conf = connection->net_conf; if (old_net_conf) { @@ -2631,7 +2604,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) rv = conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE); - conn_reconfig_done(connection); + drbd_thread_start(&connection->sender); mutex_unlock(&adm_ctx.resource->adm_mutex); drbd_adm_finish(&adm_ctx, info, rv); return 0; @@ -2640,7 +2613,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) free_crypto(&crypto); kfree(new_net_conf); - conn_reconfig_done(connection); mutex_unlock(&adm_ctx.resource->adm_mutex); out: drbd_adm_finish(&adm_ctx, info, retcode);