From patchwork Fri Sep 7 13:39:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1422431 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 41AE0DF283 for ; Fri, 7 Sep 2012 13:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760635Ab2IGNjj (ORCPT ); Fri, 7 Sep 2012 09:39:39 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:60946 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760484Ab2IGNjg (ORCPT ); Fri, 7 Sep 2012 09:39:36 -0400 Received: by mail-ie0-f174.google.com with SMTP id e11so5001652iej.19 for ; Fri, 07 Sep 2012 06:39:36 -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=qzQ5Cid4S8Ye/xPgfzfrj+MB+xkTIqn5QdxaO62eYRE=; b=fblX6uuV2TG2phNj3duiX8RYcdGQdmAPTYfIsOhaEY7V2pELF/+0LlQICpA07lITdf wh81xIs9DR6m9D0x4Sso5vNLRyH55TtHPJApXvWxLX9q1x+IXOdN4dy7RfvcqkFg/eg5 WytTpQaikmHWttN7srtqCAqI3pr4Gus8c1agtJPQVCRrXry7sjg2n3GmIQClsuBjZ+dQ bfyUhSdb3G7XZTI/u3BG5g4ttlh3MQyHBfGwxfUgEChVvDCl8+xvtoKs5xJZTY01DCmJ s1DLrsO+qrdKm4sySR/i+r+Y8h8vTw4RyPU4/j5wLG172IlqQ48LojfF5KUqaSzXUXJi THqg== Received: by 10.50.192.199 with SMTP id hi7mr28754726igc.68.1347025176397; Fri, 07 Sep 2012 06:39:36 -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 a10sm12980219igd.1.2012.09.07.06.39.32 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 06:39:32 -0700 (PDT) Message-ID: <5049F914.1050306@inktank.com> Date: Fri, 07 Sep 2012 08:39:32 -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/5] rbd: rename __rbd_init_snaps_header() References: <5049F7F5.1070609@inktank.com> In-Reply-To: <5049F7F5.1070609@inktank.com> X-Gm-Message-State: ALoCoQkR9axe+SBiQcnSCKxuxmFvDmIoLDIxrlBUrypJmphN5Olg3O6U5JH+J18Mnim+BZSUdkbM Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The name __rbd_init_snaps_header() doesn't really convey what that function does very well. Its purpose is to scan a new snapshot context and either create or destroy snapshot device entries so that local host's view is consistent with the reality maintained on the OSDs. This patch just changes the name of this function, to be rbd_dev_snap_devs_update(). Still not perfect, but I think better. Also add some dynamic debug statements to this function. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) @@ -1880,7 +1880,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev) return rc; /* no need to lock here, as rbd_dev is not registered yet */ - rc = __rbd_init_snaps_header(rbd_dev); + rc = rbd_dev_snap_devs_update(rbd_dev); if (rc) return rc; @@ -2184,7 +2184,7 @@ err: * snapshot id, highest id first. (Snapshots in the rbd_dev's list * are also maintained in that order.) */ -static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) +static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev) { struct ceph_snap_context *snapc = rbd_dev->header.snapc; const u32 snap_count = snapc->num_snaps; @@ -2193,6 +2193,7 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) struct list_head *links = head->next; u32 index = 0; + dout("%s: snap count is %u\n", __func__, (unsigned int) snap_count); while (index < snap_count || links != head) { u64 snap_id; struct rbd_snap *snap; @@ -2211,6 +2212,9 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) if (rbd_dev->snap_id == snap->id) rbd_dev->snap_exists = false; __rbd_remove_snap_dev(snap); + dout("%ssnap id %llu has been removed\n", + rbd_dev->snap_id == snap->id ? "mapped " : "", + (unsigned long long) snap->id); /* Done with this list entry; advance */ @@ -2218,6 +2222,8 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) continue; } + dout("entry %u: snap_id = %llu\n", (unsigned int) snap_count, + (unsigned long long) snap_id); if (!snap || (snap_id != CEPH_NOSNAP && snap->id < snap_id)) { struct rbd_snap *new_snap; @@ -2225,11 +2231,17 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) new_snap = __rbd_add_snap_dev(rbd_dev, index, snap_name); - if (IS_ERR(new_snap)) - return PTR_ERR(new_snap); + if (IS_ERR(new_snap)) { + int err = PTR_ERR(new_snap); + + dout(" failed to add dev, error %d\n", err); + + return err; + } /* New goes before existing, or at end of list */ + dout(" added dev%s\n", snap ? "" : " at end\n"); if (snap) list_add_tail(&new_snap->node, &snap->node); else @@ -2237,6 +2249,8 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) } else { /* Already have this one */ + dout(" already present\n"); + rbd_assert(snap->size == rbd_dev->header.snap_sizes[index]); rbd_assert(!strcmp(snap->name, snap_name)); @@ -2251,6 +2265,7 @@ static int __rbd_init_snaps_header(struct rbd_device *rbd_dev) index++; snap_name += strlen(snap_name) + 1; } + dout("%s: done\n", __func__); return 0; } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8cb8e0a..7726368 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -201,7 +201,7 @@ static DEFINE_SPINLOCK(rbd_dev_list_lock); static LIST_HEAD(rbd_client_list); /* clients */ static DEFINE_SPINLOCK(rbd_client_list_lock); -static int __rbd_init_snaps_header(struct rbd_device *rbd_dev); +static int rbd_dev_snap_devs_update(struct rbd_device *rbd_dev); static void rbd_dev_release(struct device *dev); static ssize_t rbd_snap_add(struct device *dev, struct device_attribute *attr, @@ -1848,7 +1848,7 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver) WARN_ON(strcmp(rbd_dev->header.object_prefix, h.object_prefix)); kfree(h.object_prefix); - ret = __rbd_init_snaps_header(rbd_dev); + ret = rbd_dev_snap_devs_update(rbd_dev); up_write(&rbd_dev->header_rwsem);