drbd: Converted drbd_send_fp() from mdev to tconn
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 7 Feb 2011 14:32:04 +0000 (15:32 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Wed, 28 Sep 2011 08:29:45 +0000 (10:29 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_receiver.c

index ccbb0320a2c8b464cef56a4a3a1c3ee82ee2ffc2..e640ffdad9cdee887c4878f798f85fcf10f7f40c 100644 (file)
@@ -1168,9 +1168,9 @@ extern int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev);
 extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags);
 extern int _drbd_send_state(struct drbd_conf *mdev);
 extern int drbd_send_state(struct drbd_conf *mdev);
-extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
-                         enum drbd_packet cmd, struct p_header *h,
-                         size_t size, unsigned msg_flags);
+extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock,
+                         enum drbd_packet cmd, struct p_header *h, size_t size,
+                         unsigned msg_flags);
 #define USE_DATA_SOCKET 1
 #define USE_META_SOCKET 0
 extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
@@ -1870,6 +1870,13 @@ static inline void request_ping(struct drbd_tconn *tconn)
        wake_asender(tconn);
 }
 
+static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
+                                 enum drbd_packet cmd, struct p_header *h, size_t size,
+                                 unsigned msg_flags)
+{
+       return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags);
+}
+
 static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
                                      enum drbd_packet cmd)
 {
index d1bfbfcf8f24cdec23498c42fd3655ec38e16658..2a67e272b16c29455c5fe942f5aa440f49547d69 100644 (file)
@@ -651,51 +651,50 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev, struct drbd_thread *thi
 }
 #endif
 
-static void prepare_header80(struct drbd_conf *mdev, struct p_header80 *h,
-                            enum drbd_packet cmd, int size)
+static void prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
 {
        h->magic   = cpu_to_be32(DRBD_MAGIC);
        h->command = cpu_to_be16(cmd);
        h->length  = cpu_to_be16(size);
 }
 
-static void prepare_header95(struct drbd_conf *mdev, struct p_header95 *h,
-                            enum drbd_packet cmd, int size)
+static void prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
 {
        h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
        h->command = cpu_to_be16(cmd);
        h->length  = cpu_to_be32(size);
 }
 
+static void _prepare_header(struct drbd_tconn *tconn, int vnr, struct p_header *h,
+                           enum drbd_packet cmd, int size)
+{
+       if (tconn->agreed_pro_version >= 100 || size > DRBD_MAX_SIZE_H80_PACKET)
+               prepare_header95(&h->h95, cmd, size);
+       else
+               prepare_header80(&h->h80, cmd, size);
+}
+
 static void prepare_header(struct drbd_conf *mdev, struct p_header *h,
                           enum drbd_packet cmd, int size)
 {
-       if (mdev->tconn->agreed_pro_version >= 100 || size > DRBD_MAX_SIZE_H80_PACKET)
-               prepare_header95(mdev, &h->h95, cmd, size);
-       else
-               prepare_header80(mdev, &h->h80, cmd, size);
+       _prepare_header(mdev->tconn, mdev->vnr, h, cmd, size);
 }
 
 /* the appropriate socket mutex must be held already */
-int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
+int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock,
                   enum drbd_packet cmd, struct p_header *h, size_t size,
                   unsigned msg_flags)
 {
        int sent, ok;
 
-       if (!expect(h))
-               return false;
-       if (!expect(size))
-               return false;
-
-       prepare_header(mdev, h, cmd, size - sizeof(struct p_header));
+       _prepare_header(tconn, vnr, h, cmd, size - sizeof(struct p_header));
 
-       sent = drbd_send(mdev->tconn, sock, h, size, msg_flags);
+       sent = drbd_send(tconn, sock, h, size, msg_flags);
 
        ok = (sent == size);
        if (!ok && !signal_pending(current))
-               dev_warn(DEV, "short sent %s size=%d sent=%d\n",
-                   cmdname(cmd), (int)size, sent);
+               conn_warn(tconn, "short sent %s size=%d sent=%d\n",
+                         cmdname(cmd), (int)size, sent);
        return ok;
 }
 
index a5234f99de021c92d7126a6b7e25acdfe1a02339..96622d7eadfde6160fcb5a7baea406a8e460ba43 100644 (file)
@@ -698,16 +698,14 @@ out:
        return s_estab;
 }
 
-static int drbd_send_fp(struct drbd_conf *mdev, struct socket *sock,
-                       enum drbd_packet cmd)
+static int drbd_send_fp(struct drbd_tconn *tconn, struct socket *sock, enum drbd_packet cmd)
 {
-       struct p_header *h = &mdev->tconn->data.sbuf.header;
+       struct p_header *h = &tconn->data.sbuf.header;
 
-       return _drbd_send_cmd(mdev, sock, cmd, h, sizeof(*h), 0);
+       return _conn_send_cmd(tconn, 0, sock, cmd, h, sizeof(*h), 0);
 }
 
-static enum drbd_packet drbd_recv_fp(struct drbd_conf *mdev,
-                                    struct socket *sock)
+static enum drbd_packet drbd_recv_fp(struct drbd_conf *mdev, struct socket *sock)
 {
        struct p_header80 *h = &mdev->tconn->data.rbuf.header.h80;
        int rr;
@@ -782,11 +780,11 @@ static int drbd_connect(struct drbd_conf *mdev)
 
                if (s) {
                        if (!sock) {
-                               drbd_send_fp(mdev, s, P_HAND_SHAKE_S);
+                               drbd_send_fp(mdev->tconn, s, P_HAND_SHAKE_S);
                                sock = s;
                                s = NULL;
                        } else if (!msock) {
-                               drbd_send_fp(mdev, s, P_HAND_SHAKE_M);
+                               drbd_send_fp(mdev->tconn, s, P_HAND_SHAKE_M);
                                msock = s;
                                s = NULL;
                        } else {