From patchwork Fri Mar 29 21:31:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2366781 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5E1AFE0143 for ; Fri, 29 Mar 2013 21:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757214Ab3C2Vb5 (ORCPT ); Fri, 29 Mar 2013 17:31:57 -0400 Received: from mail-ia0-f174.google.com ([209.85.210.174]:40555 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757213Ab3C2Vb4 (ORCPT ); Fri, 29 Mar 2013 17:31:56 -0400 Received: by mail-ia0-f174.google.com with SMTP id b35so699346iac.33 for ; Fri, 29 Mar 2013 14:31:55 -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=N6Rf7PITZa/TulhV6tcbwK18fZnO5ALLl9tFhLuxBCk=; b=STTgpF2vfzAsuAiQ2DAgNdWX7TYoZUIxMRLx8vvDLOpfHxSQPr7mWHfAyzknEeLaGA 5uNo8yjHVG6jLUhodBCccPod0s/Up5NwCtcat3dPGWn67TriKwbmkJbxjF4G3Rv4E2X+ 4zg1iHIvTRRKxQV5A5hQ8tlOz9By1obpSGdO0XIpIP4FoDH8xqXraaKSaJt4pqpUd1AX QCWE5KL7o1tlXg+3r4i6mQjcf4Q0JlfwJBsqHtlS3xdIwuI4VHvX8qIybhOl0KD0ecpZ nrr0aJpHzUzTHedxMUqRpck9bwCDKt+MCMDYEsgLckT5jc7FoXTwTB9vL+FEjrW4wgjT rMdg== X-Received: by 10.50.171.228 with SMTP id ax4mr110389igc.73.1364592715729; Fri, 29 Mar 2013 14:31:55 -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 xc3sm257546igb.10.2013.03.29.14.31.54 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Mar 2013 14:31:54 -0700 (PDT) Message-ID: <51560849.9060602@inktank.com> Date: Fri, 29 Mar 2013 16:31:53 -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 1/4] libceph: pass offset and length out of calc_layout() References: <5156080E.9040603@inktank.com> In-Reply-To: <5156080E.9040603@inktank.com> X-Gm-Message-State: ALoCoQnGF37KYssoXtfnzx84yivflvrBoCbgbahbepgUaVek12s1Di049mL8SCjwCIYypzKQfLZ5 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The purpose of calc_layout() is to determine, given a file offset and length and a layout describing the placement of file data across objects, where in "object space" that data resides. Specifically, it determines which object should hold the first part of the specified range of file data, and the offset and length of data within that object. The length will not exceed the bounds of the object, and the caller is informed of that maximum length. Add two parameters to calc_layout() to allow the object-relative offset and length to be passed back to the caller. This is the first steps toward having ceph_osdc_new_request() build its osd op structure using osd_req_op_extent_init(). Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) } @@ -572,7 +571,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, struct ceph_osd_req_op ops[2]; struct ceph_osd_request *req; unsigned int num_op = 1; - u64 bno = 0; + u64 objnum = 0; + u64 objoff = 0; + u64 objlen = 0; int r; memset(&ops, 0, sizeof ops); @@ -593,14 +594,15 @@ 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, &bno); + r = calc_layout(layout, off, plen, ops, &objnum, &objoff, &objlen); if (r < 0) { ceph_osdc_put_request(req); return ERR_PTR(r); } req->r_file_layout = *layout; /* keep a copy */ - snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno); + snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", + vino.ino, objnum); req->r_oid_len = strlen(req->r_oid); ceph_osdc_build_request(req, off, num_op, ops, diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 02ed728..f782aca 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -64,32 +64,31 @@ 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 *bno) + struct ceph_osd_req_op *op, u64 *objnum, + u64 *objoff, u64 *objlen) { u64 orig_len = *plen; - u64 objoff = 0; - u64 objlen = 0; int r; /* object extent? */ - r = ceph_calc_file_object_mapping(layout, off, orig_len, bno, - &objoff, &objlen); + r = ceph_calc_file_object_mapping(layout, off, orig_len, objnum, + objoff, objlen); if (r < 0) return r; - if (objlen < orig_len) { - *plen = objlen; + if (*objlen < orig_len) { + *plen = *objlen; dout(" skipping last %llu, final file extent %llu~%llu\n", 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.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; + op->extent.truncate_size -= off - *objoff; if (op->extent.truncate_size > osize) op->extent.truncate_size = osize; } @@ -97,7 +96,7 @@ static int calc_layout(struct ceph_file_layout *layout, u64 off, u64 *plen, if (op->op == CEPH_OSD_OP_WRITE) op->payload_len = *plen; - dout("calc_layout bno=%llx %llu~%llu\n", *bno, objoff, objlen); + dout("calc_layout objnum=%llx %llu~%llu\n", *objnum, *objoff, *objlen); return 0;