mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 15:13:55 +08:00
drbd: Introduce a "lockless" variant of drbd_send_protocoll()
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
4b6ad6d457
commit
a7eb7bdf58
@ -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,
|
extern int drbd_send_all(struct drbd_tconn *, struct socket *, void *, size_t,
|
||||||
unsigned);
|
unsigned);
|
||||||
|
|
||||||
|
extern int __drbd_send_protocol(struct drbd_tconn *tconn);
|
||||||
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(struct drbd_conf *mdev);
|
||||||
extern int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev);
|
extern int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev);
|
||||||
|
@ -757,14 +757,24 @@ static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr,
|
|||||||
return prepare_header80(buffer, cmd, size);
|
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 *conn_prepare_command(struct drbd_tconn *tconn, struct drbd_socket *sock)
|
||||||
{
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
mutex_lock(&sock->mutex);
|
mutex_lock(&sock->mutex);
|
||||||
if (!sock->socket) {
|
p = __conn_prepare_command(tconn, sock);
|
||||||
|
if (!p)
|
||||||
mutex_unlock(&sock->mutex);
|
mutex_unlock(&sock->mutex);
|
||||||
return NULL;
|
|
||||||
}
|
return p;
|
||||||
return sock->sbuf + drbd_header_size(tconn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *drbd_prepare_command(struct drbd_conf *mdev, struct drbd_socket *sock)
|
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;
|
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,
|
int conn_send_command(struct drbd_tconn *tconn, struct drbd_socket *sock,
|
||||||
enum drbd_packet cmd, unsigned int header_size,
|
enum drbd_packet cmd, unsigned int header_size,
|
||||||
void *data, unsigned int size)
|
void *data, unsigned int size)
|
||||||
{
|
{
|
||||||
int err;
|
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);
|
mutex_unlock(&sock->mutex);
|
||||||
return err;
|
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);
|
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 drbd_socket *sock;
|
||||||
struct p_protocol *p;
|
struct p_protocol *p;
|
||||||
@ -901,7 +918,7 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
|
|||||||
int size, cf;
|
int size, cf;
|
||||||
|
|
||||||
sock = &tconn->data;
|
sock = &tconn->data;
|
||||||
p = conn_prepare_command(tconn, sock);
|
p = __conn_prepare_command(tconn, sock);
|
||||||
if (!p)
|
if (!p)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
@ -935,7 +952,18 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
|
|||||||
strcpy(p->integrity_alg, nc->integrity_alg);
|
strcpy(p->integrity_alg, nc->integrity_alg);
|
||||||
rcu_read_unlock();
|
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)
|
int _drbd_send_uuids(struct drbd_conf *mdev, u64 uuid_flags)
|
||||||
|
Loading…
Reference in New Issue
Block a user