From patchwork Sat May 11 17:44:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2554471 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 D4267E00E6 for ; Sat, 11 May 2013 17:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754275Ab3EKRoP (ORCPT ); Sat, 11 May 2013 13:44:15 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:57468 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754227Ab3EKRoN (ORCPT ); Sat, 11 May 2013 13:44:13 -0400 Received: by mail-ie0-f179.google.com with SMTP id c13so10146110ieb.10 for ; Sat, 11 May 2013 10:44:13 -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=XAjrYbu9GzAxjv3KnraCsA0RWuZD6pcMGtQ5gENVXR8=; b=oniGCbjtaDKvPVO7PlL5PmUrnbLRdBxsGUEt9PTqY0oocEPv/Mzb3tT9u+u3ekEl7e Rc8swbC1z6417ChJr1ymaBoh4rHPgMF3Q0HNrh5jew6f/MYQxPzY9ZTuZwx+YKCf+JKA WGEO3KBT+/rRjE8k1MAjhN4ybtDeAVmVzz8nsf1gz13uvpPueuVkI2jOTx0zBVZfuqZq U51HFCGg+uLf1lXPkAXUcluACiffSgwTaKf1pvnea57S0H4WlfJlgqI7PGLs4/If/9/7 C1K7Pv9dnvdJRzqvLUDB4AryYXy/xOzz4GVO8ytR3LgSM0CKWzdhFNQGsWCoBXoisYn2 2o3w== X-Received: by 10.50.20.38 with SMTP id k6mr5738140ige.50.1368294253353; Sat, 11 May 2013 10:44:13 -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 kc10sm5817132igb.0.2013.05.11.10.44.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 11 May 2013 10:44:12 -0700 (PDT) Message-ID: <518E836C.9010404@inktank.com> Date: Sat, 11 May 2013 12:44:12 -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 3/5] rbd: define rbd_dev_unparent() References: <518E831E.6000206@inktank.com> In-Reply-To: <518E831E.6000206@inktank.com> X-Gm-Message-State: ALoCoQmzVWU96Ir7OlRTKrP6Ebkb/jJo4TatCdZD6K+C5osx6msZMSq4NAHVp0N9sgKuP/5gqDhR Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Define rbd_dev_unparent() to encapsulate cleaning up parent data structures from a layered rbd image. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) * that comprises the image request, and the Linux request pointer @@ -4062,9 +4073,7 @@ out_err: rbd_dev->mapping.size = 0; rbd_dev->header.image_size = 0; rbd_dev->header.obj_order = 0; - rbd_dev->parent_overlap = 0; - rbd_spec_put(rbd_dev->parent_spec); - rbd_dev->parent_spec = NULL; + rbd_dev_unparent(rbd_dev); rbd_dev->header.stripe_count = 0; rbd_dev->header.stripe_unit = 0; rbd_dev->header.features = 0; @@ -4492,10 +4501,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev) { struct rbd_image_header *header; - rbd_dev_remove_parent(rbd_dev); - rbd_spec_put(rbd_dev->parent_spec); - rbd_dev->parent_spec = NULL; - rbd_dev->parent_overlap = 0; + rbd_dev_unparent(rbd_dev); /* Free dynamic fields from the header, then zero it out */ @@ -4571,7 +4577,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) return 0; out_err: if (parent) { - rbd_spec_put(rbd_dev->parent_spec); + rbd_dev_unparent(rbd_dev); kfree(rbd_dev->header_name); rbd_dev_destroy(parent); } else { diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index ac3f4e7..607c536 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1835,6 +1835,17 @@ static void rbd_obj_request_destroy(struct kref *kref) kmem_cache_free(rbd_obj_request_cache, obj_request); } +/* It's OK to call this for a device with no parent */ + +static void rbd_spec_put(struct rbd_spec *spec); +static void rbd_dev_unparent(struct rbd_device *rbd_dev) +{ + rbd_dev_remove_parent(rbd_dev); + rbd_spec_put(rbd_dev->parent_spec); + rbd_dev->parent_spec = NULL; + rbd_dev->parent_overlap = 0; +} + /* * Caller is responsible for filling in the list of object requests