From patchwork Tue Nov 20 19:57:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1775401 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 AD3D3DFF38 for ; Tue, 20 Nov 2012 19:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184Ab2KTT5a (ORCPT ); Tue, 20 Nov 2012 14:57:30 -0500 Received: from mail-ia0-f174.google.com ([209.85.210.174]:58830 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091Ab2KTT5a (ORCPT ); Tue, 20 Nov 2012 14:57:30 -0500 Received: by mail-ia0-f174.google.com with SMTP id y25so4506049iay.19 for ; Tue, 20 Nov 2012 11:57:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=3Ci7ZnVdHiY2HvPDKNXveFGJDwcEAJnZE0EU8cSsgEw=; b=B9mM1weXx2XZaIeWb564xRDYw7QTW2X4NkIS/NmmvecMyONLV+VbRoElGQ9qhTlKlY WR0DqquI51SdDJlQwnHA9PTrHBSRA2bUdzKbSZb/nXNamsGAhL0lC/r0OoLof5Mri1D9 /UrNgzSPoUTPDrcaVxh+wZqVKPqOc1qjTAw/9nLjTD2Wxmxj8Eh/WE36w03mNnfGC8kR 4Z1OSLRnAQxMhi8JYqlwAkE0WUA4HPUaqO/rD5ZZ7MKP2UIPkFpSgo5XBhj3qzNA7K2w oAwW1cCuGVfGpdeLhPh8qEbNsI/F9hsnBNNE1RGP+xddnjIkjmj+26jXeiAAp8Xleho7 XLGQ== Received: by 10.50.190.130 with SMTP id gq2mr11175379igc.26.1353441449760; Tue, 20 Nov 2012 11:57:29 -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 uj6sm11147797igb.4.2012.11.20.11.57.22 (version=SSLv3 cipher=OTHER); Tue, 20 Nov 2012 11:57:28 -0800 (PST) Message-ID: <50ABE0A2.8080205@inktank.com> Date: Tue, 20 Nov 2012 13:57:22 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 3/6] rbd: initialize off and len in rbd_create_rw_op() References: <50ABDF8A.4080206@inktank.com> In-Reply-To: <50ABDF8A.4080206@inktank.com> X-Gm-Message-State: ALoCoQkBPNYeZmIYoQZEklJR8zhzqql557reF1QNEyNKNDZT/FhW55vtGZV+hH/7rktp7JHdnnmX Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Move the initialization of a read or write operation's offset, length, and payload length fields into rbd_create_rw_op(). This will actually get removed in the next patch, but it finishes the consolidation of setting these fields at osd op creation time. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) return op; } @@ -1297,7 +1301,6 @@ static int rbd_do_op(struct request *rq, u64 seg_len; int ret; struct ceph_osd_req_op *op; - u32 payload_len; int opcode; int flags; u64 snapid; @@ -1312,22 +1315,17 @@ static int rbd_do_op(struct request *rq, opcode = CEPH_OSD_OP_WRITE; flags = CEPH_OSD_FLAG_WRITE|CEPH_OSD_FLAG_ONDISK; snapid = CEPH_NOSNAP; - payload_len = seg_len; } else { opcode = CEPH_OSD_OP_READ; flags = CEPH_OSD_FLAG_READ; rbd_assert(!snapc); snapid = rbd_dev->spec->snap_id; - payload_len = 0; } ret = -ENOMEM; - op = rbd_create_rw_op(opcode, payload_len); + op = rbd_create_rw_op(opcode, seg_ofs, seg_len); if (!op) goto done; - op->extent.offset = seg_ofs; - op->extent.length = seg_len; - op->payload_len = payload_len; /* we've taken care of segment sizes earlier when we cloned the bios. We should never have a segment @@ -1363,12 +1361,9 @@ static int rbd_req_sync_read(struct rbd_device *rbd_dev, struct ceph_osd_req_op *op; int ret; - op = rbd_create_rw_op(CEPH_OSD_OP_READ, 0); + op = rbd_create_rw_op(CEPH_OSD_OP_READ, ofs, len); if (!op) return -ENOMEM; - op->extent.offset = ofs; - op->extent.length = len; - op->payload_len = 0; ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, op, object_name, ofs, len, buf, NULL, ver); @@ -1387,7 +1382,7 @@ static int rbd_req_sync_notify_ack(struct rbd_device *rbd_dev, struct ceph_osd_req_op *op; int ret; - op = rbd_create_rw_op(CEPH_OSD_OP_NOTIFY_ACK, 0); + op = rbd_create_rw_op(CEPH_OSD_OP_NOTIFY_ACK, 0, 0); if (!op) return -ENOMEM; @@ -1438,7 +1433,7 @@ static int rbd_req_sync_watch(struct rbd_device *rbd_dev, int start) __le64 version = 0; int ret; - op = rbd_create_rw_op(CEPH_OSD_OP_WATCH, 0); + op = rbd_create_rw_op(CEPH_OSD_OP_WATCH, 0, 0); if (!op) return -ENOMEM; @@ -1501,9 +1496,10 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev, * operation. */ payload_size = class_name_len + method_name_len + outbound_size; - op = rbd_create_rw_op(CEPH_OSD_OP_CALL, payload_size); + op = rbd_create_rw_op(CEPH_OSD_OP_CALL, 0, 0); if (!op) return -ENOMEM; + op->payload_len = payload_size; op->cls.class_name = class_name; op->cls.class_len = (__u8) class_name_len; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b2e819c..54d11c9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1025,19 +1025,23 @@ out_err: return NULL; } -static struct ceph_osd_req_op *rbd_create_rw_op(int opcode, u32 payload_len) +static struct ceph_osd_req_op *rbd_create_rw_op(int opcode, u64 ofs, u64 len) { struct ceph_osd_req_op *op; op = kzalloc(sizeof (*op), GFP_NOIO); if (!op) return NULL; - /* - * op extent offset and length will be set later on - * after ceph_calc_file_object_mapping(). - */ + op->op = opcode; - op->payload_len = payload_len; + if (opcode == CEPH_OSD_OP_READ || opcode == CEPH_OSD_OP_WRITE) { + op->extent.offset = ofs; + op->extent.length = len; + if (opcode == CEPH_OSD_OP_WRITE) { + rbd_assert(len <= (u64) U32_MAX); + op->payload_len = len; + } + }