From patchwork Sat Mar 9 16:42:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2241911 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6E6153FCF6 for ; Sat, 9 Mar 2013 16:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932735Ab3CIQmx (ORCPT ); Sat, 9 Mar 2013 11:42:53 -0500 Received: from mail-ie0-f176.google.com ([209.85.223.176]:51995 "EHLO mail-ie0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932441Ab3CIQmx (ORCPT ); Sat, 9 Mar 2013 11:42:53 -0500 Received: by mail-ie0-f176.google.com with SMTP id k13so3226942iea.35 for ; Sat, 09 Mar 2013 08:42:53 -0800 (PST) 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 :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=HfSbTs2bZ0u8Ma+GqC+LkcuQs5cvfcf7J5u88oQNEMg=; b=ohX7LwHX1n0ojO06HCPL0PyIRKrKp5VHKIu3/2iwCrTDWsU+RhT0PXBg8zoOX2gPWD T//hMSzmesB2CP8jnq3jXYpUEA9wMdzLI1nBxMlganhUb61O636es6h58jcqOPSrwxjK dySD+0UwI4BicX1asfppECtuBtZjyUa+RXo+h5eZ1BWLFZNWgok5a7QGe/Es/XFXUPqp zA7NonYORS4QFrcyluc8o4YjCn3pj8kTNdYM/xF1NNGd/I71EJUB0lBwf7+emnjUGkbF qcxhT/bo/G5haBSBlfu7t9yKpLLa2b1XZ4N7rdqa38GoMEzitoeg1j+2m6sf72CCUDTC HMFQ== X-Received: by 10.50.149.233 with SMTP id ud9mr2772269igb.92.1362847373052; Sat, 09 Mar 2013 08:42:53 -0800 (PST) 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 px9sm7541912igc.0.2013.03.09.08.42.51 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 09 Mar 2013 08:42:52 -0800 (PST) Message-ID: <513B668B.2090305@inktank.com> Date: Sat, 09 Mar 2013 10:42:51 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 2/6] libceph: consolidate message prep code References: <513B661F.4050203@inktank.com> In-Reply-To: <513B661F.4050203@inktank.com> X-Gm-Message-State: ALoCoQnz3a1+K+eKz56JXk/ecLOFySEIfnzOcemZnC3Qp5PmXde68OZTQqwt9kalyH2Lw87P3RHU Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org In prepare_write_message_data(), various fields are initialized in preparation for writing message data out. Meanwhile, in read_partial_message(), there is essentially the same block of code, operating on message variables associated with an incoming message. Generalize prepare_write_message_data() so it works for both incoming and outcoming messages, and use it in both spots. The did_page_crc is not used for input (so it's harmless to initialize it). Signed-off-by: Alex Elder --- net/ceph/messenger.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) @@ -742,7 +740,6 @@ static void prepare_write_message_data(struct ceph_connection *con) #endif msg_pos->data_pos = 0; msg_pos->did_page_crc = false; - con->out_more = 1; /* data + footer will follow */ } /* @@ -840,11 +837,13 @@ 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_write_message_data(con); - else + if (m->hdr.data_len) { + prepare_message_data(con->out_msg, &con->out_msg_pos); + con->out_more = 1; /* data + footer will follow */ + } else { /* no, queue up footer too and be done */ prepare_write_message_footer(con); + } con_flag_set(con, CON_FLAG_WRITE_PENDING); } @@ -1956,17 +1955,10 @@ static int read_partial_message(struct ceph_connection *con) if (m->middle) m->middle->vec.iov_len = 0; - msg_pos->page = 0; - if (m->pages) - msg_pos->page_pos = m->page_alignment; - else - msg_pos->page_pos = 0; - msg_pos->data_pos = 0; + /* prepare for data payload, if any */ -#ifdef CONFIG_BLOCK - if (m->bio) - init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg); -#endif + if (data_len) + prepare_message_data(con->in_msg, &con->in_msg_pos); } /* front */ diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 7788170..e8fa449 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -722,11 +722,9 @@ static void iter_bio_next(struct bio **bio_iter, unsigned int *seg) } #endif -static void prepare_write_message_data(struct ceph_connection *con) +static void prepare_message_data(struct ceph_msg *msg, + struct ceph_msg_pos *msg_pos) { - struct ceph_msg *msg = con->out_msg; - struct ceph_msg_pos *msg_pos = &con->out_msg_pos; - BUG_ON(!msg); BUG_ON(!msg->hdr.data_len);