From patchwork Tue May 7 01:53: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: 2529871 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 B538C3FD85 for ; Tue, 7 May 2013 01:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932760Ab3EGBxf (ORCPT ); Mon, 6 May 2013 21:53:35 -0400 Received: from mail-qe0-f43.google.com ([209.85.128.43]:54799 "EHLO mail-qe0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759121Ab3EGBxe (ORCPT ); Mon, 6 May 2013 21:53:34 -0400 Received: by mail-qe0-f43.google.com with SMTP id 1so31370qec.30 for ; Mon, 06 May 2013 18:53: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=fn99NzIbXpZjLWWJbEsd+lxuXzqV9jHo68IV+zW7m+E=; b=VLb+8+IywdlM4VGsH1TbpvnIZvXRhsfOgIWpnRScPRtrM57M7IDW4pPX7bDdzqXW5y Vy+Rng0dYk430Fv0gUeyr6TkZxPdv52of+XUeZeZI+2N1gZly4H9fNlLB1xT2hFqvcr0 bydsCkN5ixSAQ8bG0bGHDA/jWUHc29HB8IVaBGMN40UUEmZOsIx5N2Gao6lrOZs5oV+s mnwXI/my/dxvETLT/vy8h2GvFUL/XXPJ4/zNsb4wlFhYHL9UgsFnNl7BFw7mj4qhPp2C d0NRanR3kWAxUrNVGrioXjT5clW6DSruOY+lCBLbMf5XsBmBe2cU5kok9ooCMKrXuv74 Wxcg== X-Received: by 10.224.138.80 with SMTP id z16mr340743qat.2.1367891614053; Mon, 06 May 2013 18:53:34 -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 s10sm42558873qam.7.2013.05.06.18.53.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 18:53:33 -0700 (PDT) Message-ID: <51885E9C.2020001@inktank.com> Date: Mon, 06 May 2013 20:53: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 5/7] rbd: simplify rbd_dev_v1_probe() References: <51885E06.8020201@inktank.com> In-Reply-To: <51885E06.8020201@inktank.com> X-Gm-Message-State: ALoCoQmEojepOPVrC/A77Kp1xsrGwqa8MkuRt2q7ao7G24Gl46bCsUoJOcMtg44SJdUTeYDPWjQ4 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org An rbd_dev structure's fields are all zero-filled for an initial probe, so there's no need to explicitly zero the parent_spec and parent_overlap fields in rbd_dev_v1_probe(). Removing these assignments makes rbd_dev_v1_probe() *almost* trivial. Move the dout() message that announces discovery of an image into rbd_dev_image_probe(), generalize to support images in either format and only show it if an image is fully discovered. This highlights that are some unnecessary cleanups in the error path for rbd_dev_v1_probe(), so they can be removed. Now rbd_dev_v1_probe() *is* a trivial wrapper function. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) @@ -4553,9 +4529,6 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) if (ret) goto out_err; - dout("discovered version 2 image, header name is %s\n", - rbd_dev->header_name); - return 0; out_err: rbd_dev->parent_overlap = 0; @@ -4758,9 +4731,13 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only) rbd_dev->mapping.read_only = read_only; ret = rbd_dev_probe_parent(rbd_dev); - if (!ret) - return 0; + if (ret) + goto err_out_probe; + + dout("discovered format %u image, header name is %s\n", + rbd_dev->image_format, rbd_dev->header_name); + return 0; err_out_probe: rbd_dev_unprobe(rbd_dev); err_out_watch: diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a7985d9..ed18888 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4469,31 +4469,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev) static int rbd_dev_v1_probe(struct rbd_device *rbd_dev) { - int ret; - - /* Populate rbd image metadata */ - - ret = rbd_dev_v1_header_read(rbd_dev); - if (ret < 0) - goto out_err; - - /* Version 1 images have no parent (no layering) */ - - rbd_dev->parent_spec = NULL; - rbd_dev->parent_overlap = 0; - - dout("discovered version 1 image, header name is %s\n", - rbd_dev->header_name); - - return 0; - -out_err: - kfree(rbd_dev->header_name); - rbd_dev->header_name = NULL; - kfree(rbd_dev->spec->image_id); - rbd_dev->spec->image_id = NULL; - - return ret; + return rbd_dev_v1_header_read(rbd_dev); }