From patchwork Mon Mar 11 05:08:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2246611 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 3FB493FC8F for ; Mon, 11 Mar 2013 05:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751636Ab3CKFIR (ORCPT ); Mon, 11 Mar 2013 01:08:17 -0400 Received: from mail-qe0-f50.google.com ([209.85.128.50]:55504 "EHLO mail-qe0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047Ab3CKFIO (ORCPT ); Mon, 11 Mar 2013 01:08:14 -0400 Received: by mail-qe0-f50.google.com with SMTP id k5so2058915qej.37 for ; Sun, 10 Mar 2013 22:08:13 -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=I2l2FAvADmdldlY9mMqVroOdxshLnqX6wcsYAmmqBhI=; b=CFMOdXutkXcGowd8z34EbNDG+f1XBouDKj34NoS6TjKs5MJDx+2UggF7J+EqtFW4AA H1I4TLfTE90NSbYS4WgVuwwuOTtE1Xq471RBRRuuvVxcswh2aFqtNily90ACdVpodeWQ MWHux0eZQKQZ/OaJDJKVpmBbNohJO/hCbdMGE8DX5qaQdYTJXf3Rn0fh8jwioX/5IFlw HKxJV2vGc6pczuUuybo2Kp0eOl/6ZrqFLvqMGTNAB+8bq9T51B+8gGlmIrYwe+TqaVal fd5q9tGEpWWFFoUG3TlKTS0wKC4C4FO6cGS75AJ7iyVAivFFLs71VJM3QOOf2cfQYZj8 q1EQ== X-Received: by 10.224.42.66 with SMTP id r2mr8566992qae.36.1362978493173; Sun, 10 Mar 2013 22:08:13 -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 fr4sm23847988qab.3.2013.03.10.22.08.11 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 10 Mar 2013 22:08:12 -0700 (PDT) Message-ID: <513D66BA.8010106@inktank.com> Date: Mon, 11 Mar 2013 00:08:10 -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 4/4, v2] libceph: more cleanup of write_partial_msg_pages() References: <513CEE83.4040900@inktank.com> <513CEEE7.2090809@inktank.com> In-Reply-To: <513CEEE7.2090809@inktank.com> X-Gm-Message-State: ALoCoQmIW6PpdlpikrKLqfMjo5MuK+nSG4/hmBUUEiWajnGv5+iTuulDOC8X3VAFEGxIST10eyts Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org I was a little sloppy in dealing with the zero_page case in write_partial_message_data(), and I believe it led to some problems I saw in testing. So I've modified it so the length and last_piece values are calculated correctly, and that's reflected in this updated version of the patch. -Alex Basically all cases in write_partial_msg_pages() use the cursor, and as a result we can simplify that function quite a bit. Signed-off-by: Alex Elder --- v2: fixed length and last_piece calculation for zero_page net/ceph/messenger.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) con, msg, msg_pos->page, msg_pos->page_pos); @@ -1480,36 +1479,29 @@ static int write_partial_message_data(struct ceph_connection *con) * been revoked, so use the zero page. */ while (data_len > msg_pos->data_pos) { - struct page *page = NULL; + struct page *page; size_t page_offset; size_t length; - bool use_cursor = false; - bool last_piece = true; /* preserve existing behavior */ - - total_max_write = data_len - msg_pos->data_pos; + bool last_piece; if (ceph_msg_has_pages(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->p, &page_offset, &length, &last_piece); } else if (ceph_msg_has_pagelist(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->l, &page_offset, &length, &last_piece); #ifdef CONFIG_BLOCK } else if (ceph_msg_has_bio(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->b, &page_offset, &length, &last_piece); #endif } else { - page = zero_page; - } - if (!use_cursor) { - length = min_t(int, PAGE_SIZE - msg_pos->page_pos, - total_max_write); + unsigned int resid = data_len - msg_pos->data_pos; + page = zero_page; page_offset = msg_pos->page_pos; + length = min(resid, PAGE_SIZE - page_offset); + last_piece = length == resid; } if (do_datacrc && !msg_pos->did_page_crc) { u32 crc = le32_to_cpu(msg->footer.data_crc); diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index b7ddf2b..6818c2f 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1466,7 +1466,6 @@ static int write_partial_message_data(struct ceph_connection *con) unsigned int data_len = le32_to_cpu(msg->hdr.data_len); bool do_datacrc = !con->msgr->nocrc; int ret; - int total_max_write; dout("%s %p msg %p page %d offset %d\n", __func__,