From patchwork Tue May 7 01:52:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2529831 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5D8213FD85 for ; Tue, 7 May 2013 01:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759552Ab3EGBwf (ORCPT ); Mon, 6 May 2013 21:52:35 -0400 Received: from mail-ve0-f174.google.com ([209.85.128.174]:45762 "EHLO mail-ve0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759546Ab3EGBwe (ORCPT ); Mon, 6 May 2013 21:52:34 -0400 Received: by mail-ve0-f174.google.com with SMTP id pb11so41923veb.19 for ; Mon, 06 May 2013 18:52:34 -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 :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=tJT2WOZWbZMC0c0AuMQ5aqeG2WAqd1nAhIg9Uv1oPkE=; b=O6kiD4S2kT9FL3A+38EHFk8k8OCl7YXZ70uxegi8yvxYPeN33UEaPu/AwHGrLwMBVo ViRnM4BnZ4X4z9/kdZXNnr1aMyBQW5e1M+HscBqjsAFIwhU5r+fO7lGD5MS1IMm7WgJR 6swnl6InD36Y/c3RbtUsWVH2YQysd4tQzAP6tACKFcKRAqig33kZEQj2Vs4wDdOgvM4i BlW0jeWlNCEYorvr+W63EEIN+rAfNJIvH/liTO42PRVCb7FUAMJj7P0xVTbgJbZGPlFO BrJTcF4DN84O0VjafK3Yfig1oi8Ve4yttuIh33FObkr8bCLx4cKxyP1ct551uGCFjqAa xfeA== X-Received: by 10.52.74.35 with SMTP id q3mr6738954vdv.39.1367891553979; Mon, 06 May 2013 18:52:33 -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 ESMTPSA id q5sm19483918vdj.5.2013.05.06.18.52.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 18:52:33 -0700 (PDT) Message-ID: <51885E60.2010902@inktank.com> Date: Mon, 06 May 2013 20:52:32 -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 1/7] rbd: set the mapping size and features later References: <51885E06.8020201@inktank.com> In-Reply-To: <51885E06.8020201@inktank.com> X-Gm-Message-State: ALoCoQnannWL7MluHRdGdWqS92GZU4iOfjQWQY3qm1qUIw8kmlgW3Wg+bDq/0Umf/nPSoQZG5hBp Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Defer setting the size and features fields of a mapped image until after the Linux disk structure is set up. Set the capacity of the disk after that. Rearrange the definition of rbd_image_header, separating the fields that are set only once from those that can be updated. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) @@ -4662,13 +4657,17 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) if (ret) goto err_out_blkdev; - ret = rbd_bus_add_dev(rbd_dev); + ret = rbd_dev_mapping_set(rbd_dev); if (ret) goto err_out_disk; + set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); + + ret = rbd_bus_add_dev(rbd_dev); + if (ret) + goto err_out_mapping; /* Everything's ready. Announce the disk to the world. */ - set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); add_disk(rbd_dev->disk); @@ -4677,6 +4676,8 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) return ret; +err_out_mapping: + rbd_dev_mapping_clear(rbd_dev); err_out_disk: rbd_free_disk(rbd_dev); err_out_blkdev: diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0c72643..357a11f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -100,21 +100,20 @@ * block device image metadata (in-memory version) */ struct rbd_image_header { - /* These four fields never change for a given rbd image */ + /* These six fields never change for a given rbd image */ char *object_prefix; - u64 features; __u8 obj_order; __u8 crypt_type; __u8 comp_type; + u64 stripe_unit; + u64 stripe_count; + u64 features; /* Might be changeable someday? */ /* The remaining fields need to be updated occasionally */ u64 image_size; struct ceph_snap_context *snapc; - char *snap_names; - u64 *snap_sizes; - - u64 stripe_unit; - u64 stripe_count; + char *snap_names; /* format 1 only */ + u64 *snap_sizes; /* format 1 only */ }; /* @@ -4637,10 +4636,6 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) { int ret; - ret = rbd_dev_mapping_set(rbd_dev); - if (ret) - return ret; - /* generate unique id: find highest unique id, add one */ rbd_dev_id_get(rbd_dev);