From patchwork Wed Mar 13 01:09:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2260591 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 9F3DF3FCF6 for ; Wed, 13 Mar 2013 01:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932473Ab3CMBJX (ORCPT ); Tue, 12 Mar 2013 21:09:23 -0400 Received: from mail-oa0-f41.google.com ([209.85.219.41]:34855 "EHLO mail-oa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932394Ab3CMBJW (ORCPT ); Tue, 12 Mar 2013 21:09:22 -0400 Received: by mail-oa0-f41.google.com with SMTP id i10so528908oag.28 for ; Tue, 12 Mar 2013 18:09:22 -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 :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=hmn0UqE9Pki1p76JhiGbuykJBbRxqhy8BVGaanNG1E0=; b=YPJzMVORlZtG7EZdfcJ/43RGfz+wdgaj/iodqkNWCpZvquBrzmxkqklTGP6aI/broQ PmjLLRhvb6YEi2Y364sjKAj8Jo6q61htp9GnzfgiFhf2gR2D83sZr3EybrGyQlx+PUwT 30O/YMYR411OVJboeWChXns6RCIsLlX7gKotloS6SJLsbZxai32D2hpJpN80MJmQ6X87 fxSna+pcAblI8ad/FUgURV6PzyfuUY/1meCBntZLsGO4ABueRRIROg8IyLsD6vWvyDhp 7aFiMsAZKFVfQ3YwUq8mpz28Lcn5ZNbqzGFSVVDRzDGcDEKld8IjvqVi+FAKw34Gua0w q1Tw== X-Received: by 10.182.169.103 with SMTP id ad7mr14164306obc.51.1363136962189; Tue, 12 Mar 2013 18:09:22 -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 w10sm24537180oed.2.2013.03.12.18.09.17 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Mar 2013 18:09:18 -0700 (PDT) Message-ID: <513FD1BC.4060001@inktank.com> Date: Tue, 12 Mar 2013 20:09:16 -0500 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 1/4] libceph: use cursor resid for loop condition References: <513FD178.60207@inktank.com> In-Reply-To: <513FD178.60207@inktank.com> X-Gm-Message-State: ALoCoQkiP81tJvzSx15SGT6xl6I+nHDyrmrOGq9E3syoOkB8BC8eU1ejGyXUEKJhcXzDJnd65pcJ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Use the "resid" field of a cursor rather than finding when the message data position has moved up to meet the data length to determine when all data has been sent or received in write_partial_message_data() and read_partial_msg_data(). This is cleanup of old code related to: http://tracker.ceph.com/issues/4428 Signed-off-by: Alex Elder --- net/ceph/messenger.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) @@ -1461,7 +1461,7 @@ static int write_partial_message_data(struct ceph_connection *con) * need to map the page. If we have no pages, they have * been revoked, so use the zero page. */ - while (data_len > msg_pos->data_pos) { + while (cursor->resid) { struct page *page; size_t page_offset; size_t length; @@ -1471,7 +1471,6 @@ static int write_partial_message_data(struct ceph_connection *con) &last_piece); if (do_datacrc && !msg_pos->did_page_crc) { u32 crc = le32_to_cpu(msg->footer.data_crc); - crc = ceph_crc32c_page(crc, page, page_offset, length); msg->footer.data_crc = cpu_to_le32(crc); msg_pos->did_page_crc = true; @@ -2131,7 +2130,7 @@ static int read_partial_message_section(struct ceph_connection *con, static int read_partial_msg_data(struct ceph_connection *con) { struct ceph_msg *msg = con->in_msg; - struct ceph_msg_pos *msg_pos = &con->in_msg_pos; + struct ceph_msg_data_cursor *cursor = &msg->data.cursor; const bool do_datacrc = !con->msgr->nocrc; unsigned int data_len; struct page *page; @@ -2144,7 +2143,7 @@ static int read_partial_msg_data(struct ceph_connection *con) return -EIO; data_len = le32_to_cpu(con->in_hdr.data_len); - while (msg_pos->data_pos < data_len) { + while (cursor->resid) { page = ceph_msg_data_next(&msg->data, &page_offset, &length, NULL); ret = ceph_tcp_recvpage(con->sock, page, page_offset, length); diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 30943c1..389dc62 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1442,8 +1442,8 @@ static u32 ceph_crc32c_page(u32 crc, struct page *page, static int write_partial_message_data(struct ceph_connection *con) { struct ceph_msg *msg = con->out_msg; + struct ceph_msg_data_cursor *cursor = &msg->data.cursor; struct ceph_msg_pos *msg_pos = &con->out_msg_pos; - unsigned int data_len = le32_to_cpu(msg->hdr.data_len); bool do_datacrc = !con->msgr->nocrc; int ret;