From patchwork Sat Mar 9 16:43:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2241951 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 167593FCF6 for ; Sat, 9 Mar 2013 16:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879Ab3CIQoC (ORCPT ); Sat, 9 Mar 2013 11:44:02 -0500 Received: from mail-ia0-f179.google.com ([209.85.210.179]:42090 "EHLO mail-ia0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932846Ab3CIQoB (ORCPT ); Sat, 9 Mar 2013 11:44:01 -0500 Received: by mail-ia0-f179.google.com with SMTP id x24so2384706iak.24 for ; Sat, 09 Mar 2013 08:44:00 -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=My5FMZauiTVWtnp0rqnDZKKl+t5yuv9LamiALOeyiYc=; b=K/54H0sCMkIYHTudbw5zROrwO8S01Qw9HQ5aMBkWkgV5DlAToTFUbwC/YFH3n55Zel z0WwMIfaqXASbdSA4sLKzUs0Da2mKCHb0QCguww0WLrmqlc0IOR7+IXaPgMBpxWFXVYR QN62bUm7f+OehIAd5eQU6xZvNORnWpSN8JMCI+QsNN7ak0PCsagzkAvc1nz5sDXggoX8 DuJF46QNzirhFVEAVhLOwPWvsTDaG6ztoB5ofR01xEo05lLHABnIYCtC68EHDmfnnBmw bcMiKkMEJj77w9rakMj073wzX/4u7bJ7Y9Vbxyp72nJ5HjJ4PVB4P+B7FY3Uod3jddB6 1OxQ== X-Received: by 10.50.108.235 with SMTP id hn11mr2590049igb.107.1362847440611; Sat, 09 Mar 2013 08:44:00 -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 uy13sm4839653igb.7.2013.03.09.08.43.58 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 09 Mar 2013 08:43:59 -0800 (PST) Message-ID: <513B66CE.2000609@inktank.com> Date: Sat, 09 Mar 2013 10:43:58 -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 6/6] libceph: define and use ceph_crc32c_page() References: <513B661F.4050203@inktank.com> In-Reply-To: <513B661F.4050203@inktank.com> X-Gm-Message-State: ALoCoQml+S9OGbh3PXZSswiLWUk2B8IiCrWw+i6AdXEq6FKmrX3nKWtMtulkPNaLl74kJonNIhCd Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Factor out a common block of code that updates a CRC calculation over a range of data in a page. This and the preceding patches are related to: http://tracker.ceph.com/issues/4403 Signed-off-by: Alex Elder --- net/ceph/messenger.c | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) * up the footer. @@ -1153,15 +1166,9 @@ static int write_partial_message_data(struct ceph_connection *con) page_offset = msg_pos->page_pos + bio_offset; if (do_datacrc && !msg_pos->did_page_crc) { - void *base; u32 crc = le32_to_cpu(msg->footer.data_crc); - char *kaddr; - kaddr = kmap(page); - BUG_ON(kaddr == NULL); - base = kaddr + page_offset; - crc = crc32c(crc, base, length); - kunmap(page); + crc = ceph_crc32c_page(crc, page, page_offset, length); msg->footer.data_crc = cpu_to_le32(crc); msg_pos->did_page_crc = true; } @@ -1843,16 +1850,9 @@ static int read_partial_message_pages(struct ceph_connection *con, if (ret <= 0) return ret; - if (do_datacrc) { - void *kaddr; - void *base; - - kaddr = kmap(page); - BUG_ON(!kaddr); - base = kaddr + page_offset; - con->in_data_crc = crc32c(con->in_data_crc, base, ret); - kunmap(page); - } + if (do_datacrc) + con->in_data_crc = ceph_crc32c_page(con->in_data_crc, page, + page_offset, ret); in_msg_pos_next(con, length, ret); @@ -1886,16 +1886,9 @@ static int read_partial_message_bio(struct ceph_connection *con, if (ret <= 0) return ret; - if (do_datacrc) { - void *kaddr; - void *base; - - kaddr = kmap(page); - BUG_ON(!kaddr); - base = kaddr + page_offset; - con->in_data_crc = crc32c(con->in_data_crc, base, ret); - kunmap(page); - } + if (do_datacrc) + con->in_data_crc = ceph_crc32c_page(con->in_data_crc, page, + page_offset, ret); in_msg_pos_next(con, length, ret); diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 7df7941..e677fd3 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1085,6 +1085,19 @@ static void in_msg_pos_next(struct ceph_connection *con, size_t len, #endif /* CONFIG_BLOCK */ } +static u32 ceph_crc32c_page(u32 crc, struct page *page, + unsigned int page_offset, + unsigned int length) +{ + char *kaddr; + + kaddr = kmap(page); + BUG_ON(kaddr == NULL); + crc = crc32c(crc, kaddr + page_offset, length); + kunmap(page); + + return crc; +} /* * Write as much message data payload as we can. If we finish, queue