From patchwork Fri Sep 7 14:50:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1423091 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 7F9A83FC33 for ; Fri, 7 Sep 2012 14:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933247Ab2IGOua (ORCPT ); Fri, 7 Sep 2012 10:50:30 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:54481 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932990Ab2IGOua (ORCPT ); Fri, 7 Sep 2012 10:50:30 -0400 Received: by mail-ie0-f174.google.com with SMTP id e11so5147910iej.19 for ; Fri, 07 Sep 2012 07:50:29 -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=moNX2UXEew7FMm+0xI+7d44x1MpHgwi5cK2/hxFkWoo=; b=gVsAFEk2Jvk7L+vdDzErFBoHYLO4DhR5/Zl3Jqbp2xP7ICBUoCgWc796GyjL+k4PCc R6U0I2A0LP82Uu7mFPXzGx5smUiNPWxS5/fVO7XVI/inP3o4ImqgIr9FZhmXvxSMPh2O OenRzksBUzeHPGNY3+m648S2B/4kxmLfHnJh3wZUvmfEHc35Z5zHwwDvmznb21KPKG2l 83YtAJjNrUaDj3/tpErcx718dePcXXF+fzbxQyJckUB3H0cnAjLiw8uvR7pDkv8I2SRb ghE1ucPEKGb5E+FKeVx1iXSbRBIzC1fkJ4pBc7ljUhpcR86/mg7jLG3s5Q48M1G444U7 LWuA== Received: by 10.50.160.233 with SMTP id xn9mr28964417igb.37.1347029429677; Fri, 07 Sep 2012 07:50:29 -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 ff4sm13316839igc.5.2012.09.07.07.50.27 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:50:28 -0700 (PDT) Message-ID: <504A09B4.3080909@inktank.com> Date: Fri, 07 Sep 2012 09:50:28 -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 3/4] rbd: don't register snapshots in bus_add_dev() References: <504A090F.7000706@inktank.com> In-Reply-To: <504A090F.7000706@inktank.com> X-Gm-Message-State: ALoCoQmbDnXkHssdR1Jcg8Afq2WtpdTKmy4ycr41YSbio49mUxMlKsjxLXapVv5l09ctkCs5f6L+ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org When rbd_bus_add_dev() is called (one spot--in rbd_add()), the rbd image header has not even been read yet. This means that the list of snapshots will be empty at the time of the call. As a result, there is no need for the code that calls rbd_register_snap_dev() for each entry in that list--so get rid of it. Once the header has been read (just after returning), a call will be made to rbd_dev_snap_devs_update(), which will then find every snapshot in the context to be new and will therefore call rbd_register_snap_dev() via __rbd_add_snap_dev() accomplishing the same thing. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 6af09f1..e922989 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2244,29 +2244,21 @@ static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev) static int rbd_bus_add_dev(struct rbd_device *rbd_dev) { - int ret; struct device *dev; - struct rbd_snap *snap; + int ret; mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); - dev = &rbd_dev->dev; + dev = &rbd_dev->dev; dev->bus = &rbd_bus_type; dev->type = &rbd_device_type; dev->parent = &rbd_root_dev; dev->release = rbd_dev_release; dev_set_name(dev, "%d", rbd_dev->dev_id); ret = device_register(dev); - if (ret < 0) - goto out; - list_for_each_entry(snap, &rbd_dev->snaps, node) { - ret = rbd_register_snap_dev(snap, &rbd_dev->dev); - if (ret < 0) - break; - } -out: mutex_unlock(&ctl_mutex); + return ret; }