From patchwork Tue Feb 14 20:11:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572779 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 E7AE660578 for ; Tue, 14 Feb 2017 20:12:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3B992840E for ; Tue, 14 Feb 2017 20:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8AAE28417; Tue, 14 Feb 2017 20:12:53 +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 840C62840E for ; Tue, 14 Feb 2017 20:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754996AbdBNUMv (ORCPT ); Tue, 14 Feb 2017 15:12:51 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:33464 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754956AbdBNUMo (ORCPT ); Tue, 14 Feb 2017 15:12:44 -0500 Received: by mail-qk0-f194.google.com with SMTP id 11so20554690qkl.0 for ; Tue, 14 Feb 2017 12:12:44 -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=tbTsGGHLCUTT30jjWY8m0EZc3AJX3w8HxkCOMwIgCxs=; b=kKdkVS8aXy3TlWYG1+OA6uHSErUkjO2vjI/xIPYvBCNKQE4UxktKWzYYM2k+78QDNh jT6Hb8+F9X/Mp4kwa0H/muIQbVSvOsQuRD32RPvHgOUrP2DLkeMk/2sChxblAz1P9nXC xexz62oqqoe4deozKnNP1OkioOyPqTTTjez2PBf8nAwUjVxqm5mVzjnJZ7PZefDUq4g1 sNARQg9ylV7XzthCR0v2UkOYaLoISP9DZdckCe2ERl+UIR72DlC6tS4+k6IGjkduVZgX srjAiDDe58YO5X68rx9G5q5S/bUoK2pEjbRw7hUwFvaaekltiZ7DJQ6Lr5ZeGccL69OM Yhig== 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=tbTsGGHLCUTT30jjWY8m0EZc3AJX3w8HxkCOMwIgCxs=; b=DSh5loWpOJpOVBSxI0Cxr95YuCliCyw1BxLREc+5vQtX9cweMGBjAUadMW09ARCGj4 dB9qPbCDGh9UizaAvMY4kD8q6JYYe44iduDaZadXyz+6cNcD0c3OioLaT2K88UBuSyXr XcA8iOK8dYmwH0eROrcOstcz+HycakF2ZszYOWa16YLgyExL4a8PvE0uAREZsPqejT1B E2w/5oYXOu257iB3AAyuwJWxkze1ZzLoyqF13UAuczZYVBnCEyjYmOFSPfGSFq4EAG4c ojQf07aFmjJx22urx2LPf73hTsF37IlZK+OYEPV7PcSxAzbzOZ2jD8BAwlvWn2i/AryS dTNQ== X-Gm-Message-State: AMke39kk5VSKW6V4VOCctwayGn8wAqqjrCE6Nv5zxxfKeUgOmGmeSpE3flfxTOpWxEtZEQ== X-Received: by 10.55.148.133 with SMTP id w127mr32538886qkd.217.1487103163851; Tue, 14 Feb 2017 12:12:43 -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:43 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 10/15] rbd: support for data-pool feature Date: Tue, 14 Feb 2017 21:11:59 +0100 Message-Id: <1487103124-2974-11-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 Add support for RBD_FEATURE_DATA_POOL feature. rbd_dev->layout.pool_id now stores the data pool id. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index aac1d3259738..f01dfdfa5645 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -123,9 +123,11 @@ static int atomic_dec_return_safe(atomic_t *v) #define RBD_FEATURE_LAYERING (1<<0) #define RBD_FEATURE_STRIPINGV2 (1<<1) #define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2) +#define RBD_FEATURE_DATA_POOL (1<<7) #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ RBD_FEATURE_STRIPINGV2 | \ - RBD_FEATURE_EXCLUSIVE_LOCK) + RBD_FEATURE_EXCLUSIVE_LOCK | \ + RBD_FEATURE_DATA_POOL) /* Features supported by this (client software) implementation. */ @@ -146,6 +148,7 @@ struct rbd_image_header { __u8 obj_order; u64 stripe_unit; u64 stripe_count; + s64 data_pool_id; u64 features; /* Might be changeable someday? */ /* The remaining fields need to be updated occasionally */ @@ -989,7 +992,8 @@ static void rbd_init_layout(struct rbd_device *rbd_dev) rbd_dev->layout.stripe_unit = rbd_dev->header.stripe_unit; rbd_dev->layout.stripe_count = rbd_dev->header.stripe_count; rbd_dev->layout.object_size = rbd_obj_bytes(&rbd_dev->header); - rbd_dev->layout.pool_id = rbd_dev->spec->pool_id; + rbd_dev->layout.pool_id = rbd_dev->header.data_pool_id == CEPH_NOPOOL ? + rbd_dev->spec->pool_id : rbd_dev->header.data_pool_id; RCU_INIT_POINTER(rbd_dev->layout.pool_ns, NULL); } @@ -4797,6 +4801,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_client *rbdc, INIT_LIST_HEAD(&rbd_dev->node); init_rwsem(&rbd_dev->header_rwsem); + rbd_dev->header.data_pool_id = CEPH_NOPOOL; ceph_oid_init(&rbd_dev->header_oid); rbd_dev->header_oloc.pool = spec->pool_id; @@ -5161,6 +5166,24 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev) return 0; } +static int rbd_dev_v2_data_pool(struct rbd_device *rbd_dev) +{ + __le64 data_pool_id; + int ret; + + ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, + &rbd_dev->header_oloc, "get_data_pool", + NULL, 0, &data_pool_id, sizeof(data_pool_id)); + if (ret < 0) + return ret; + if (ret < sizeof(data_pool_id)) + return -EBADMSG; + + rbd_dev->header.data_pool_id = le64_to_cpu(data_pool_id); + WARN_ON(rbd_dev->header.data_pool_id == CEPH_NOPOOL); + return 0; +} + static char *rbd_dev_image_name(struct rbd_device *rbd_dev) { CEPH_DEFINE_OID_ONSTACK(oid); @@ -5858,6 +5881,12 @@ static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev) goto out_err; } + if (rbd_dev->header.features & RBD_FEATURE_DATA_POOL) { + ret = rbd_dev_v2_data_pool(rbd_dev); + if (ret) + goto out_err; + } + rbd_init_layout(rbd_dev); return 0;