libceph: don't call ->reencode_message() more than once per message
authorIlya Dryomov <idryomov@gmail.com>
Wed, 26 Jul 2017 07:59:15 +0000 (09:59 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 1 Aug 2017 14:46:43 +0000 (16:46 +0200)
Reencoding an already reencoded message is a bad idea.  This could
happen on Policy::stateful_server connections (!CEPH_MSG_CONNECT_LOSSY),
such as MDS sessions.

This didn't pop up in testing because currently only OSD requests are
reencoded and OSD sessions are always lossy.

Fixes: 98ad5ebd1505 ("libceph: ceph_connection_operations::reencode_message() method")
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
net/ceph/messenger.c

index b7cc615d42efdb2219771c7a83c0acd5fa9ea9f5..a67298c7e0cd4f8f7a441fa938af57e37c4bd4da 100644 (file)
@@ -1287,10 +1287,10 @@ static void prepare_write_message(struct ceph_connection *con)
        if (m->needs_out_seq) {
                m->hdr.seq = cpu_to_le64(++con->out_seq);
                m->needs_out_seq = false;
-       }
 
-       if (con->ops->reencode_message)
-               con->ops->reencode_message(m);
+               if (con->ops->reencode_message)
+                       con->ops->reencode_message(m);
+       }
 
        dout("prepare_write_message %p seq %lld type %d len %d+%d+%zd\n",
             m, con->out_seq, le16_to_cpu(m->hdr.type),