From patchwork Sat Feb 16 17:08:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2152231 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 1EBA93FDF1 for ; Sat, 16 Feb 2013 17:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753847Ab3BPRIS (ORCPT ); Sat, 16 Feb 2013 12:08:18 -0500 Received: from mail-qc0-f176.google.com ([209.85.216.176]:63241 "EHLO mail-qc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753844Ab3BPRIH (ORCPT ); Sat, 16 Feb 2013 12:08:07 -0500 Received: by mail-qc0-f176.google.com with SMTP id n41so1578400qco.35 for ; Sat, 16 Feb 2013 09:08:06 -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 :content-type:content-transfer-encoding:x-gm-message-state; bh=HfpZYlDWq40DFMn6Q9hjuh0FxosQYiUezzkc9rvqBvA=; b=GyrTc1W1WiRV3xeaQvQhQq3QZBNsK8P4jcfUnnwoARzCmlUxF99ukfPzBoUZivhZbn aKlFBrDmQXCEHf0pBhFe/eAX3+j71FaLHAEQcLKT16tXSUKAcle+OQ4yQzRkyUfvz5n/ jLBc2K7r4zq/CiKjIhj/qaSxdJoAFDRMOFwz1BqYeWFbH5VCqkvLMBl89e203sY3ItjU noeuBoN3tVF0PFlKnuNCjiZ9Mx9NLf1Ce2abQ/O3XAksNssWw8E7doMdJK1vn4hElsW8 yc23zZwe6Sh+9tlIuuXSq8o/mUTTwnj2cwjmzRVSmmXML6kb4zfwo1EmyEKpcgUMMO8K eJzA== X-Received: by 10.49.16.9 with SMTP id b9mr2581751qed.16.1361034486785; Sat, 16 Feb 2013 09:08:06 -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 gw9sm21307327qab.10.2013.02.16.09.08.05 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Feb 2013 09:08:05 -0800 (PST) Message-ID: <511FBCF5.7090506@inktank.com> Date: Sat, 16 Feb 2013 11:08:05 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] libceph: simplify data length calculation X-Gm-Message-State: ALoCoQk/CCxf2fVxc3BLpcGA3LCr4yyLXsMQPaEAU0MJFJFxahc3DGWpRKCNAe6gz4JPd7jYvW5X Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Simplify the way the data length recorded in a message header is calculated in ceph_osdc_build_request(). Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- net/ceph/osd_client.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) WARN_ON((flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == 0); @@ -363,8 +363,6 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, while (num_op--) osd_req_encode_op(req, op++, src_op++); - data_len += req->r_trail.length; - if (snapc) { head->snap_seq = cpu_to_le64(snapc->seq); head->num_snaps = cpu_to_le32(snapc->num_snaps); @@ -374,14 +372,12 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, } } + data_len = req->r_trail.length; if (flags & CEPH_OSD_FLAG_WRITE) { req->r_request->hdr.data_off = cpu_to_le16(off); - req->r_request->hdr.data_len = cpu_to_le32(len + data_len); - } else if (data_len) { - req->r_request->hdr.data_off = 0; - req->r_request->hdr.data_len = cpu_to_le32(data_len); + data_len += len; } - + req->r_request->hdr.data_len = cpu_to_le32(data_len); req->r_request->page_alignment = req->r_page_alignment; BUG_ON(p > msg->front.iov_base + msg->front.iov_len); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index bbd1575..b58748e 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -335,7 +335,7 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, void *p; size_t msg_size = sizeof(*head) + num_op*sizeof(*op); int flags = req->r_flags; - u64 data_len = 0; + u64 data_len; int i;