From patchwork Wed Jul 11 14:01:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1182711 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 0B664E0008 for ; Wed, 11 Jul 2012 14:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932724Ab2GKOB4 (ORCPT ); Wed, 11 Jul 2012 10:01:56 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:58247 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932723Ab2GKOBy (ORCPT ); Wed, 11 Jul 2012 10:01:54 -0400 Received: by ghrr11 with SMTP id r11so1225639ghr.19 for ; Wed, 11 Jul 2012 07:01:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=NdZrRcktk/0TzgWBn4Tnmjz6nYWGFAC9wg9GSg6wyfs=; b=LxFfvgj/Uw26fi/mqavTMCxCrmKL/Vw6LqVGG3HDJanU+U3xKYb8YMZdV2Gm8YCgej fj386LHEzVjmfeyh6oagBNWb0k3RR/xSeBYZZuDf6KH7lWkAToqbax4tLEfhtv3UFm0a FJZgz06D/Wtup6L0lfwPIKkymedxs7H8n0NdGTiZaPIPYi0PvevqG3ln1QeAjrf372rL ge3nE6FJRa54xVFMSaZNT1Bun7gUhxsbxUNSNBLHS3FRPDu5gYw6oyB1sSqOSa9XSLNM /Lt9DEsz6/btJfnJKSNlJTUHIsq+zGjWU01d8p3sLXQq2GL7A/hBtNp//E7npSKm3ACH R8aQ== Received: by 10.236.156.69 with SMTP id l45mr56361237yhk.123.1342015314244; Wed, 11 Jul 2012 07:01:54 -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 y63sm3283732yha.9.2012.07.11.07.01.53 (version=SSLv3 cipher=OTHER); Wed, 11 Jul 2012 07:01:53 -0700 (PDT) Message-ID: <4FFD8750.7010407@inktank.com> Date: Wed, 11 Jul 2012 09:01:52 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 07/16] rbd: dynamically allocate object prefix References: <4FFD847C.7070205@inktank.com> In-Reply-To: <4FFD847C.7070205@inktank.com> X-Gm-Message-State: ALoCoQnMmGb7tl3WkrSGazwj+VAR18dvvOxhJEU5cv//Bv60B8r4q+QD9VQr9n+iZjcPR8b+zK54 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org There is no need to impose a small limit the length of the object prefix recorded for an rbd image in a struct rbd_image_header. Remove the limitation by allocating space for the object prefix dynamically. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) header->obj_order = ondisk->options.order; @@ -546,6 +553,8 @@ static int rbd_header_from_disk(struct rbd_image_header *header, return 0; +err_sizes: + kfree(header->snap_sizes); err_names: kfree(header->snap_names); err_snapc: @@ -611,9 +620,10 @@ done: static void rbd_header_free(struct rbd_image_header *header) { - kfree(header->snapc); - kfree(header->snap_names); + kfree(header->object_prefix); kfree(header->snap_sizes); + kfree(header->snap_names); + kfree(header->snapc); } /* @@ -1711,15 +1721,17 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev) if head moves */ follow_seq = 1; - kfree(rbd_dev->header.snapc); - kfree(rbd_dev->header.snap_names); + kfree(rbd_dev->header.object_prefix); kfree(rbd_dev->header.snap_sizes); + kfree(rbd_dev->header.snap_names); + kfree(rbd_dev->header.snapc); rbd_dev->header.total_snaps = h.total_snaps; rbd_dev->header.snapc = h.snapc; rbd_dev->header.snap_names = h.snap_names; rbd_dev->header.snap_names_len = h.snap_names_len; rbd_dev->header.snap_sizes = h.snap_sizes; + rbd_dev->header.object_prefix = h.object_prefix; if (follow_seq) rbd_dev->header.snapc->seq = rbd_dev->header.snapc->snaps[0]; else diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 57d264c..3aa0ca0 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -78,7 +78,7 @@ */ struct rbd_image_header { u64 image_size; - char object_prefix[32]; + char *object_prefix; __u8 obj_order; __u8 crypt_type; __u8 comp_type; @@ -518,8 +518,15 @@ static int rbd_header_from_disk(struct rbd_image_header *header, header->snap_names = NULL; header->snap_sizes = NULL; } + + header->object_prefix = kmalloc(sizeof (ondisk->block_name) + 1, + gfp_flags); + if (!header->object_prefix) + goto err_sizes; + memcpy(header->object_prefix, ondisk->block_name, sizeof(ondisk->block_name)); + header->object_prefix[sizeof (ondisk->block_name)] = '\0'; header->image_size = le64_to_cpu(ondisk->image_size);