aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r--net/ceph/messenger.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index fa9b4d0243a0..a6fda9532102 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1076,18 +1076,14 @@ static bool ceph_msg_data_advance(struct ceph_msg_data *data, size_t bytes)
1076 return new_piece; 1076 return new_piece;
1077} 1077}
1078 1078
1079static void prepare_message_data(struct ceph_msg *msg) 1079static void prepare_message_data(struct ceph_msg *msg, u32 data_len)
1080{ 1080{
1081 size_t data_len;
1082
1083 BUG_ON(!msg); 1081 BUG_ON(!msg);
1084
1085 data_len = le32_to_cpu(msg->hdr.data_len);
1086 BUG_ON(!data_len); 1082 BUG_ON(!data_len);
1087 1083
1088 /* Initialize data cursor */ 1084 /* Initialize data cursor */
1089 1085
1090 ceph_msg_data_cursor_init(msg->data, data_len); 1086 ceph_msg_data_cursor_init(msg->data, (size_t)data_len);
1091} 1087}
1092 1088
1093/* 1089/*
@@ -1150,11 +1146,12 @@ static void prepare_write_message(struct ceph_connection *con)
1150 m->hdr.seq = cpu_to_le64(++con->out_seq); 1146 m->hdr.seq = cpu_to_le64(++con->out_seq);
1151 m->needs_out_seq = false; 1147 m->needs_out_seq = false;
1152 } 1148 }
1149 WARN_ON(m->data_length != le32_to_cpu(m->hdr.data_len));
1153 1150
1154 dout("prepare_write_message %p seq %lld type %d len %d+%d+%d\n", 1151 dout("prepare_write_message %p seq %lld type %d len %d+%d+%zd\n",
1155 m, con->out_seq, le16_to_cpu(m->hdr.type), 1152 m, con->out_seq, le16_to_cpu(m->hdr.type),
1156 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len), 1153 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len),
1157 le32_to_cpu(m->hdr.data_len)); 1154 m->data_length);
1158 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len); 1155 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
1159 1156
1160 /* tag + hdr + front + middle */ 1157 /* tag + hdr + front + middle */
@@ -1185,8 +1182,8 @@ static void prepare_write_message(struct ceph_connection *con)
1185 1182
1186 /* is there a data payload? */ 1183 /* is there a data payload? */
1187 con->out_msg->footer.data_crc = 0; 1184 con->out_msg->footer.data_crc = 0;
1188 if (m->hdr.data_len) { 1185 if (m->data_length) {
1189 prepare_message_data(con->out_msg); 1186 prepare_message_data(con->out_msg, m->data_length);
1190 con->out_more = 1; /* data + footer will follow */ 1187 con->out_more = 1; /* data + footer will follow */
1191 } else { 1188 } else {
1192 /* no, queue up footer too and be done */ 1189 /* no, queue up footer too and be done */
@@ -2231,7 +2228,7 @@ static int read_partial_message(struct ceph_connection *con)
2231 /* prepare for data payload, if any */ 2228 /* prepare for data payload, if any */
2232 2229
2233 if (data_len) 2230 if (data_len)
2234 prepare_message_data(con->in_msg); 2231 prepare_message_data(con->in_msg, data_len);
2235 } 2232 }
2236 2233
2237 /* front */ 2234 /* front */