From patchwork Fri Mar 29 21:32:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2366791 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 D59F93FD40 for ; Fri, 29 Mar 2013 21:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757223Ab3C2VcK (ORCPT ); Fri, 29 Mar 2013 17:32:10 -0400 Received: from mail-ia0-f173.google.com ([209.85.210.173]:45547 "EHLO mail-ia0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757216Ab3C2VcI (ORCPT ); Fri, 29 Mar 2013 17:32:08 -0400 Received: by mail-ia0-f173.google.com with SMTP id h37so697079iak.32 for ; Fri, 29 Mar 2013 14:32:08 -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=2tfdHJq3yDGWnrAFjogWeQrGDUhFxA7LMV4oBO8A9co=; b=c7TxE3SJ4BnE3RbR5N0Xtj6dgLmh0vNPCmNB7UgZgUf5ClfGEXh/TEsiTj6NE4Wf/z 0fVslh2ejVRAAtFGeHondiDfKeCe21kpO9Dyor6qdF9d8gT7uK+GXg0Y4w+RobXwErgd VUihMSFvx5RVjYW4/PZ67HmruTcqR9gTkEvgnNQgskc6zzxe/wXl5Lgs3WRnZfsksdbj 730RR2UkyF1ilykKtxdg4iqa1v7uaVOHWewwsUHu29iOmFQQGo8DToqwca/DWYDLGV30 tDDzk3HhHtoltfz5HvO3cHKVqWk/DfUU/ERAdd/RpSoHFG8EBJsDvC1VhHvEF03eq6gH hNyA== X-Received: by 10.50.13.175 with SMTP id i15mr74013igc.105.1364592728505; Fri, 29 Mar 2013 14:32:08 -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 p11sm283629igr.4.2013.03.29.14.32.07 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Mar 2013 14:32:07 -0700 (PDT) Message-ID: <51560856.4070805@inktank.com> Date: Fri, 29 Mar 2013 16:32:06 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 2/4] libceph: don't update op in calc_layout() References: <5156080E.9040603@inktank.com> In-Reply-To: <5156080E.9040603@inktank.com> X-Gm-Message-State: ALoCoQmkdRry14OgpFK9wmndh31gPimEMC+VTfgRKAU1qk/ayFq8sA6wTLCA4UUKGRUgyECETD/i Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The ceph_osdc_new_request() an array of osd operations is built up and filled in partially within that function and partially in the called function calc_layout(). Move the latter part back out to ceph_osdc_new_request() so it's all done in one place. This makes it unnecessary to pass the op pointer to calc_layout(), so get rid of that parameter. Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) return 0; @@ -594,11 +578,27 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, req->r_flags = flags; /* calculate max write size */ - r = calc_layout(layout, off, plen, ops, &objnum, &objoff, &objlen); + r = calc_layout(layout, off, plen, &objnum, &objoff, &objlen); if (r < 0) { ceph_osdc_put_request(req); return ERR_PTR(r); } + + if (op_has_extent(ops[0].op)) { + u32 osize = le32_to_cpu(layout->fl_object_size); + ops[0].extent.offset = objoff; + ops[0].extent.length = objlen; + if (ops[0].extent.truncate_size <= off - objoff) { + ops[0].extent.truncate_size = 0; + } else { + ops[0].extent.truncate_size -= off - objoff; + if (ops[0].extent.truncate_size > osize) + ops[0].extent.truncate_size = osize; + } + } + if (ops[0].op == CEPH_OSD_OP_WRITE) + ops[0].payload_len = *plen; + req->r_file_layout = *layout; /* keep a copy */ snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index f782aca..0eb417b 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -64,8 +64,7 @@ static int op_has_extent(int op) * fill osd op in request message. */ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, - struct ceph_osd_req_op *op, u64 *objnum, - u64 *objoff, u64 *objlen) + u64 *objnum, u64 *objoff, u64 *objlen) { u64 orig_len = *plen; int r; @@ -81,21 +80,6 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, orig_len - *plen, off, *plen); } - if (op_has_extent(op->op)) { - u32 osize = le32_to_cpu(layout->fl_object_size); - op->extent.offset = *objoff; - op->extent.length = *objlen; - if (op->extent.truncate_size <= off - *objoff) { - op->extent.truncate_size = 0; - } else { - op->extent.truncate_size -= off - *objoff; - if (op->extent.truncate_size > osize) - op->extent.truncate_size = osize; - } - } - if (op->op == CEPH_OSD_OP_WRITE) - op->payload_len = *plen; - dout("calc_layout objnum=%llx %llu~%llu\n", *objnum, *objoff, *objlen);