From patchwork Fri Sep 27 17:09:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 2956351 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B6D49F244 for ; Fri, 27 Sep 2013 17:09:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6206220272 for ; Fri, 27 Sep 2013 17:09:45 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1601C2026F for ; Fri, 27 Sep 2013 17:09:44 +0000 (UTC) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8RH9C9H023729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Sep 2013 17:09:13 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8RH9BJY006298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 Sep 2013 17:09:11 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VPbXT-0003qL-Le; Fri, 27 Sep 2013 10:09:11 -0700 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VPbXK-0003q1-R9 for ocfs2-devel@oss.oracle.com; Fri, 27 Sep 2013 10:09:02 -0700 Received: from aserp1030.oracle.com (aserp1030.oracle.com [141.146.126.68]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8RH92ne016379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 27 Sep 2013 17:09:02 GMT Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by aserp1030.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8RH914R019248 for ; Fri, 27 Sep 2013 17:09:01 GMT Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2207CA52BF for ; Fri, 27 Sep 2013 19:09:01 +0200 (CEST) Date: Fri, 27 Sep 2013 12:09:00 -0500 From: Goldwyn Rodrigues To: ocfs2-devel@oss.oracle.com Message-ID: <20130927170855.GA11732@shrek.lan> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=195.135.220.15 ct-class=R5 ct-vol1=-99 ct-vol2=8 ct-vol3=9 ct-risk=46 ct-spam1=75 ct-spam2=0 ct-bulk=99 rcpts=1 size=4189 X-SPF-Info: NONE::cantor2.suse.de X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=boN1Wiqi c=1 sm=1 tr=0 a=uEuDQZVrWKuLCe7byFjfVg==:117 a=uEuDQZVrWKuLCe7byFjfVg==:17 a=LcaDllckn3IA:10 a=3V4uhVZvulkA:10 a=7SFtLa4N3QQA:10 a=kj9zAlcOel0A:10 a=yPCof4ZbAAAA:8 a=3c1ULUpnqyIA:10 a=f6Z7lf95z5fs9-RuR1QA:9 a=s6mCPRDbun 7uWI7D:21 a=pV_g_sYbATRENOxK:21 a=CjuIK1q_8ugA:10 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090206.5245BBAE.009F:SCFSTAT13898897, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Cc: mfasheh@suse.com Subject: [Ocfs2-devel] [PATCH 5/7] Record this node's information X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- fs/ocfs2/stack_user.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index ffefbb5..cccc1e1 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "stackglue.h" @@ -116,6 +117,9 @@ struct ocfs2_live_connection { struct list_head oc_list; struct ocfs2_cluster_connection *oc_conn; enum ocfs2_connection_type oc_type; + atomic_t oc_this_node; + int oc_our_slot; + wait_queue_head_t oc_wait; }; struct ocfs2_control_private { @@ -205,15 +209,13 @@ static struct ocfs2_live_connection *ocfs2_connection_find(const char *name) * fill_super(), we can't get dupes here. */ static int ocfs2_live_connection_new(struct ocfs2_cluster_connection *conn, - struct ocfs2_live_connection *c, - enum ocfs2_connection_type type) + struct ocfs2_live_connection *c) { int rc = 0; mutex_lock(&ocfs2_control_lock); c->oc_conn = conn; - c->oc_type = type; - if ((type == NO_CONTROLD) || atomic_read(&ocfs2_control_opened)) + if ((c->oc_type == NO_CONTROLD) || atomic_read(&ocfs2_control_opened)) list_add(&c->oc_list, &ocfs2_live_connection_list); else { printk(KERN_ERR @@ -802,12 +804,30 @@ static void user_recover_prep(void *arg) static void user_recover_slot(void *arg, struct dlm_slot *slot) { + struct ocfs2_cluster_connection *conn = + (struct ocfs2_cluster_connection *) arg; + printk(KERN_INFO "ocfs2: Node %d/%d down. Initiating recovery.\n", + slot->nodeid, slot->slot); + conn->cc_recovery_handler(slot->nodeid, conn->cc_recovery_data); } static void user_recover_done(void *arg, struct dlm_slot *slots, int num_slots, int our_slot, uint32_t generation) { + struct ocfs2_cluster_connection *conn = + (struct ocfs2_cluster_connection *)arg; + struct ocfs2_live_connection *lc = conn->cc_private; + int i; + + for (i = 0; i < num_slots; i++) + if (slots[i].slot == our_slot) { + atomic_set(&lc->oc_this_node, slots[i].nodeid); + break; + } + + lc->oc_our_slot = our_slot; + wake_up(&lc->oc_wait); } const struct dlm_lockspace_ops ocfs2_ls_ops = { @@ -830,7 +850,6 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) dlm_lockspace_t *fsdlm; struct ocfs2_live_connection *lc = NULL; int rc = 0, ops_rv; - enum ocfs2_connection_type type = NO_CONTROLD; BUG_ON(conn == NULL); @@ -840,6 +859,11 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) goto out; } + init_waitqueue_head(&lc->oc_wait); + atomic_set(&lc->oc_this_node, 0); + conn->cc_private = lc; + lc->oc_type = NO_CONTROLD; + rc = dlm_new_lockspace(conn->cc_name, conn->cc_cluster_name, DLM_LSFL_FS, DLM_LVB_LEN, &ocfs2_ls_ops, conn, &ops_rv, &fsdlm); @@ -848,7 +872,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) goto out; if (ops_rv == -EOPNOTSUPP) { - type = WITH_CONTROLD; + lc->oc_type = WITH_CONTROLD; printk(KERN_NOTICE "ocfs2: You seem to be using an older " "version of dlm_controld and/or ocfs2-tools." " Please consider upgrading.\n"); @@ -858,11 +882,11 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) } conn->cc_lockspace = fsdlm; - rc = ocfs2_live_connection_new(conn, lc, type); + rc = ocfs2_live_connection_new(conn, lc); if (rc) goto out; - if (type == WITH_CONTROLD) { + if (lc->oc_type == WITH_CONTROLD) { /* * running_proto must have been set before we allowed any mounts * to proceed. @@ -890,9 +914,9 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) lc = NULL; goto out; } - } + } else if (lc->oc_type == NO_CONTROLD) + wait_event(lc->oc_wait, (atomic_read(&lc->oc_this_node) > 0)); - conn->cc_private = lc; out: if (rc && lc) kfree(lc);