From patchwork Wed Aug 21 13:10:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 2847715 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 5B9B79F271 for ; Wed, 21 Aug 2013 13:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A0342049D for ; Wed, 21 Aug 2013 13:14:01 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 742322047E for ; Wed, 21 Aug 2013 13:13:59 +0000 (UTC) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r7LDDouN001496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Aug 2013 13:13:51 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7LDDo44029231 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Aug 2013 13:13:50 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VC8BN-0007MS-6W; Wed, 21 Aug 2013 06:10:41 -0700 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VC8BE-0007M2-Rc for ocfs2-devel@oss.oracle.com; Wed, 21 Aug 2013 06:10:33 -0700 Received: from aserp1030.oracle.com (aserp1030.oracle.com [141.146.126.68]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7LDAWU3014741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 Aug 2013 13:10:32 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 r7LDAV0g000984 for ; Wed, 21 Aug 2013 13:10:31 GMT Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 39094A52C6; Wed, 21 Aug 2013 15:10:31 +0200 (CEST) Date: Wed, 21 Aug 2013 08:10:30 -0500 From: Goldwyn Rodrigues To: ocfs2-devel@oss.oracle.com Message-ID: <20130821131026.GA4011@shrek.cartoons> 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=T2 ct-vol1=0 ct-vol2=4 ct-vol3=4 ct-risk=67 ct-spam1=80 ct-spam2=43 ct-bulk=26 rcpts=1 size=6070 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=D6B+dJhj c=1 sm=1 tr=0 a=uEuDQZVrWKuLCe7byFjfVg==:117 a=uEuDQZVrWKuLCe7byFjfVg==:17 a=LcaDllckn3IA:10 a=HgAQv6pGeRsA:10 a=7SFtLa4N3QQA:10 a=kj9zAlcOel0A:10 a=8X-mjxrNKSwA:10 a=iox4zFpeAAAA:8 a=yA65PWEwBQh2kNz8NkAA:9 a=ID5kO-Lo2B --Nr1V:21 a=zEZAi-TswNP0rrmW:21 a=CjuIK1q_8ugA:10 a=n9GBPR9yFnkA:10 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090206.5214BC48.00AE: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 4/5] ocfs2_connection_private for holding DLM this_node 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: acsinet21.oracle.com [141.146.126.237] X-Spam-Status: No, score=-7.0 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 ocfs2_connection_private holds this nodes information, such as the DLM allocated slot number and the node number assigned to the node. Signed-off-by: Goldwyn Rodrigues --- fs/ocfs2/dlmglue.c | 2 +- fs/ocfs2/stack_o2cb.c | 3 ++- fs/ocfs2/stack_user.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ fs/ocfs2/stackglue.c | 4 ++-- fs/ocfs2/stackglue.h | 4 ++-- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 7c57de3..f2d48c8 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -3007,7 +3007,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) goto bail; } - status = ocfs2_cluster_this_node(&osb->node_num); + status = ocfs2_cluster_this_node(conn, &osb->node_num); if (status < 0) { mlog_errno(status); mlog(ML_ERROR, diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index bf1f893..1724d43 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c @@ -398,7 +398,8 @@ static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn) return 0; } -static int o2cb_cluster_this_node(unsigned int *node) +static int o2cb_cluster_this_node(struct ocfs2_cluster_connection *conn, + unsigned int *node) { int node_num; diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index d604a36..b869d4d6 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" @@ -112,6 +113,12 @@ struct ocfs2_live_connection { struct ocfs2_cluster_connection *oc_conn; }; +struct ocfs2_connection_private { + atomic_t cp_this_node; + int cp_our_slot; + wait_queue_head_t cp_wait; +}; + struct ocfs2_control_private { struct list_head op_list; int op_state; @@ -805,12 +812,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_connection_private *priv = conn->cc_private; + int i; + + for (i = 0; i < num_slots; i++) + if (slots[i].slot == our_slot) { + atomic_set(&priv->cp_this_node, slots[i].nodeid); + break; + } + + priv->cp_our_slot = our_slot; + wake_up(&priv->cp_wait); } const struct dlm_lockspace_ops ocfs2_ls_ops = { @@ -823,9 +848,20 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) { dlm_lockspace_t *fsdlm; int rc = 0, ops_rv; + struct ocfs2_connection_private *priv; BUG_ON(conn == NULL); + priv = kzalloc(sizeof(struct ocfs2_connection_private), GFP_KERNEL); + if (!priv) { + rc = -ENOMEM; + goto out; + } + init_waitqueue_head(&priv->cp_wait); + atomic_set(&priv->cp_this_node, 0); + + conn->cc_private = priv; + rc = dlm_new_lockspace(conn->cc_name, conn->cc_cluster_name, DLM_LSFL_FS, DLM_LVB_LEN, &ocfs2_ls_ops, conn, &ops_rv, &fsdlm); @@ -839,6 +875,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) goto out; } + wait_event(priv->cp_wait, (atomic_read(&priv->cp_this_node) > 0)); conn->cc_lockspace = fsdlm; out: return rc; @@ -848,19 +885,21 @@ static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn) { dlm_release_lockspace(conn->cc_lockspace, 2); conn->cc_lockspace = NULL; + kfree(conn->cc_private); conn->cc_private = NULL; return 0; } -static int user_cluster_this_node(unsigned int *this_node) +static int user_cluster_this_node(struct ocfs2_cluster_connection *conn, + unsigned int *this_node) { - int rc; + struct ocfs2_connection_private *priv = + (struct ocfs2_connection_private *)conn->cc_private; - rc = ocfs2_control_get_this_node(); - if (rc < 0) - return rc; + if (!priv) + return -EINVAL; + *this_node = atomic_read(&priv->cp_this_node); - *this_node = rc; return 0; } diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 9acee13..4dd732b 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -465,9 +465,9 @@ void ocfs2_cluster_hangup(const char *group, int grouplen) } EXPORT_SYMBOL_GPL(ocfs2_cluster_hangup); -int ocfs2_cluster_this_node(unsigned int *node) +int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *conn, unsigned int *node) { - return active_stack->sp_ops->this_node(node); + return active_stack->sp_ops->this_node(conn, node); } EXPORT_SYMBOL_GPL(ocfs2_cluster_this_node); diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index b46fd51..c953290 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h @@ -157,7 +157,7 @@ struct ocfs2_stack_operations { * ->this_node() returns the cluster's unique identifier for the * local node. */ - int (*this_node)(unsigned int *node); + int (*this_node)(struct ocfs2_cluster_connection *conn, unsigned int *node); /* * Call the underlying dlm lock function. The ->dlm_lock() @@ -267,7 +267,7 @@ int ocfs2_cluster_connect_agnostic(const char *group, int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn, int hangup_pending); void ocfs2_cluster_hangup(const char *group, int grouplen); -int ocfs2_cluster_this_node(unsigned int *node); +int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *, unsigned int *node); struct ocfs2_lock_res; int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,