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 10/16] drbd: Introduce a "lockless" variant of drbd_send_protocoll()
Date: Wed, 5 Oct 2011 11:37:58 +0200 [thread overview]
Message-ID: <1317807484-24628-11-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1317807484-24628-1-git-send-email-philipp.reisner@linbit.com>
From: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_int.h | 1 +
drivers/block/drbd/drbd_main.c | 44 ++++++++++++++++++++++++++++++++-------
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index e6e4f4e..44f7726 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1051,6 +1051,7 @@ extern int drbd_send(struct drbd_tconn *tconn, struct socket *sock,
extern int drbd_send_all(struct drbd_tconn *, struct socket *, void *, size_t,
unsigned);
+extern int __drbd_send_protocol(struct drbd_tconn *tconn);
extern int drbd_send_protocol(struct drbd_tconn *tconn);
extern int drbd_send_uuids(struct drbd_conf *mdev);
extern int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 417c437..bcdd66d 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -757,14 +757,24 @@ static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr,
return prepare_header80(buffer, cmd, size);
}
+static void *__conn_prepare_command(struct drbd_tconn *tconn,
+ struct drbd_socket *sock)
+{
+ if (!sock->socket)
+ return NULL;
+ return sock->sbuf + drbd_header_size(tconn);
+}
+
void *conn_prepare_command(struct drbd_tconn *tconn, struct drbd_socket *sock)
{
+ void *p;
+
mutex_lock(&sock->mutex);
- if (!sock->socket) {
+ p = __conn_prepare_command(tconn, sock);
+ if (!p)
mutex_unlock(&sock->mutex);
- return NULL;
- }
- return sock->sbuf + drbd_header_size(tconn);
+
+ return p;
}
void *drbd_prepare_command(struct drbd_conf *mdev, struct drbd_socket *sock)
@@ -798,13 +808,20 @@ static int __send_command(struct drbd_tconn *tconn, int vnr,
return err;
}
+static int __conn_send_command(struct drbd_tconn *tconn, struct drbd_socket *sock,
+ enum drbd_packet cmd, unsigned int header_size,
+ void *data, unsigned int size)
+{
+ return __send_command(tconn, 0, sock, cmd, header_size, data, size);
+}
+
int conn_send_command(struct drbd_tconn *tconn, struct drbd_socket *sock,
enum drbd_packet cmd, unsigned int header_size,
void *data, unsigned int size)
{
int err;
- err = __send_command(tconn, 0, sock, cmd, header_size, data, size);
+ err = __conn_send_command(tconn, sock, cmd, header_size, data, size);
mutex_unlock(&sock->mutex);
return err;
}
@@ -893,7 +910,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev)
return drbd_send_command(mdev, sock, cmd, size, NULL, 0);
}
-int drbd_send_protocol(struct drbd_tconn *tconn)
+int __drbd_send_protocol(struct drbd_tconn *tconn)
{
struct drbd_socket *sock;
struct p_protocol *p;
@@ -901,7 +918,7 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
int size, cf;
sock = &tconn->data;
- p = conn_prepare_command(tconn, sock);
+ p = __conn_prepare_command(tconn, sock);
if (!p)
return -EIO;
@@ -935,7 +952,18 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
strcpy(p->integrity_alg, nc->integrity_alg);
rcu_read_unlock();
- return conn_send_command(tconn, sock, P_PROTOCOL, size, NULL, 0);
+ return __conn_send_command(tconn, sock, P_PROTOCOL, size, NULL, 0);
+}
+
+int drbd_send_protocol(struct drbd_tconn *tconn)
+{
+ int err;
+
+ mutex_lock(&tconn->data.mutex);
+ err = __drbd_send_protocol(tconn);
+ mutex_unlock(&tconn->data.mutex);
+
+ return err;
}
int _drbd_send_uuids(struct drbd_conf *mdev, u64 uuid_flags)
--
1.7.4.1
next prev parent reply other threads:[~2011-10-05 9:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 9:37 [RFC 00/16] drbd: part 14 of adding multiple volume support to drbd Philipp Reisner
2011-10-05 9:37 ` [PATCH 01/16] drbd: Consider all crypto options in connect and in net-options Philipp Reisner
2011-10-05 9:37 ` [PATCH 02/16] drbd: on reconfiguration requests, mind the SET_DEFAULTS flag Philipp Reisner
2011-10-05 9:37 ` [PATCH 03/16] drbd: rename variable ndc to new_disk_conf Philipp Reisner
2011-10-05 9:37 ` [PATCH 04/16] drbd: rename variable sc to res_opts Philipp Reisner
2011-10-05 9:37 ` [PATCH 05/16] drbd: fix copy/paste error in comment Philipp Reisner
2011-10-05 9:37 ` [PATCH 06/16] drbd: Wrong use of RCU in receive_protocol() Philipp Reisner
2011-10-05 9:37 ` [PATCH 07/16] drbd: Rename integrity_w_tfm -> integrity_tfm Philipp Reisner
2011-10-05 9:37 ` [PATCH 08/16] drbd: Rename integrity_r_tfm -> peer_integrity_tfm Philipp Reisner
2011-10-05 9:37 ` [PATCH 09/16] drbd: Remove obsolete drbd_crypto_is_hash() Philipp Reisner
2011-10-05 9:37 ` Philipp Reisner [this message]
2011-10-05 9:37 ` [PATCH 11/16] drbd: Allow to change data-integrity-alg on the fly Philipp Reisner
2011-10-05 9:38 ` [PATCH 12/16] drbd: fix race when forcefully disconnecting Philipp Reisner
2011-10-05 9:38 ` [PATCH 13/16] drbd: fix thread stop deadlock Philipp Reisner
2011-10-05 9:38 ` [PATCH 14/16] drbd: fix schedule in atomic Philipp Reisner
2011-10-05 9:38 ` [PATCH 15/16] drbd: Remove left-over unused define Philipp Reisner
2011-10-05 9:38 ` [PATCH 16/16] drbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h 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=1317807484-24628-11-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®