From patchwork Tue Feb 14 20:12:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572783 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 E38E760589 for ; Tue, 14 Feb 2017 20:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E00C0271BC for ; Tue, 14 Feb 2017 20:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D535328415; Tue, 14 Feb 2017 20:13:15 +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 7B7BE281E1 for ; Tue, 14 Feb 2017 20:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755066AbdBNUND (ORCPT ); Tue, 14 Feb 2017 15:13:03 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:33483 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754979AbdBNUMs (ORCPT ); Tue, 14 Feb 2017 15:12:48 -0500 Received: by mail-qk0-f196.google.com with SMTP id 11so20554900qkl.0 for ; Tue, 14 Feb 2017 12:12:47 -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=YIAmd+8RjI0UmEsXABb0VBN3b/5+7JdOXy+sr68Pi7o=; b=tls4OJ0jcmLSM6cbgY1DryM//HXk/TNr6vozHQlzp07ORhgRk07f9JtskM8FVLf/OJ xnQuFLeRyGgncMFKLiS4eGgjMrQicAU2ZsrjhT0iWtyc66KNtKCImq+cUeQ+OkeTPwpW Jxt12TO3H14SaZZztyBAkUAuk3q77WxIBuNMieDMFXHpvygKPz3d7gty9+1Q+H/nimGq EuIZaPosIUlVigrF5McqmQsM5pcekRt+OoZKA+QdRVaD3HYJC+68nIiLBIugc/8C/YKh 41RvV9+z16S/HRkfwQ2h8Q8wHFJJ7hEs/bl93ualeGq1aF7n6BCxPzY+WoxMHg0CIvx6 0IMw== 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=YIAmd+8RjI0UmEsXABb0VBN3b/5+7JdOXy+sr68Pi7o=; b=KQ41TiOeAcKltt00ESUXswXBHh02onGRZZp9GdORHLhjnoitSEIusXA7sy+KlGwibJ ft3QeHT6mwlSEze+5ialw/UOr2AAB+OwoXyizpZdT5D/0TmUhMLTUkh1ybhxNf+/5ANG 5IyK2W5stZRrKekBSaY8WXkJ8NPU1rt909f6pvgUex9UPtsDmgIxyF0FXo0Tb4U5IEr9 JNvO1d2EZGfYGH/msD4X9+k+8mCHVWblhawXh05l8wFHF7Hbml+491WdUR8Bk+k6UoHP qCUW4rNicRKqnTNbT69jMFjnL7YW64wI8VDmYRT1J/ogaf2BkQfpi4p173eBtJB6X2tz bPDA== X-Gm-Message-State: AMke39kraG37QQRhPs4sI/r+J95vJj6zgxZfVqySET/AjftVrIvR6H0m5x1kqnBCIEGfBA== X-Received: by 10.55.91.71 with SMTP id p68mr31483760qkb.172.1487103166966; Tue, 14 Feb 2017 12:12:46 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:12:46 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 13/15] rbd: RBD_V{1,2}_DATA_FORMAT macros Date: Tue, 14 Feb 2017 21:12:02 +0100 Message-Id: <1487103124-2974-14-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 ... and also fix up the comment -- format 1 data objects have always been 12 hex digits long. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 6 ++---- drivers/block/rbd_types.h | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 47cfd5d89e69..3bc84afe5b50 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1257,18 +1257,16 @@ static void rbd_segment_name_free(const char *name) static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) { + const char *name_format = rbd_dev->image_format == 1 ? + RBD_V1_DATA_FORMAT : RBD_V2_DATA_FORMAT; char *name; u64 segment; int ret; - char *name_format; name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO); if (!name) return NULL; segment = offset >> rbd_dev->header.obj_order; - name_format = "%s.%012llx"; - if (rbd_dev->image_format == 2) - name_format = "%s.%016llx"; ret = snprintf(name, CEPH_MAX_OID_NAME_LEN + 1, name_format, rbd_dev->header.object_prefix, segment); if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) { diff --git a/drivers/block/rbd_types.h b/drivers/block/rbd_types.h index be9c76d292f5..0a15ca3aa0f1 100644 --- a/drivers/block/rbd_types.h +++ b/drivers/block/rbd_types.h @@ -25,8 +25,8 @@ */ #define RBD_HEADER_PREFIX "rbd_header." -#define RBD_DATA_PREFIX "rbd_data." #define RBD_ID_PREFIX "rbd_id." +#define RBD_V2_DATA_FORMAT "%s.%016llx" #define RBD_LOCK_NAME "rbd_lock" #define RBD_LOCK_TAG "internal" @@ -42,13 +42,14 @@ enum rbd_notify_op { /* * For format version 1, rbd image 'foo' consists of objects * foo.rbd - image metadata - * rb...00000000 - * rb...00000001 + * rb...000000000000 + * rb...000000000001 * ... - data * There is no notion of a persistent image id in rbd format 1. */ #define RBD_SUFFIX ".rbd" +#define RBD_V1_DATA_FORMAT "%s.%012llx" #define RBD_DIRECTORY "rbd_directory" #define RBD_INFO "rbd_info"