From patchwork Sun Apr 21 21:18:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2469521 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 1BA87DF230 for ; Sun, 21 Apr 2013 21:18:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751930Ab3DUVSD (ORCPT ); Sun, 21 Apr 2013 17:18:03 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:61091 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720Ab3DUVSB (ORCPT ); Sun, 21 Apr 2013 17:18:01 -0400 Received: by mail-ie0-f169.google.com with SMTP id ar20so6537669iec.0 for ; Sun, 21 Apr 2013 14:18:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=4w+/+UntzPdp+7ZvdDcvjAoe0JB3df9Uf/BRTRG8diw=; b=CcVkSnyFNb4DKwZA0SrzNkFmScWMkco2/WoXzei/Tbb8lRt76/qvEe7zYlkacK/iVy fn7kaZu4EsnoGwlnU84c+IoD6Lrjjh+jHYzunFygSZ3KQZgAt7T68HOeTzdICd9tlpFs wInRztflBOe89UPUBgm6EWj2I4smVE9cd3f5EnthlG3HRNAWx+2PH7OP9eXEopV9Pj5d Qoc2VjQZST7r7xPJEVAheZB0tioTAoZm18gSIjJNkpLrEfUz5FB68V4h+kvPuHU++RIl MnNmhq0GsXvSMrP+cje5doccMnxqOxQkUIlNR1hp4oHsf3ekpN/h2UGCjawytXDSainy 1iEw== X-Received: by 10.50.118.33 with SMTP id kj1mr6161984igb.72.1366579081505; Sun, 21 Apr 2013 14:18:01 -0700 (PDT) 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 qs4sm14175008igb.10.2013.04.21.14.18.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 14:18:00 -0700 (PDT) Message-ID: <51745788.5060109@inktank.com> Date: Sun, 21 Apr 2013 16:18:00 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: get and check striping parameters X-Gm-Message-State: ALoCoQkojGY8VwA6vMgcrV3bqwpV1X6v5jJqJ74H/R+8krYj0y72W/I0LgIzZsiiXoPlvRhtises Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If an rbd format 2 image indicates it supports the STRIPINGV2 feature we need to find out its stripe unit and stripe count in order to know whether we can use it. We don't yet support fancy striping fully, but if the default parameters are used the behavior is indistinguishible from non-fancy striping. This is necessary because some images require the STRIPINGV2 feature even if they use the default parameters. (Which is to say the feature bit was erroneously set even if the feature was not used.) This resolves: http://tracker.ceph.com/issues/4709 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) rbd_dev->header.crypt_type = 0; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 3013cdb0..d23cc8f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -317,6 +317,9 @@ struct rbd_device { u64 parent_overlap; struct rbd_device *parent; + u64 stripe_unit; + u64 stripe_count; + /* protects updating the header */ struct rw_semaphore header_rwsem; @@ -3748,6 +3751,56 @@ out_err: return ret; } +static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev) +{ + struct { + __le64 stripe_unit; + __le64 stripe_count; + } __attribute__ ((packed)) striping_info_buf = { 0 }; + size_t size = sizeof (striping_info_buf); + void *p; + u64 obj_size; + u64 stripe_unit; + u64 stripe_count; + int ret; + + ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, + "rbd", "get_stripe_unit_count", NULL, 0, + (char *)&striping_info_buf, size, NULL); + dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); + if (ret < 0) + return ret; + if (ret < size) + return -ERANGE; + + /* + * We don't actually support the "fancy striping" feature + * (STRIPINGV2) yet, but if the striping sizes are the + * defaults the behavior is the same as before. So find + * out, and only fail if the image has non-default values. + */ + ret = -EINVAL; + obj_size = (u64)1 << rbd_dev->header.obj_order; + p = &striping_info_buf; + stripe_unit = ceph_decode_64(&p); + if (stripe_unit != obj_size) { + rbd_warn(rbd_dev, "unsupported stripe unit " + "(got %llu want %llu)", + stripe_unit, obj_size); + return -EINVAL; + } + stripe_count = ceph_decode_64(&p); + if (stripe_count != 1) { + rbd_warn(rbd_dev, "unsupported stripe count " + "(got %llu want 1)", stripe_count); + return -EINVAL; + } + rbd_dev->stripe_unit = stripe_unit; + rbd_dev->stripe_count = stripe_count; + + return 0; +} + static char *rbd_dev_image_name(struct rbd_device *rbd_dev) { size_t image_id_size; @@ -4672,6 +4725,14 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) goto out_err; } + /* If the image supports fancy striping, get its parameters */ + + if (rbd_dev->header.features & RBD_FEATURE_STRIPINGV2) { + ret = rbd_dev_v2_striping_info(rbd_dev); + if (ret < 0) + goto out_err; + } + /* crypto and compression type aren't (yet) supported for v2 images */