From patchwork Sat Apr 27 12:37:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2497131 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 15348DFB79 for ; Sat, 27 Apr 2013 12:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755889Ab3D0Mhf (ORCPT ); Sat, 27 Apr 2013 08:37:35 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:50697 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755874Ab3D0Mhd (ORCPT ); Sat, 27 Apr 2013 08:37:33 -0400 Received: by mail-ie0-f169.google.com with SMTP id ar20so5984944iec.28 for ; Sat, 27 Apr 2013 05:37:33 -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=V+SgaeHHM+480fNYYa/hrWt6WErfYAXQQ5Ln4OWgdaE=; b=F1+C6sll3QKs6WR3cvpBy2Lc3fx5RMx9sqibMeFCHTj1SBBi0ivp0nlJwUKSfGh87e XPX5be5//VB0j5Y/K1l3hHOsg/dMnnwq+JzQd6p1m9unGt3aIzyb62jQUwlNv+QokwmW kMJWZEQHUptucvTg3s8YjPbeHHzllNGqNdLm0+0PI27QGNKoa7gmpNkBNBJ6KtIQ+4kb 435fw/KnLZ/oZtLALelVtIYCQTdoSwRTLVhBNqhDymL3DPUfp9qbmtJOMoP1LvVO55xk qMO/5vgHdH0draKdXceENTmKI1gCvu+0I2bydXR4LIgdTkB9DyBNAvJcLNt51Vgujjb6 T4+g== X-Received: by 10.50.13.100 with SMTP id g4mr303768igc.73.1367066253474; Sat, 27 Apr 2013 05:37: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 y5sm8449137igg.7.2013.04.27.05.37.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 27 Apr 2013 05:37:32 -0700 (PDT) Message-ID: <517BC68B.3040806@inktank.com> Date: Sat, 27 Apr 2013 07:37:31 -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 4/6] rbd: fix rbd_dev_remove_parent() References: <517BC608.5030008@inktank.com> In-Reply-To: <517BC608.5030008@inktank.com> X-Gm-Message-State: ALoCoQmcvJF83UYiN6Z3Hdy3bPsXgnsfr7GtZIjgSYh1HS8npR+m8KhZVvq/pJbDoTEVkfrZ35qq Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org In certain error paths, it is possible for an rbd device to have a parent spec but no parent rbd_dev. In rbd_dev_remove_parent() use the parent field rather than parent_spec in determining whether to try to remove any parent devices. Use assertions to indicate that any non-null parent pointer has parent_spec associated with it. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 9936067..99d231b 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4984,7 +4984,7 @@ static void rbd_dev_release(struct device *dev) static void rbd_dev_remove_parent(struct rbd_device *rbd_dev) { - while (rbd_dev->parent_spec) { + while (rbd_dev->parent) { struct rbd_device *first = rbd_dev; struct rbd_device *second = first->parent; struct rbd_device *third; @@ -4997,12 +4997,15 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev) first = second; second = third; } + rbd_assert(second); rbd_remove_all_snaps(second); rbd_bus_del_dev(second); + first->parent = NULL; + first->parent_overlap = 0; + + rbd_assert(first->parent_spec); rbd_spec_put(first->parent_spec); first->parent_spec = NULL; - first->parent_overlap = 0; - first->parent = NULL; } }