From patchwork Tue Feb 14 20:12:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E7FC60589 for ; Tue, 14 Feb 2017 20:13:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AD70271BC for ; Tue, 14 Feb 2017 20:13:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FCD0281E1; Tue, 14 Feb 2017 20:13:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5BC228417 for ; Tue, 14 Feb 2017 20:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755092AbdBNUNH (ORCPT ); Tue, 14 Feb 2017 15:13:07 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:35515 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754994AbdBNUMv (ORCPT ); Tue, 14 Feb 2017 15:12:51 -0500 Received: by mail-qt0-f195.google.com with SMTP id s58so18789594qtc.2 for ; Tue, 14 Feb 2017 12:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1tNc650FGKCkt0AnP1DEb63IU7Fe0aDiM1+dL1kXONw=; b=i7SFjD2MG/JVgof4g/5clq4T8vrHtsavKmuUOGsCS5Czn9L8M/98PSJKJZWJPnjk59 r3efvoToP6UeXvLdNGc3rglaAL9fppR9MldKNclQOVt7PJi+tO/FJquLyL/+tYIUV6ko kgjxmolNfvfEYypqv9bMs4pEIdzNymUAo7o7I3HiuIXUd9mxk1mj1sL3wNrx/7nudNYr k/f1S9+Sqvhe1j5UMhi3oZ9FF5gDT8zAK5dYwdBiDTglUamyDJMg/SVaJ25F34wlydPJ cOdAfmUVhbjdUxIx3ilVp3tBqDnjmaHe6EwNGgAz1pU4UxRm7gyIA2MRdA3sVHx8CalF jKJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1tNc650FGKCkt0AnP1DEb63IU7Fe0aDiM1+dL1kXONw=; b=CUiNYlghi0cp0oAO+SJwRVgcAp861nDb6YJ1cEe43mcdgI1sUXDsa2OpMUYOLceoga +Gtu6oTJ61zWhnV07KQFzO7ciL6lS+sUBxMTdpmBlkewB71TtE2+lJkXet1rRWHlDtW/ K4zZmiUJzbSIydCof1vdUNZsf4DWLmLw9mKRsdzpnvQrootfYgQxel4x6fBbygCxrpZF dtZL4u3dRXuWoyPDp7osj8kXgqvGUSSy77R5dN82kYh8WWhY1DFHUqe6+0ktXPmEiLd/ F025Im4ArQXw10KPU+pgtHTJK8rpeAboA1CmVkUN4c/jnH9y3Fzsve5M+7cQXBR0zehi FSZQ== X-Gm-Message-State: AMke39l02SDp0YIi5UmB8T7wRUwpV2zdb6djGMBEBlz6cTIx4hklHM7aMXdxkHNVglbnzw== X-Received: by 10.237.35.210 with SMTP id k18mr28021461qtc.219.1487103164821; Tue, 14 Feb 2017 12:12:44 -0800 (PST) Received: from dhcp-1-235.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id w138sm939945qka.27.2017.02.14.12.12.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:12:44 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 11/15] rbd: set offset and length outside of rbd_obj_request_create() Date: Tue, 14 Feb 2017 21:12:00 +0100 Message-Id: <1487103124-2974-12-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1487103124-2974-1-git-send-email-idryomov@gmail.com> References: <1487103124-2974-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The allocation doesn't depend on offset and length. Both offset and length can be changed after obj_request is allocated, too. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index f01dfdfa5645..ea60d238ca55 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1631,7 +1631,9 @@ static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) { struct ceph_osd_request *osd_req = obj_request->osd_req; - dout("%s %p osd_req %p\n", __func__, obj_request, osd_req); + dout("%s %p \"%s\" %llu~%llu osd_req %p\n", __func__, + obj_request, obj_request->object_name, obj_request->offset, + obj_request->length, osd_req); if (obj_request_img_data_test(obj_request)) { WARN_ON(obj_request->callback != rbd_img_obj_callback); rbd_img_request_get(obj_request->img_request); @@ -2073,7 +2075,6 @@ static void rbd_osd_req_destroy(struct ceph_osd_request *osd_req) /* object_name is assumed to be a non-null pointer and NUL-terminated */ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, - u64 offset, u64 length, enum obj_request_type type) { struct rbd_obj_request *obj_request; @@ -2094,18 +2095,13 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, } obj_request->object_name = memcpy(name, object_name, size); - obj_request->offset = offset; - obj_request->length = length; - obj_request->flags = 0; obj_request->which = BAD_WHICH; obj_request->type = type; INIT_LIST_HEAD(&obj_request->links); init_completion(&obj_request->completion); kref_init(&obj_request->kref); - dout("%s: \"%s\" %llu/%llu %d -> obj %p\n", __func__, object_name, - offset, length, (int)type, obj_request); - + dout("%s %p\n", __func__, obj_request); return obj_request; } @@ -2517,21 +2513,21 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, while (resid) { struct ceph_osd_request *osd_req; const char *object_name; - u64 offset; - u64 length; + u64 offset = rbd_segment_offset(rbd_dev, img_offset); + u64 length = rbd_segment_length(rbd_dev, img_offset, resid); object_name = rbd_segment_name(rbd_dev, img_offset); if (!object_name) goto out_unwind; - offset = rbd_segment_offset(rbd_dev, img_offset); - length = rbd_segment_length(rbd_dev, img_offset, resid); - obj_request = rbd_obj_request_create(object_name, - offset, length, type); + obj_request = rbd_obj_request_create(object_name, type); /* object request has its own copy of the object name */ rbd_segment_name_free(object_name); if (!obj_request) goto out_unwind; + obj_request->offset = offset; + obj_request->length = length; + /* * set obj_request->img_request before creating the * osd_request so that it gets the right snapc @@ -2870,7 +2866,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request) size_t size; int ret; - stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0, + stat_request = rbd_obj_request_create(obj_request->object_name, OBJ_REQUEST_PAGES); if (!stat_request) return -ENOMEM;