From patchwork Mon Nov 2 14:20:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zdenek Kabelac X-Patchwork-Id: 57029 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA2EKlOn029902 for ; Mon, 2 Nov 2009 14:20:52 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 0081C619DDC; Mon, 2 Nov 2009 09:20:44 -0500 (EST) Received: from int-mx08.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nA2EKaeb012332 for ; Mon, 2 Nov 2009 09:20:36 -0500 Received: from dhcp-0-185.brq.redhat.com (dhcp-0-185.brq.redhat.com [10.34.0.185]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA2EKYTw004186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 Nov 2009 09:20:35 -0500 Received: from dhcp-0-185.brq.redhat.com (dhcp-0-185.brq.redhat.com [127.0.0.1]) by dhcp-0-185.brq.redhat.com (8.14.3/8.14.3) with ESMTP id nA2EKXjh008477; Mon, 2 Nov 2009 15:20:33 +0100 Received: (from kabi@localhost) by dhcp-0-185.brq.redhat.com (8.14.3/8.14.3/Submit) id nA2EKXVO008476; Mon, 2 Nov 2009 15:20:33 +0100 From: Zdenek Kabelac To: dm-devel@redhat.com Date: Mon, 2 Nov 2009 15:20:13 +0100 Message-Id: <1257171622-8380-10-git-send-email-zkabelac@redhat.com> In-Reply-To: <1257171622-8380-9-git-send-email-zkabelac@redhat.com> References: <1257171622-8380-1-git-send-email-zkabelac@redhat.com> <1257171622-8380-2-git-send-email-zkabelac@redhat.com> <1257171622-8380-3-git-send-email-zkabelac@redhat.com> <1257171622-8380-4-git-send-email-zkabelac@redhat.com> <1257171622-8380-5-git-send-email-zkabelac@redhat.com> <1257171622-8380-6-git-send-email-zkabelac@redhat.com> <1257171622-8380-7-git-send-email-zkabelac@redhat.com> <1257171622-8380-8-git-send-email-zkabelac@redhat.com> <1257171622-8380-9-git-send-email-zkabelac@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-loop: dm-devel@redhat.com Cc: Zdenek Kabelac Subject: [dm-devel] [PATCH 09/18] Replicator: vg validation X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 67ba551..ebb2f16 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -2088,6 +2088,67 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea } } +/* + * Check for duplicate + * site name + * site index + * device name + * device index + */ +static int _replicator_validate(const struct logical_volume *lv) +{ + struct replicator_site *rsite, *rsiteb; + struct replicator_device *rdev, *rdevb; + int r = 1; + + dm_list_iterate_items(rsite, &lv->rsites) { + dm_list_iterate_items(rsiteb, &lv->rsites) { + if (rsite == rsiteb) + break; + if (strcasecmp(rsite->name, rsiteb->name) == 0) { + log_error("Internal error: Duplicate site name " + "%s detected for replicator %s", + rsite->name, lv->name); + r = 0; + } + if (rsite->site_index == rsiteb->site_index) { + log_error("Internal error: Duplicate site index " + "%d detected for replicator %s/%s", + rsite->site_index, lv->name, rsite->name); + r = 0; + } + } + + dm_list_iterate_items(rdev, &rsite->rdevices) { + dm_list_iterate_items(rdevb, &rsite->rdevices) { + if (rdev == rdevb) + break; + log_error("devs: lv:%s %s", rdev->name, rdevb->name); + if (rdev->slog && (rdev->slog == rdevb->slog)) { + log_error("Internal error: Duplicate sync log " + "%s detected for replicator %s", + rdev->slog->name, lv->name); + r = 0; + } + if (strcasecmp(rdev->name, rdevb->name) == 0) { + log_error("Internal error: Duplicate device name " + "%s detected for replicator %s", + rdev->name, lv->name); + r = 0; + } + if (rdev->device_index == rdevb->device_index) { + log_error("Internal error: Duplicate device index %" + PRId64 " detected for replicator %s/%s", + rdev->device_index, lv->name, rsite->name); + r = 0; + } + } + } + } + + return r; +} + int vg_validate(struct volume_group *vg) { struct pv_list *pvl, *pvl2; @@ -2188,6 +2249,9 @@ int vg_validate(struct volume_group *vg) r = 0; } } + + if (lv_is_replicator(lvl->lv) && !_replicator_validate(lvl->lv)) + r = 0; } dm_list_iterate_items(lvl, &vg->lvs) {