From patchwork Mon Nov 2 14:20:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zdenek Kabelac X-Patchwork-Id: 57030 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 nA2EKlOp029902 for ; Mon, 2 Nov 2009 14:20:53 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 D0F58619DF3; Mon, 2 Nov 2009 09:20:44 -0500 (EST) Received: from int-mx02.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 nA2EKaJE012341 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-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA2EKY8n005444 (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 nA2EKYYR008489; Mon, 2 Nov 2009 15:20:34 +0100 Received: (from kabi@localhost) by dhcp-0-185.brq.redhat.com (8.14.3/8.14.3/Submit) id nA2EKYAD008488; Mon, 2 Nov 2009 15:20:34 +0100 From: Zdenek Kabelac To: dm-devel@redhat.com Date: Mon, 2 Nov 2009 15:20:16 +0100 Message-Id: <1257171622-8380-13-git-send-email-zkabelac@redhat.com> In-Reply-To: <1257171622-8380-12-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> <1257171622-8380-10-git-send-email-zkabelac@redhat.com> <1257171622-8380-11-git-send-email-zkabelac@redhat.com> <1257171622-8380-12-git-send-email-zkabelac@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Zdenek Kabelac Subject: [dm-devel] [PATCH 12/18] Replicator: add replicator to dtree 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/activate/dev_manager.c b/lib/activate/dev_manager.c index 1f1d645..00f3cf3 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -951,6 +951,47 @@ static int _add_target_to_dtree(struct dev_manager *dm, static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, const char *layer); +/* Add all replicators' LVs from active segment */ +static int _add_replicator_dev_target_to_dtree(struct dev_manager *dm, + struct dm_tree *dtree, + struct lv_segment *seg) +{ + struct replicator_device *rdev; + struct replicator_site *rsite; + + /* only active replicator */ + if (lv_is_active_replicator_dev(seg->lv)) { + /* activation of one replicator node activate all other nodes */ + if (!seg->replicator || + !_add_new_lv_to_dtree(dm, dtree, seg->replicator, NULL)) + return_0; + + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + dm_list_iterate_items(rdev, &rsite->rdevices) { + if (rdev->slog && !_add_new_lv_to_dtree(dm, dtree, rdev->slog, NULL)) + return_0; + if ((rsite->state == REPLICATOR_STATE_ACTIVE) && + (!rdev->lv || !_add_new_lv_to_dtree(dm, dtree, rdev->lv, NULL))) + return_0; + } + } + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + if (rsite->state != REPLICATOR_STATE_ACTIVE) + continue; + dm_list_iterate_items(rdev, &rsite->rdevices) { + if (rdev->replicator_dev->lv == seg->lv) + continue; + if (!rdev->replicator_dev->lv || + !_add_new_lv_to_dtree(dm, dtree, rdev->replicator_dev->lv, NULL)) + return_0; + } + } + } else if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->rdevice->lv, NULL)) + return_0; + + return 1; +} + static int _add_segment_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct dm_tree_node *dnode, @@ -981,8 +1022,14 @@ static int _add_segment_to_dtree(struct dev_manager *dm, !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL)) return_0; + if (seg_is_replicator_dev(seg)) { + if (!_add_replicator_dev_target_to_dtree(dm, dtree, seg)) + return_0; + } else if (seg_is_replicator(seg) && seg->rlog_lv) { + if (!_add_new_lv_to_dtree(dm, dtree, seg->rlog_lv, NULL)) + return_0; /* If this is a snapshot origin, add real LV */ - if (lv_is_origin(seg->lv) && !layer) { + } else if (lv_is_origin(seg->lv) && !layer) { if (vg_is_clustered(seg->lv->vg)) { log_error("Clustered snapshots are not yet supported"); return 0;