From patchwork Fri Apr 5 13:35:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2398561 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D6BEBDF2E5 for ; Fri, 5 Apr 2013 13:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161486Ab3DENf2 (ORCPT ); Fri, 5 Apr 2013 09:35:28 -0400 Received: from mail-ie0-f175.google.com ([209.85.223.175]:59346 "EHLO mail-ie0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161177Ab3DENf2 (ORCPT ); Fri, 5 Apr 2013 09:35:28 -0400 Received: by mail-ie0-f175.google.com with SMTP id c12so4326123ieb.34 for ; Fri, 05 Apr 2013 06:35:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=SCX2OUJhRdlfJlnNKt36XsA7o/GPCXFniefPBiiZsAw=; b=G8Nxt9h4DfsO5IC7UB673HFq4xj8Ud+LD6yve+FBbnevJm8W2WFjPPMCPgAD1ClH5V KFssxd08MekiIbwY4SCVZ6cTkbXNt4vIktDjvNw42wcrznDQD/HU1Ykmc785cgxa1vJr VkMNZzJxXg4lpK96Twd/ogf2zzQNjin+YyO+fZ+T148IT8ioeotkfsOpSeVkOe6wOcqx EvTvS1lWO1U2uboAoACFrGz0gn1QVXBwO7qQvphIisOIEH3QnA9skEjoK7OOnZ8kEju7 p/un2/C/WuGwZM8zFEBFrBD9UQOy4lL1l4sc5nTHqCNx2AErW09lpxa5KdZEBP0H053l I7mA== X-Received: by 10.42.151.3 with SMTP id c3mr5486575icw.27.1365168927821; Fri, 05 Apr 2013 06:35:27 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id ih1sm2323465igc.3.2013.04.05.06.35.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 06:35:27 -0700 (PDT) Message-ID: <515ED31E.4050307@inktank.com> Date: Fri, 05 Apr 2013 08:35:26 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH] libceph: provide data length when preparing message X-Gm-Message-State: ALoCoQkbdu2RFq9+SOR3uUyXlTTdXu7OVlhruEs6M6uvKPmL2JdZXoHTdfOYDs/BbH5i25QbMgrs Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org In prepare_message_data(), the length used to initialize the cursor is taken from the header of the message provided. I'm working toward not using the header data length field to determine length in outbound messages, and this is a step in that direction. For inbound messages this will be set to be the actual number of bytes that arriving (which may be less than the total size of the data buffer available). This resolves: http://tracker.ceph.com/issues/4589 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- net/ceph/messenger.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) /* @@ -1117,6 +1113,7 @@ static void prepare_write_message_footer(struct ceph_connection *con) static void prepare_write_message(struct ceph_connection *con) { struct ceph_msg *m; + u32 data_len; u32 crc; con_out_kvec_reset(con); @@ -1150,11 +1147,12 @@ static void prepare_write_message(struct ceph_connection *con) m->hdr.seq = cpu_to_le64(++con->out_seq); m->needs_out_seq = false; } + data_len = le32_to_cpu(m->hdr.data_len); dout("prepare_write_message %p seq %lld type %d len %d+%d+%d\n", m, con->out_seq, le16_to_cpu(m->hdr.type), le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len), - le32_to_cpu(m->hdr.data_len)); + data_len); BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len); /* tag + hdr + front + middle */ @@ -1185,8 +1183,8 @@ static void prepare_write_message(struct ceph_connection *con) /* is there a data payload? */ con->out_msg->footer.data_crc = 0; - if (m->hdr.data_len) { - prepare_message_data(con->out_msg); + if (data_len) { + prepare_message_data(con->out_msg, data_len); con->out_more = 1; /* data + footer will follow */ } else { /* no, queue up footer too and be done */ @@ -2231,7 +2229,7 @@ static int read_partial_message(struct ceph_connection *con) /* prepare for data payload, if any */ if (data_len) - prepare_message_data(con->in_msg); + prepare_message_data(con->in_msg, data_len); } /* front */ diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index fa9b4d0..78ab83d 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) return new_piece; } -static void prepare_message_data(struct ceph_msg *msg) +static void prepare_message_data(struct ceph_msg *msg, u32 data_len) { - size_t data_len; - BUG_ON(!msg); - - data_len = le32_to_cpu(msg->hdr.data_len); BUG_ON(!data_len); /* Initialize data cursor */ - ceph_msg_data_cursor_init(msg->data, data_len); + ceph_msg_data_cursor_init(msg->data, (size_t) data_len); }