From patchwork Fri Sep 7 15:44:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1423541 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 9594F3FC85 for ; Fri, 7 Sep 2012 15:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371Ab2IGPo2 (ORCPT ); Fri, 7 Sep 2012 11:44:28 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:63393 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854Ab2IGPo1 (ORCPT ); Fri, 7 Sep 2012 11:44:27 -0400 Received: by ieje11 with SMTP id e11so5261193iej.19 for ; Fri, 07 Sep 2012 08:44:27 -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=JHzFaXbTQ2m7bfv6PXhJixrM9BexzFia505WmW7QX78=; b=fg9XTdFTAEkfV1DiQxkWdBvuLkFOuK/I6osH/dUjYx59xKlh0gnDtpkGZ/mx/0LE5+ CvM9pdC4HBc44681mJMRSCD1tltK4jqjusCA12ywCVVA+NhqJ4Lchwmatw1svy3+3sLy fK3l5GbRAUiQ7zH7yoapPxwCntdpR8xeJ0Q2OzNddP/LnyEBPXcUBbRTC7Vk3wl4T5aA IJGsQfPb8zqyUXJMOoOld68YV/cPjHYXXpK2UOIXwV4QPiozzuTFqFrAST2HVGFKD8or INJUl6Zlv/+OpChXGeGFqVBxR3Qkdxeeatr0TGS/RTUCLw7FeiVe7Gwt1wwLoOJQZpbP FqUA== Received: by 10.42.18.193 with SMTP id y1mr7597351ica.0.1347032666912; Fri, 07 Sep 2012 08:44:26 -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 hz10sm8517059igc.12.2012.09.07.08.44.25 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 08:44:26 -0700 (PDT) Message-ID: <504A1653.7020609@inktank.com> Date: Fri, 07 Sep 2012 10:44:19 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 1/9] rbd: assign header name later References: <504A152E.4000905@inktank.com> In-Reply-To: <504A152E.4000905@inktank.com> X-Gm-Message-State: ALoCoQlcZp0TeKccVecNcjwiTmpWvQEaPvpdIknr29OBLkU1biNynSF6pulXqMmFEt1EnuapUGwv Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Move the assignment of the header name for an rbd image a bit later, outside rbd_add_parse_args() and into its caller. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) if (!len) { @@ -2501,8 +2492,6 @@ dout(" SNAP_NAME is <%s>, len is %zd\n", snap_name, len); return snap_name; out_err: - kfree(rbd_dev->header_name); - rbd_dev->header_name = NULL; kfree(rbd_dev->image_name); rbd_dev->image_name = NULL; rbd_dev->image_name_len = 0; @@ -2569,6 +2558,15 @@ static ssize_t rbd_add(struct bus_type *bus, goto err_out_client; rbd_dev->pool_id = rc; + /* Create the name of the header object */ + + rbd_dev->header_name = kmalloc(rbd_dev->image_name_len + + sizeof (RBD_SUFFIX), + GFP_KERNEL); + if (!rbd_dev->header_name) + goto err_out_client; + sprintf(rbd_dev->header_name, "%s%s", rbd_dev->image_name, RBD_SUFFIX); + /* register our block device */ rc = register_blkdev(0, rbd_dev->name); if (rc < 0) @@ -2630,11 +2628,11 @@ err_out_bus: err_out_blkdev: unregister_blkdev(rbd_dev->major, rbd_dev->name); err_out_client: + kfree(rbd_dev->header_name); rbd_put_client(rbd_dev); err_put_id: if (rbd_dev->pool_name) { kfree(rbd_dev->mapping.snap_name); - kfree(rbd_dev->header_name); kfree(rbd_dev->image_name); kfree(rbd_dev->pool_name); } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4dff92f..14034e3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2475,15 +2475,6 @@ static char *rbd_add_parse_args(struct rbd_device *rbd_dev, if (!rbd_dev->image_name) goto out_err; - /* Create the name of the header object */ - - rbd_dev->header_name = kmalloc(rbd_dev->image_name_len - + sizeof (RBD_SUFFIX), - GFP_KERNEL); - if (!rbd_dev->header_name) - goto out_err; - sprintf(rbd_dev->header_name, "%s%s", rbd_dev->image_name, RBD_SUFFIX); - /* Snapshot name is optional */ len = next_token(&buf);