From patchwork Tue Feb 14 20:12:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572785 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 3E3BE60578 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 3A54E271BC for ; Tue, 14 Feb 2017 20:13:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F345281E1; 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 C57462841C for ; Tue, 14 Feb 2017 20:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755089AbdBNUNG (ORCPT ); Tue, 14 Feb 2017 15:13:06 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:35935 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754983AbdBNUMt (ORCPT ); Tue, 14 Feb 2017 15:12:49 -0500 Received: by mail-qt0-f194.google.com with SMTP id h53so18733987qth.3 for ; Tue, 14 Feb 2017 12:12:49 -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=dT7P4zkk2XNk8Z6U0qWGPaYUJ8LJXJBcZ6opBYeomC0=; b=H7MLa2DN9ZMqWvEG28ioIfykNZiJlKeoFZ3q7toKCU4nXUIMHOpkz53tAIX0hoNTVm w4iYpQYbAu7LQywbGByCT8HWsnsxMEoPoe5R+eVlZoWTC9exg4UHaP1VVG+p7iemVbb1 2UjOT7sZiZd23t1AyUG4gIR483klOhvvITY6cfyjEp4YwmuX1tdqD1K4L6qeX2MjjEjO qU0+XQR3Big4t00+iBGkDZgMkTpeQU1Jwb9eZvmufuThCeIr7eqc7eGFGiy8JhUtrGqa bQ0gvsByNRdbFUk2qW8JyDKDdwfhLP40Fd9V86KqMqAHuFiP5Vst+wzFuDti3zKGx0PO twyw== 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=dT7P4zkk2XNk8Z6U0qWGPaYUJ8LJXJBcZ6opBYeomC0=; b=TKOg2IkCtB48R6FcxCvionP2S4ZTJmZBW5tVzQ2xPe4/BI+f8zIonjRGRt2okbI3N+ XEsCoVuSFS4+oUrJOd7jbNcqEKHSjnEB3JgxTG4rG6KeQAQIP3Esy4qs3ocvVHX54JY7 dMaDVXp6TcvyifL+aj1HSQ+wBrw5gejnLI+obDlS3ticxF1ta9o4+8/b7lSC4eg5IpzB wmIjd0U6cLwmEmg1pWCn5eALFzJMD/sqU/KyuVhko58Ix8kIPviZDPVa8v0B5yRPNjCw uX8rHQoidw4PFue8BShHETT7kqGtcColOUvK37qSO8upXQ7uYsedJcf3JFH4iQuWatdY 8PGg== X-Gm-Message-State: AMke39l4GjJFvxhnF1CzM5kjn8KXaGROyb+ZK/fnYh3g/J9BO8RU9n90NpO3dIrNvZgrNQ== X-Received: by 10.200.45.211 with SMTP id q19mr28423199qta.115.1487103168052; Tue, 14 Feb 2017 12:12:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:12:47 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 14/15] rbd: store and use obj_request->object_no Date: Tue, 14 Feb 2017 21:12:03 +0100 Message-Id: <1487103124-2974-15-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 object_no can be trivially formatted into an object name. We already store object names in OSD requests with special care to avoid dynamic allocations for short names. Storing a name in obj_request, obtained as below (!), is a waste and will be removed in the next commit. name = kmem_cache_alloc(rbd_segment_name_cache, ...); snprintf(name, ...); obj_request->object_name = kstrdup(name); kmem_cache_free(rbd_segment_name_cache, name); ... ceph_oid_aprintf(..., "%s", obj_request->object_name); Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 3bc84afe5b50..3133bb66ce18 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -232,6 +232,7 @@ enum obj_req_flags { struct rbd_obj_request { const char *object_name; + u64 object_no; u64 offset; /* object start byte */ u64 length; /* bytes from offset */ unsigned long flags; @@ -1629,8 +1630,8 @@ 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 \"%s\" %llu~%llu osd_req %p\n", __func__, - obj_request, obj_request->object_name, obj_request->offset, + dout("%s %p object_no %016llx %llu~%llu osd_req %p\n", __func__, + obj_request, obj_request->object_no, 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); @@ -1925,8 +1926,8 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req) rbd_osd_call_callback(obj_request); break; default: - rbd_warn(NULL, "%s: unsupported op %hu", - obj_request->object_name, (unsigned short) opcode); + rbd_warn(NULL, "unexpected OSD op: object_no %016llx opcode %d", + obj_request->object_no, opcode); break; } @@ -1958,6 +1959,8 @@ __rbd_osd_req_create(struct rbd_device *rbd_dev, { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct ceph_osd_request *req; + const char *name_format = rbd_dev->image_format == 1 ? + RBD_V1_DATA_FORMAT : RBD_V2_DATA_FORMAT; req = ceph_osdc_alloc_request(osdc, snapc, num_ops, false, GFP_NOIO); if (!req) @@ -1968,8 +1971,8 @@ __rbd_osd_req_create(struct rbd_device *rbd_dev, req->r_priv = obj_request; req->r_base_oloc.pool = rbd_dev->layout.pool_id; - if (ceph_oid_aprintf(&req->r_base_oid, GFP_NOIO, "%s", - obj_request->object_name)) + if (ceph_oid_aprintf(&req->r_base_oid, GFP_NOIO, name_format, + rbd_dev->header.object_prefix, obj_request->object_no)) goto err_req; if (ceph_osdc_alloc_messages(req, GFP_NOIO)) @@ -2488,6 +2491,7 @@ 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 object_no = img_offset >> rbd_dev->header.obj_order; u64 offset = rbd_segment_offset(rbd_dev, img_offset); u64 length = rbd_segment_length(rbd_dev, img_offset, resid); @@ -2500,6 +2504,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, if (!obj_request) goto out_unwind; + obj_request->object_no = object_no; obj_request->offset = offset; obj_request->length = length; @@ -2846,6 +2851,8 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request) if (!stat_request) return -ENOMEM; + stat_request->object_no = obj_request->object_no; + stat_request->osd_req = rbd_osd_req_create(rbd_dev, OBJ_OP_READ, 1, stat_request); if (!stat_request->osd_req) {