[Ocfs2-commits] jlbec commits r1819 - in trunk/fs/ocfs2: . cluster
dlm
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jan 20 19:50:12 CST 2005
Author: jlbec
Date: 2005-01-20 19:50:08 -0600 (Thu, 20 Jan 2005)
New Revision: 1819
Added:
trunk/fs/ocfs2/dlm/
trunk/fs/ocfs2/dlm/Makefile
trunk/fs/ocfs2/dlm/dlm_compat.h
trunk/fs/ocfs2/dlm/dlmast.c
trunk/fs/ocfs2/dlm/dlmcommon.h
trunk/fs/ocfs2/dlm/dlmconvert.c
trunk/fs/ocfs2/dlm/dlmlock.c
trunk/fs/ocfs2/dlm/dlmmaster.c
trunk/fs/ocfs2/dlm/dlmmod.c
trunk/fs/ocfs2/dlm/dlmmod.h
trunk/fs/ocfs2/dlm/dlmrecovery.c
trunk/fs/ocfs2/dlm/dlmthread.c
trunk/fs/ocfs2/dlm/dlmunlock.c
trunk/fs/ocfs2/dlm/util.c
trunk/fs/ocfs2/dlm/util.h
trunk/fs/ocfs2/dlm/warning_hack.h
Removed:
trunk/fs/ocfs2/cluster/dlm_compat.h
trunk/fs/ocfs2/cluster/dlmast.c
trunk/fs/ocfs2/cluster/dlmcommon.h
trunk/fs/ocfs2/cluster/dlmconvert.c
trunk/fs/ocfs2/cluster/dlmlock.c
trunk/fs/ocfs2/cluster/dlmmaster.c
trunk/fs/ocfs2/cluster/dlmmod.c
trunk/fs/ocfs2/cluster/dlmmod.h
trunk/fs/ocfs2/cluster/dlmrecovery.c
trunk/fs/ocfs2/cluster/dlmthread.c
trunk/fs/ocfs2/cluster/dlmunlock.c
Log:
Step 7 - Move DLM files to their own directory
o Move all the DLM files.
o Copy util.[ch] and warning_hack.h. I'm too lazy right now to figure
out the best way to share them.
Deleted: trunk/fs/ocfs2/cluster/dlm_compat.h
===================================================================
--- trunk/fs/ocfs2/cluster/dlm_compat.h 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlm_compat.h 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,189 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlm_compat.h
- *
- * Compatibility stuff for 2.4
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version
- * 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#ifndef CLUSTER_DLM_COMPAT_H
-#define CLUSTER_DLM_COMPAT_H
-
-#include <linux/version.h>
-#include <linux/types.h>
-#include <linux/kdev_t.h>
-#include <linux/sched.h>
-#include <linux/compiler.h>
-
-/* for tcp_sk() */
-#include <net/sock.h>
-#include <linux/tcp.h>
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-# include <linux/locks.h>
-# include <linux/blkdev.h>
-#else
-# include <linux/buffer_head.h>
-#endif
-
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-
-extern inline int generic_fls(int x);
-extern inline int get_bitmask_order(unsigned int count);
-/* XXX Hack to avoid warning */
-struct mem_dqinfo;
-
-#define flush_scheduled_work flush_scheduled_tasks
-#define work_struct tq_struct
-#define INIT_WORK(w, f, d) INIT_TQUEUE(w, f, d)
-#define schedule_work(w) schedule_task(w)
-
-#ifdef HAVE_NPTL
-static inline void dequeue_signal_lock(struct task_struct *task,
- sigset_t *blocked, siginfo_t *info)
-{
- spin_lock_irq(&task->sighand->siglock);
- dequeue_signal(blocked, info);
- spin_unlock_irq(&task->sighand->siglock);
-}
-#else
-static inline void dequeue_signal_lock(struct task_struct *task,
- sigset_t *blocked, siginfo_t *info)
-{
- spin_lock_irq(&task->sigmask_lock);
- dequeue_signal(blocked, info);
- spin_unlock_irq(&task->sigmask_lock);
-}
-#endif
-#define kstatfs statfs
-
-
-
-/*
- * Copied right out of the 2.6.2 kernel's buffer_head.h:
- * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
- * and buffer_foo() functions.
- */
-#define BUFFER_FNS(bit, name) \
-static inline void set_buffer_##name(struct buffer_head *bh) \
-{ \
- set_bit(BH_##bit, &(bh)->b_state); \
-} \
-static inline void clear_buffer_##name(struct buffer_head *bh) \
-{ \
- clear_bit(BH_##bit, &(bh)->b_state); \
-} \
-static inline int buffer_##name(struct buffer_head *bh) \
-{ \
- return test_bit(BH_##bit, &(bh)->b_state); \
-}
-
-#undef buffer_uptodate
-#undef buffer_dirty
-BUFFER_FNS(Uptodate, uptodate)
-BUFFER_FNS(Dirty, dirty)
-
-#define clear_buffer_dirty mark_buffer_clean
-
-#define OCFS_CURRENT_SECONDS CURRENT_TIME
-
-static inline __u32 mk_inode_time(long tv_sec, long tv_nsec)
-{
- return tv_sec;
-}
-
-#ifndef tcp_sk
-static inline struct tcp_opt * tcp_sk(const struct sock *__sk)
-{
- return &__sk->tp_info.af_tcp;
-}
-#endif
-static inline int ocfs_dev_bits(kdev_t dev)
-{
- return blksize_bits(block_size(dev));
-}
-
-#define blk_run_address_space(throwaway) run_task_queue(&tq_disk)
-
-#else /* LINUX_VERSION_CODE < 2.6 */
-
-static inline int ocfs_dev_bits(dev_t dev)
-{
- struct block_device *bd = bdget(dev);
- int ret = -EINVAL;
-
- if (bd == NULL)
- goto out;
-
- ret = bd->bd_inode->i_blkbits;
- bdput(bd);
-out:
- return ret;
-
-}
-
-static inline struct buffer_head *getblk(dev_t dev, sector_t block, int size)
-{
- struct block_device *bd = bdget(dev);
- struct buffer_head *bh;
-
- if (bd == NULL)
- return NULL;
-
- bh = __getblk(bd, block, size);
- bdput(bd);
- return bh;
-}
-
-#define OCFS_CURRENT_SECONDS (CURRENT_TIME.tv_sec)
-
-static inline struct timespec mk_inode_time(long tv_sec, long tv_nsec)
-{
- struct timespec ts = {
- .tv_sec = tv_sec,
- .tv_nsec = tv_nsec,
- };
- return ts;
-}
-
-#endif /* LINUX_VERSION_CODE */
-
-#ifndef HAVE_SOCK_CREATE_LITE
-static inline int sock_create_lite(int family, int type, int protocol,
- struct socket **res)
-{
- struct socket *sock = sock_alloc();
- int ret = 0;
-
- if (sock == NULL)
- ret = -ENOMEM;
-
- *res = sock;
-
- return ret;
-}
-#endif /* HAVE_SOCK_CREATE_LITE */
-
-
-#endif /* CLUSTER_DLM_COMPAT_H */
-
Deleted: trunk/fs/ocfs2/cluster/dlmast.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmast.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmast.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,311 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmast.c
- *
- * AST and BAST functionality for local and remote nodes
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-static int dlm_send_proxy_ast(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int type, int blocked_type);
-
-int dlm_do_ast(dlm_ctxt *dlm, dlm_lock_resource *res, dlm_lock *lock)
-{
- int ret;
-
- dlm_astlockfunc_t *fn;
- dlm_lockstatus *lksb;
-
- dlmprintk0("\n");
-
- DLM_ASSERT(lock);
- DLM_ASSERT(res);
- DLM_ASSERT(lock->lksb);
-
- lksb = lock->lksb;
- fn = lock->ast;
-
- if (res->owner == dlm->group_index) {
- /* this node is the lockres master */
- if (lksb->flags & DLM_LKSB_GET_LVB) {
- dlmprintk("getting lvb from lockres for %s node\n",
- lock->node == dlm->group_index ? "master" :
- "remote");
- memcpy(lksb->lvb, res->lvb, DLM_LVB_LEN);
- } else if (lksb->flags & DLM_LKSB_PUT_LVB) {
- dlmprintk("setting lvb from lockres for %s node\n",
- lock->node == dlm->group_index ? "master" :
- "remote");
- memcpy(res->lvb, lksb->lvb, DLM_LVB_LEN);
- }
- }
-
- ret = 0;
- if (lock->node != dlm->group_index) {
- /* lock request came from another node
- * go do the ast over there */
- ret = dlm_send_proxy_ast(dlm, res, lock, DLM_AST, 0);
- } else {
- DLM_ASSERT(fn);
- (*fn)(lock->astdata);
- }
-
- /* reset any lvb flags on the lksb */
- lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
- return ret;
-}
-
-
-int dlm_do_bast(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int blocked_type)
-{
- int ret;
- dlm_bastlockfunc_t *fn = lock->bast;
-
- dlmprintk0("\n");
-
- if (lock->node != dlm->group_index) {
- ret = dlm_send_proxy_ast(dlm, res, lock,
- DLM_BAST, blocked_type);
- goto leave;
- }
-
- if (!fn) {
- dlmprintk("eek! lock has no bast %*s! cookie=%llu\n",
- res->lockname.len, res->lockname.name, lock->cookie);
- ret = -EINVAL;
- goto leave;
- }
- (*fn)(lock->astdata, blocked_type);
- ret = 0;
-leave:
- return ret;
-}
-
-
-int dlm_proxy_ast_handler(net_msg *msg, u32 len, void *data)
-{
- int ret;
- int status;
- dlm_ctxt *dlm = data;
- dlm_lock_resource *res;
- dlm_lock *lock = NULL;
- dlm_proxy_ast *past = (dlm_proxy_ast *) msg->buf;
- struct qstr lockname;
- struct list_head *iter, *head=NULL;
- u64 cookie;
- u32 flags;
-
- dlm_proxy_ast_to_host(past);
- lockname.name = past->name;
- lockname.len = past->namelen;
- cookie = past->cookie;
- flags = past->flags;
-
- if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
- (LKM_PUT_LVB|LKM_GET_LVB)) {
- dlmprintk("both PUT and GET lvb specified\n");
- ret = DLM_BADARGS;
- goto leave;
- }
-
- dlmprintk("lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" :
- (flags & LKM_GET_LVB ? "get lvb" : "none"));
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- dlmprintk("type=%d, blocked_type=%d\n", past->type, past->blocked_type);
-
- if (past->type != DLM_AST &&
- past->type != DLM_BAST) {
- dlmprintk("Eeeek unknown ast type! %d, cookie=%llu, "
- "name=%*s\n",
- past->type, cookie, lockname.len, lockname.name);
- ret = DLM_IVLOCKID;
- goto leave;
- }
-
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res) {
- dlmprintk("eek! got %sast for unknown lockres! cookie=%llu, "
- "name=%*s, namelen=%d\n",
- past->type == DLM_AST ? "" : "b",
- cookie, lockname.len, lockname.name, lockname.len);
- ret = DLM_IVLOCKID;
- goto leave;
- }
-
- dlmprintk("lockres %*s\n", res->lockname.len, res->lockname.name);
- if (!dlm_is_recovery_lock(past->name, past->namelen))
- down_read(&dlm->recovery_sem);
- spin_lock(&res->spinlock);
-
- /* try convert queue for both ast/bast */
- head = &res->converting;
- lock = NULL;
- list_for_each(iter, head) {
- lock = list_entry (iter, dlm_lock, list);
- if (lock->cookie == cookie)
- goto do_ast;
- }
-
- /* if not on convert, try blocked for ast, granted for bast */
- if (past->type == DLM_AST)
- head = &res->blocked;
- else
- head = &res->granted;
-
- list_for_each(iter, head) {
- lock = list_entry (iter, dlm_lock, list);
- if (lock->cookie == cookie)
- goto do_ast;
- }
-
- dlmprintk("eek! got %sast for unknown lock! cookie=%llu, "
- "name=%*s, namelen=%d\n",
- past->type == DLM_AST ? "" : "b",
- cookie, lockname.len, lockname.name, lockname.len);
- spin_unlock(&res->spinlock);
- if (!dlm_is_recovery_lock(past->name, past->namelen))
- up_read(&dlm->recovery_sem);
- ret = DLM_NORMAL;
- goto leave;
-
-do_ast:
- ret = DLM_NORMAL;
- if (past->type == DLM_AST) {
- list_del(&lock->list);
- list_add_tail(&lock->list, &res->granted);
- dlmprintk("ast: adding to granted list... type=%d, "
- "convert_type=%d\n", lock->type, lock->convert_type);
- if (lock->convert_type != LKM_IVMODE) {
- lock->type = lock->convert_type;
- lock->convert_type = LKM_IVMODE;
- } else {
- // should already be there....
- }
-
- lock->lksb->status = DLM_NORMAL;
-
- /* if we requested the lvb, fetch it into our lksb now */
- if (flags & LKM_GET_LVB) {
- DLM_ASSERT(lock->lksb->flags & DLM_LKSB_GET_LVB);
- memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN);
- }
- status = dlm_do_ast(dlm, res, lock);
- dlmprintk("ast done: now... type=%d, convert_type=%d\n",
- lock->type, lock->convert_type);
- } else {
- dlmprintk("bast: before... type=%d, convert_type=%d\n",
- lock->type, lock->convert_type);
- status = dlm_do_bast(dlm, res, lock, past->blocked_type);
- dlmprintk("bast: after... type=%d, convert_type=%d\n",
- lock->type, lock->convert_type);
- }
-
- if (status < 0)
- dlmprintk("eeek: ast/bast returned %d\n", status);
-
- spin_unlock(&res->spinlock);
- if (!dlm_is_recovery_lock(past->name, past->namelen))
- up_read(&dlm->recovery_sem);
-
-leave:
- return ret;
-}
-
-static int dlm_send_proxy_ast(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int type, int blocked_type)
-{
- int ret = 0;
- dlm_proxy_ast past;
- struct inode *inode = NULL;
- struct iovec iov[2];
- size_t iovlen = 1;
-
- dlmprintk("res %*s, to=%u, type=%d, blocked_type=%d\n",
- res->lockname.len, res->lockname.name, lock->node,
- type, blocked_type);
-
-
- memset(&past, 0, sizeof(dlm_proxy_ast));
- past.node_idx = dlm->group_index;
- past.type = type;
- past.blocked_type = blocked_type;
- past.namelen = res->lockname.len;
- strncpy(past.name, res->lockname.name, past.namelen);
- past.cookie = lock->cookie;
-
- iov[0].iov_len = sizeof(dlm_proxy_ast);
- iov[0].iov_base = &past;
- if (lock->lksb->flags & DLM_LKSB_GET_LVB) {
- past.flags |= LKM_GET_LVB;
- iov[1].iov_len = DLM_LVB_LEN;
- iov[1].iov_base = lock->lksb->lvb;
- iovlen++;
- }
-
- ret = -EINVAL;
- inode = nm_get_group_node_by_index(dlm->group, lock->node);
- if (inode) {
- dlm_proxy_ast_to_net(&past);
- ret = net_send_message_iov(DLM_PROXY_AST_MSG, dlm->key,
- iov, iovlen, inode, NULL);
- iput(inode);
- }
- if (ret < 0)
- dlmprintk("(%d) dlm_send_proxy_ast: returning %d\n",
- current->pid, ret);
- return ret;
-}
-
-
Deleted: trunk/fs/ocfs2/cluster/dlmcommon.h
===================================================================
--- trunk/fs/ocfs2/cluster/dlmcommon.h 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmcommon.h 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,52 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmcommon.h
- *
- * Common stuff
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#ifndef CLUSTER_DLMCOMMON_H
-#define CLUSTER_DLMCOMMON_H
-
-#define DLM_ASSERT(x) ({ if (!(x)) { printk("assert failed! %s:%d\n", __FILE__, __LINE__); BUG(); } })
-
-typedef struct _nm_ctxt nm_ctxt;
-typedef struct _dlm_ctxt dlm_ctxt;
-typedef struct _heartbeat_ctxt heartbeat_ctxt;
-
-#define CLUSTER_DISK_UUID_LEN 32 // 16 byte binary == 32 char hex string
-
-typedef struct _cluster_disk
-{
- // uuid of disk
- char uuid[CLUSTER_DISK_UUID_LEN+1];
- // all the rest are for heartbeat
- dev_t dev;
- u32 blocksize_bits;
- u32 num_blocks;
- u64 start_block;
- util_rarray slots;
-} cluster_disk;
-
-
-#endif /* CLUSTER_DLMCOMMON_H */
Deleted: trunk/fs/ocfs2/cluster/dlmconvert.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmconvert.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmconvert.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,457 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmconvert.c
- *
- * underlying calls for lock conversion
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-
-/* NOTE: __dlmconvert_master is the only function in here that
- * needs a spinlock held on entry (res->spinlock) and it is the
- * only one that holds a lock on exit (res->spinlock).
- * All other functions in here need no locks and drop all of
- * the locks that they acquire. */
-static dlm_status __dlmconvert_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type,
- int *call_ast, int *kick_thread);
-static dlm_status dlm_send_remote_convert_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type);
-
-/*
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock
- * held on exit: none
- * returns: see __dlmconvert_master
- */
-dlm_status dlmconvert_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type)
-{
- int call_ast = 0, kick_thread = 0;
- dlm_status status;
-
-#warning i think i need some IN_PROGRESS work here
- spin_lock(&res->spinlock);
- status = __dlmconvert_master(dlm, res, lock, flags, type,
- &call_ast, &kick_thread);
- spin_unlock(&res->spinlock);
-
-#warning fix all ast calling!!!
- if (call_ast)
- if (dlm_do_ast(dlm, res, lock) < 0)
- dlmprintk0("eek\n");
-
- if (kick_thread)
- dlm_kick_thread(dlm, res);
-
- return status;
-}
-
-/* performs lock conversion at the lockres master site
- * locking:
- * caller needs: res->spinlock
- * taken: takes and drops lock->spinlock
- * held on exit: res->spinlock
- * returns: DLM_NORMAL, DLM_NOTQUEUED, DLM_DENIED
- * call_ast: whether ast should be called for this lock
- * kick_thread: whether dlm_kick_thread should be called
- */
-static dlm_status __dlmconvert_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type,
- int *call_ast, int *kick_thread)
-{
- dlm_status status = DLM_NORMAL;
- struct list_head *iter;
- dlm_lock *tmplock=NULL;
-
- dlmprintk("type=%d, convert_type=%d, new convert_type=%d\n", lock->type,
- lock->convert_type, type);
-
- spin_lock(&lock->spinlock);
-
- /* already converting? */
- if (lock->convert_type != LKM_IVMODE) {
- dlmprintk0("attempted to convert a lock with a lock conversion "
- "pending\n");
- status = DLM_DENIED;
- goto unlock_exit;
- }
-
- /* must be on grant queue to convert */
- if (!dlm_lock_on_list(&res->granted, lock)) {
- dlmprintk0("attempted to convert a lock not on grant queue\n");
- status = DLM_DENIED;
- goto unlock_exit;
- }
-
- if (flags & LKM_VALBLK) {
- switch (lock->type) {
- case LKM_EXMODE:
- /* EX + LKM_VALBLK + convert == set lvb */
- dlmprintk("will set lvb: converting %s->%s\n",
- dlm_lock_mode_name(lock->type),
- dlm_lock_mode_name(type));
- lock->lksb->flags |= DLM_LKSB_PUT_LVB;
- break;
- case LKM_PRMODE:
- case LKM_NLMODE:
- /* refetch if new level is not NL */
- if (type > LKM_NLMODE) {
- dlmprintk("will fetch new value into "
- "lvb: converting %s->%s\n",
- dlm_lock_mode_name(lock->type),
- dlm_lock_mode_name(type));
- lock->lksb->flags |= DLM_LKSB_GET_LVB;
- } else {
- dlmprintk("will NOT fetch new value "
- "into lvb: converting "
- "%s->%s\n",
- dlm_lock_mode_name(lock->type),
- dlm_lock_mode_name(type));
- flags &= ~(LKM_VALBLK);
- }
- break;
- }
- }
-
-
- /* in-place downconvert? */
- if (type <= lock->type)
- goto grant;
-
- /* upconvert from here on */
- status = DLM_NORMAL;
- list_for_each(iter, &res->granted) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (tmplock == lock)
- continue;
- if (!dlm_lock_compatible(tmplock->type, type))
- goto switch_queues;
- }
-
- list_for_each(iter, &res->converting) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (!dlm_lock_compatible(tmplock->type, type))
- goto switch_queues;
- /* existing conversion requests take precedence */
- if (!dlm_lock_compatible(tmplock->convert_type, type))
- goto switch_queues;
- }
-
- /* fall thru to grant */
-
-grant:
- dlmprintk("res %*s, granting %s lock\n", res->lockname.len,
- res->lockname.name, dlm_lock_mode_name(type));
- /* immediately grant the new lock type */
- lock->lksb->status = DLM_NORMAL;
- if (lock->node == dlm->group_index)
- dlmprintk0("doing in-place convert for nonlocal lock\n");
- lock->type = type;
- status = DLM_NORMAL;
- *call_ast = 1;
- goto unlock_exit;
-
-switch_queues:
- if (flags & LKM_NOQUEUE) {
- dlmprintk("failed to convert NOQUEUE lock %*s from "
- "%d to %d...\n", res->lockname.len,
- res->lockname.name, lock->type, type);
- status = DLM_NOTQUEUED;
- goto unlock_exit;
- }
- dlmprintk("res %*s, queueing...\n", res->lockname.len,
- res->lockname.name);
-
- lock->convert_type = type;
- list_del(&lock->list);
- list_add_tail(&lock->list, &res->converting);
-
-unlock_exit:
- spin_unlock(&lock->spinlock);
- if (status == DLM_NORMAL)
- *kick_thread = 1;
- return status;
-}
-
-/* messages the master site to do lock conversion
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock, uses DLM_LOCK_RES_IN_PROGRESS
- * held on exit: none
- * returns: DLM_NORMAL, DLM_RECOVERING, status from remote node
- */
-dlm_status dlmconvert_remote(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type)
-{
- dlm_status status;
-
- dlmprintk("type=%d, convert_type=%d, busy=%d\n", lock->type,
- lock->convert_type, res->state & DLM_LOCK_RES_IN_PROGRESS);
-
- spin_lock(&res->spinlock);
- if (res->state & DLM_LOCK_RES_RECOVERING) {
- status = DLM_RECOVERING;
- goto bail;
- }
- /* will exit this call with spinlock held */
- __dlm_wait_on_lockres(res);
-
- res->state |= DLM_LOCK_RES_IN_PROGRESS;
-
- /* move lock to local convert queue */
- list_del(&lock->list);
- list_add_tail(&lock->list, &res->converting);
- if (lock->convert_type != LKM_IVMODE) {
- dlmprintk0("error! converting a remote lock that is already "
- "converting!\n");
- /* TODO: return correct error */
- BUG();
- }
- lock->convert_type = type;
-
- if (flags & LKM_VALBLK) {
- if (lock->type == LKM_EXMODE) {
- flags |= LKM_PUT_LVB;
- lock->lksb->flags |= DLM_LKSB_PUT_LVB;
- } else {
- if (lock->convert_type == LKM_NLMODE) {
- dlmprintk0("erm, no point in specifying "
- "LKM_VALBLK if converting to NL\n");
- flags &= ~LKM_VALBLK;
- } else {
- flags |= LKM_GET_LVB;
- lock->lksb->flags |= DLM_LKSB_GET_LVB;
- }
- }
- }
- spin_unlock(&res->spinlock);
-
- /* no locks held here.
- * need to wait for a reply as to whether it got queued or not. */
- status = dlm_send_remote_convert_request(dlm, res, lock, flags, type);
-
- spin_lock(&res->spinlock);
- res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
-
- /* if it failed, move it back to granted queue */
- if (status != DLM_NORMAL) {
- list_del(&lock->list);
- list_add_tail(&lock->list, &res->granted);
- lock->convert_type = LKM_IVMODE;
- lock->lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB);
- }
-bail:
- spin_unlock(&res->spinlock);
-
- /* TODO: should this be a wake_one? */
- /* wake up any IN_PROGRESS waiters */
- wake_up(&res->wq);
-
- return status;
-}
-
-/* sends DLM_CONVERT_LOCK_MSG to master site
- * locking:
- * caller needs: none
- * taken: none
- * held on exit: none
- * returns: DLM_NOLOCKMGR, status from remote node
- */
-static dlm_status dlm_send_remote_convert_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type)
-{
- struct inode *inode = NULL;
- dlm_convert_lock convert;
- int tmpret;
- dlm_status ret;
- int status = 0;
- struct iovec iov[2];
- size_t iovlen = 1;
-
- dlmprintk0("\n");
-
- memset(&convert, 0, sizeof(dlm_convert_lock));
- convert.node_idx = dlm->group_index;
- convert.requested_type = type;
- convert.cookie = lock->cookie;
- convert.namelen = res->lockname.len;
- convert.flags = flags;
- strncpy(convert.name, res->lockname.name, convert.namelen);
-
- iov[0].iov_len = sizeof(dlm_convert_lock);
- iov[0].iov_base = &convert;
-
- if (flags & LKM_PUT_LVB) {
- /* extra data to send if we are updating lvb */
- iov[1].iov_len = DLM_LVB_LEN;
- iov[1].iov_base = lock->lksb->lvb;
- iovlen++;
- }
-
- ret = DLM_NOLOCKMGR;
- inode = nm_get_group_node_by_index(dlm->group, res->owner);
- if (inode) {
- dlm_convert_lock_to_net(&convert);
- tmpret = net_send_message_iov(DLM_CONVERT_LOCK_MSG, dlm->key,
- iov, iovlen, inode, &status);
- if (tmpret >= 0) {
- // successfully sent and received
- ret = status; // this is already a dlm_status
- } else {
- dlmprintk("error occurred in net_send_message: %d\n",
- tmpret);
- ret = dlm_err_to_dlm_status(tmpret);
- }
- iput(inode);
- }
-
- return ret;
-}
-
-
-/* handler for DLM_CONVERT_LOCK_MSG on master site
- * locking:
- * caller needs: none
- * taken: takes and drop res->spinlock
- * held on exit: none
- * returns: DLM_NORMAL, DLM_IVLOCKID, DLM_BADARGS,
- * status from __dlmconvert_master
- */
-int dlm_convert_lock_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_convert_lock *cnv = (dlm_convert_lock *)msg->buf;
- dlm_lock_resource *res = NULL;
- struct list_head *iter;
- dlm_lock *lock = NULL;
- dlm_lockstatus *lksb;
- dlm_status status = DLM_NORMAL;
- struct qstr lockname;
- u32 flags;
- int call_ast = 0, kick_thread = 0;
- int found = 0;
-
- dlm_convert_lock_to_host(cnv);
- lockname.name = cnv->name;
- lockname.len = cnv->namelen;
- flags = cnv->flags;
-
- if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
- (LKM_PUT_LVB|LKM_GET_LVB)) {
- dlmprintk("both PUT and GET lvb specified\n");
- status = DLM_BADARGS;
- goto leave;
- }
-
- dlmprintk("lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" :
- (flags & LKM_GET_LVB ? "get lvb" : "none"));
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- status = DLM_IVLOCKID;
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res)
- goto leave;
-
- spin_lock(&res->spinlock);
- list_for_each(iter, &res->granted) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock->cookie == cnv->cookie &&
- lock->node == cnv->node_idx) {
- found = 1;
- break;
- }
- }
- spin_unlock(&res->spinlock);
- if (!found)
- goto leave;
-
- /* found the lock */
- lksb = lock->lksb;
-
- /* see if caller needed to get/put lvb */
- if (flags & LKM_PUT_LVB) {
- DLM_ASSERT(!(lksb->flags &
- (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)));
- lksb->flags |= DLM_LKSB_PUT_LVB;
- memcpy(&lksb->lvb[0], &cnv->lvb[0], DLM_LVB_LEN);
- } else if (flags & LKM_GET_LVB) {
- DLM_ASSERT(!(lksb->flags &
- (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)));
- lksb->flags |= DLM_LKSB_GET_LVB;
- }
-
-#warning i think we need some handling of IN_PROGRESS here!
- status = __dlmconvert_master(dlm, res, lock, flags, cnv->requested_type,
- &call_ast, &kick_thread);
-
- if (status != DLM_NORMAL)
- lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB);
-
-leave:
- if (!lock)
- dlmprintk("did not find lock to convert on "
- "grant queue! cookie=%llu\n", cnv->cookie);
-
-#warning fix all ast calling!!!
- if (call_ast)
- if (dlm_do_ast(dlm, res, lock) < 0)
- dlmprintk0("eek\n");
- if (kick_thread)
- dlm_kick_thread(dlm, res);
-
- return status;
-}
Deleted: trunk/fs/ocfs2/cluster/dlmlock.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmlock.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmlock.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,334 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmlock.c
- *
- * underlying calls for lock creation
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-static dlm_status dlm_send_remote_lock_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock, int flags);
-
-/* performs lock creation at the lockres master site
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock
- * held on exit: none
- * returns: DLM_NORMAL, DLM_NOTQUEUED
- */
-dlm_status dlmlock_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags)
-{
- struct list_head *iter;
- dlm_lock *tmplock;
- int call_ast = 0;
- dlm_status status = DLM_NORMAL;
-
- DLM_ASSERT(lock);
- DLM_ASSERT(res);
- DLM_ASSERT(dlm);
- DLM_ASSERT(lock->lksb);
-
- dlmprintk("type=%d\n", lock->type);
-
- /* this will effectively spin_lock(&res->spinlock) */
- dlm_wait_on_lockres(res);
- res->state |= DLM_LOCK_RES_IN_PROGRESS;
-
- /* for NOQUEUE request, unless we get
- * lock right away, return DLM_NOTQUEUED */
- if (flags & LKM_NOQUEUE)
- status = DLM_NOTQUEUED;
-
- list_for_each(iter, &res->granted) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (!dlm_lock_compatible(tmplock->type, lock->type)) {
- list_add_tail(&lock->list, &res->blocked);
- goto done;
- }
- }
-
- list_for_each(iter, &res->converting) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (!dlm_lock_compatible(tmplock->type, lock->type)) {
- list_add_tail(&lock->list, &res->blocked);
- goto done;
- }
- }
-
- /* got it right away */
- lock->lksb->status = DLM_NORMAL;
- status = DLM_NORMAL;
- list_add_tail(&lock->list, &res->granted);
- call_ast = 1;
-
-done:
- res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
- spin_unlock(&res->spinlock);
- wake_up(&res->wq);
-
- dlm_kick_thread(dlm, res);
-
- if (call_ast) {
-#warning fix all ast calling!!!
- if (dlm_do_ast(dlm, res, lock) < 0)
- dlmprintk0("eek\n");
- }
-
- return status;
-}
-
-/*
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock
- * held on exit: none
- * returns: DLM_DENIED, DLM_RECOVERING, or net status
- */
-dlm_status dlmlock_remote(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags)
-{
- dlm_status status = DLM_DENIED;
-
- dlmprintk("type=%d\n", lock->type);
-
- spin_lock(&res->spinlock);
- if (res->state & DLM_LOCK_RES_RECOVERING) {
- status = DLM_RECOVERING;
- goto bail;
- }
-
- /* will exit this call with spinlock held */
- __dlm_wait_on_lockres(res);
- res->state |= DLM_LOCK_RES_IN_PROGRESS;
- /* add lock to local (secondary) queue */
- list_add_tail(&lock->list, &res->blocked);
- spin_unlock(&res->spinlock);
-
- /* spec seems to say that you will get DLM_NORMAL when the lock
- * has been queued, meaning we need to wait for a reply here. */
- status = dlm_send_remote_lock_request(dlm, res, lock, flags);
-
- spin_lock(&res->spinlock);
- res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
- if (status != DLM_NORMAL) {
- /* remove from local queue if it failed */
- list_del(&lock->list);
- }
-bail:
- spin_unlock(&res->spinlock);
- wake_up(&res->wq);
- return status;
-}
-
-
-/* for remote lock creation.
- * locking:
- * caller needs: none, but need res->state & DLM_LOCK_RES_IN_PROGRESS
- * taken: none
- * held on exit: none
- * returns: DLM_NOLOCKMGR, or net status
- */
-static dlm_status dlm_send_remote_lock_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock, int flags)
-{
- struct inode *inode = NULL;
- dlm_create_lock create;
- int tmpret, status = 0;
- dlm_status ret;
-
- dlmprintk0("\n");
-
- memset(&create, 0, sizeof(create));
- create.node_idx = dlm->group_index;
- create.requested_type = lock->type;
- create.cookie = lock->cookie;
- create.namelen = res->lockname.len;
- create.flags = flags;
- strncpy(create.name, res->lockname.name, create.namelen);
-
- ret = DLM_NOLOCKMGR;
- inode = nm_get_group_node_by_index(dlm->group, res->owner);
- if (inode) {
- dlm_create_lock_to_net(&create);
- tmpret = net_send_message(DLM_CREATE_LOCK_MSG, dlm->key,
- &create, sizeof(create),
- inode, &status);
- if (tmpret >= 0) {
- // successfully sent and received
- ret = status; // this is already a dlm_status
- } else {
- dlmprintk("error occurred in net_send_message: %d\n",
- tmpret);
- ret = dlm_err_to_dlm_status(tmpret);
- }
- iput(inode);
- }
-
- return ret;
-}
-
-/* handler for lock creation net message
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock
- * held on exit: none
- * returns: DLM_NORMAL, DLM_SYSERR, DLM_IVLOCKID, DLM_NOTQUEUED
- */
-int dlm_create_lock_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_create_lock *create = (dlm_create_lock *)msg->buf;
- dlm_lock_resource *res;
- dlm_lock *newlock = NULL, *tmplock;
- dlm_lockstatus *lksb = NULL;
- dlm_status status = DLM_NORMAL;
- struct qstr lockname;
- struct list_head *iter;
- int call_ast = 0;
-
- DLM_ASSERT(dlm);
-
- dlm_create_lock_to_host(create);
- lockname.name = create->name;
- lockname.len = create->namelen;
-
- dlmprintk0("\n");
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- status = DLM_SYSERR;
- newlock = kmalloc(sizeof(dlm_lock), GFP_KERNEL);
- if (!newlock)
- goto leave;
-
- lksb = kmalloc(sizeof(dlm_lockstatus), GFP_KERNEL);
- if (!lksb)
- goto leave;
-
- memset(newlock, 0, sizeof(dlm_lock));
- INIT_LIST_HEAD(&newlock->list);
- INIT_LIST_HEAD(&newlock->ast_list);
- spin_lock_init(&newlock->spinlock);
- newlock->type = create->requested_type;
- newlock->convert_type = LKM_IVMODE;
- newlock->highest_blocked = LKM_IVMODE;
- newlock->node = create->node_idx;
- newlock->ast = NULL;
- newlock->bast = NULL;
- newlock->astdata = NULL;
- newlock->cookie = create->cookie;
-
- memset(lksb, 0, sizeof(dlm_lockstatus));
- newlock->lksb = lksb;
- lksb->lockid = newlock;
- lksb->flags |= DLM_LKSB_KERNEL_ALLOCATED;
-
- status = DLM_IVLOCKID;
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res)
- goto leave;
-
- /* found lock resource */
- status = DLM_NORMAL;
- spin_lock(&res->spinlock);
- newlock->lockres = res;
-
- /* for NOQUEUE request, unless we get
- * lock right away, return DLM_NOTQUEUED */
- if (create->flags & LKM_NOQUEUE)
- status = DLM_NOTQUEUED;
-
- /* see if any granted locks are blocking us */
- list_for_each(iter, &res->granted) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (!dlm_lock_compatible(tmplock->type, newlock->type)) {
- list_add_tail(&newlock->list, &res->blocked);
- goto blocked;
- }
- }
- list_for_each(iter, &res->converting) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (!dlm_lock_compatible(tmplock->type, newlock->type)){
- list_add_tail(&newlock->list, &res->blocked);
- goto blocked;
- }
- }
-
- /* got it right away */
- newlock->lksb->status = DLM_NORMAL;
- status = DLM_NORMAL;
- list_add_tail(&newlock->list, &res->granted);
- call_ast = 1;
-
-blocked:
- spin_unlock(&res->spinlock);
-
-#warning fix all ast calling!!!
- if (call_ast)
- if (dlm_do_ast(dlm, res, newlock) < 0)
- dlmprintk0("eek\n");
-
- dlm_kick_thread(dlm, res);
-
-leave:
- if (status != DLM_NORMAL) {
- if (newlock)
- kfree(newlock);
- if (lksb)
- kfree(lksb);
- }
-
- return status;
-}
Deleted: trunk/fs/ocfs2/cluster/dlmmaster.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmmaster.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmmaster.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,1071 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmmod.c
- *
- * standalone DLM module
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-spinlock_t dlm_master_lock = SPIN_LOCK_UNLOCKED;
-LIST_HEAD(dlm_master_list);
-
-/* gives a really vague idea of the system load */
-atomic_t dlm_num_resources = ATOMIC_INIT(0);
-
-
-static int dlm_init_mle(dlm_master_list_entry *mle, int type, dlm_ctxt *dlm,
- dlm_lock_resource *res, struct qstr *name, int locked);
-static void dlm_put_mle(dlm_master_list_entry *mle);
-static int dlm_do_master_request_resp(dlm_ctxt *dlm, struct qstr *name,
- int response, int to);
-static int dlm_do_master_request(dlm_master_list_entry *mle, int to);
-static int dlm_do_assert_master(dlm_master_list_entry *mle);
-static void dlm_mle_node_up(struct inode *group, struct inode *node,
- int idx, void *data);
-static void dlm_mle_node_down(struct inode *group, struct inode *node,
- int idx, void *data);
-
-
-
-
-/* remove from list and free */
-static void dlm_put_mle(dlm_master_list_entry *mle)
-{
- if (atomic_dec_and_lock(&mle->refcnt, &dlm_master_lock)) {
- list_del(&mle->list);
- spin_unlock(&dlm_master_lock);
- hb_unregister_callback(HB_NODE_DOWN_CB, dlm_mle_node_down, mle);
- hb_unregister_callback(HB_NODE_UP_CB, dlm_mle_node_up, mle);
- kfree(mle);
- }
-}
-
-static inline void dlm_get_mle(dlm_master_list_entry *mle)
-{
- atomic_inc(&mle->refcnt);
-}
-
-
-
-static int dlm_init_mle(dlm_master_list_entry *mle, int type, dlm_ctxt *dlm,
- dlm_lock_resource *res, struct qstr *name, int locked)
-{
- int ret = 0;
-
- mle->dlm = dlm;
- mle->type = type;
- INIT_LIST_HEAD(&mle->list);
- memset(mle->maybe_map, 0, sizeof(mle->maybe_map));
- spin_lock_init(&mle->spinlock);
- init_waitqueue_head(&mle->wq);
- atomic_set(&mle->woken, 0);
- atomic_set(&mle->refcnt, 1);
- memset(mle->response_map, 0, sizeof(mle->response_map));
- mle->master = NM_MAX_NODES;
- mle->error = 0;
-
- if (mle->type == DLM_MLE_MASTER)
- mle->u.res = res;
- else
- strncpy(mle->u.name.name, name->name, name->len);
-
- if (!locked)
- spin_lock(&dlm->spinlock);
-
- /* copy off the node_map and register hb callbacks on our copy */
- memcpy(mle->node_map, dlm->node_map, sizeof(mle->node_map));
- memcpy(mle->vote_map, dlm->node_map, sizeof(mle->vote_map));
- clear_bit(dlm->group_index, mle->vote_map);
- clear_bit(dlm->group_index, mle->node_map);
-
-#warning cannot do this here cuz this kmallocs and we are under a spinlock
- if (hb_register_callback(HB_NODE_DOWN_CB, dlm_mle_node_down, mle,
- DLM_HB_NODE_DOWN_PRI+1)
- ||
- hb_register_callback(HB_NODE_UP_CB, dlm_mle_node_up, mle,
- DLM_HB_NODE_UP_PRI+1)) {
- ret = -EINVAL;
- }
-
- if (!locked)
- spin_unlock(&dlm->spinlock);
-
- return ret;
-}
-
-
-
-
-/////////////////////////////////////////////////
-//
-// TODO: change these comments to reflect reality
-//
-// master_request(target=me)
-// wait for all responses
-// if maybe_map is 0 there are no others in progress
-// assert_master(me)
-// else (maybe_map has some nodes in it)
-// (nodes in maybe_map had better be < my node num)
-// wait for assert_master
-// endif
-//
-//
-// receive:
-// master_request(target):
-// if i own it, return YES
-// if i dont know anything about it, return NO
-// if i have it in progress
-// if my node number is lower
-// return MAYBE
-// else
-// if target < lowest_so_far, lowest_so_far=target
-// return NO
-//
-// assert_master(master):
-// if i own it, BUG()!!!
-// if i have it, but owner!=master, BUG()!!!
-// if i dont know anything about it, ignore
-// if i have it in progress
-// if lowest_so_far != master
-// BUG()!!!
-// else
-// set the owner, DONE
-//
-/////////////////////////////////////////////////
-
-
-
-
-/*
- * lookup a lock resource by name.
- * may already exist in the hashtable.
- *
- * if not, allocate enough for the lockres and for
- * the temporary structure used in doing the mastering.
- *
- * also, do a lookup in the dlm_master_list to see
- * if another node has begun mastering the same lock.
- * if so, there should be a block entry in there
- * for this name, and we should *not* attempt to master
- * the lock here. need to wait around for that node
- * to assert_master (or die).
- *
- */
-dlm_lock_resource * dlm_get_lock_resource(dlm_ctxt *dlm,
- struct qstr *lockname, int flags)
-{
- dlm_lock_resource *tmpres=NULL, *res=NULL;
- struct list_head *bucket;
- dlm_master_list_entry *mle = NULL, *tmpmle = NULL;
- struct list_head *iter;
- int blocked = 0;
- int map_changed = 0, restart = 0, assert = 0;
- int ret, start, bit;
-
- bucket = &(dlm->resources[lockname->hash & DLM_HASH_MASK]);
-
- /* pre-allocate a dlm_lock_resource and master stuff */
- mle = kmalloc(sizeof(dlm_master_list_entry), GFP_KERNEL);
- res = kmalloc(sizeof(dlm_lock_resource), GFP_KERNEL);
- if (!mle || !res) {
- dlmprintk0("could not allocate memory for new lock resource\n");
- if (mle)
- kfree(mle);
- if (res)
- kfree(res);
- res = NULL;
- goto leave;
- }
-
- /* check for pre-existing lock */
- spin_lock(&dlm->spinlock);
- tmpres = __dlm_lookup_lock(dlm, lockname);
- if (tmpres) {
- spin_unlock(&dlm->spinlock);
- /* TODO: return error, or return the lockres ?!? */
- kfree(res);
- kfree(mle);
- res = tmpres;
- goto leave;
- }
-
- dlm_init_lockres(res, lockname);
-
- if (flags & LKM_LOCAL) {
- /* caller knows it's safe to assume it's not mastered elsewhere
- * DONE! return right away */
- list_add_tail(&res->list, bucket);
- res->owner = dlm->group_index;
- atomic_inc(&dlm_num_resources);
- spin_unlock(&dlm->spinlock);
- /* lockres still marked IN_PROGRESS */
- goto wake_waiters;
- }
-
- /* check master list to see if another node has started mastering it */
- spin_lock(&dlm_master_lock);
- list_for_each(iter, &dlm_master_list) {
- tmpmle = list_entry(iter, dlm_master_list_entry, list);
- if (!dlm_mle_equal(dlm, tmpmle, lockname))
- continue;
-
- if (tmpmle->type == DLM_MLE_MASTER) {
- dlmprintk0("eek! master entry for nonexistent lock!\n");
- BUG();
- }
- dlm_get_mle(tmpmle);
- blocked = 1;
- // found a block, wait for lock to be mastered by another node
- break;
- }
-
- if (!blocked) {
- /* go ahead and try to master lock on this node */
- if (dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 1)) {
- dlmprintk0("bug! failed to register hb callbacks\n");
- BUG();
- }
- list_add(&mle->list, &dlm_master_list);
- }
- spin_unlock(&dlm_master_lock);
-
- /* at this point there is either a DLM_MLE_BLOCK or a DLM_MLE_MASTER
- * on the master list, so it's safe to add the lockres to the hashtable.
- * anyone who finds the lock will still have to wait on the IN_PROGRESS.
- * also, any new nodes that try to join at this point will have to wait
- * until my dlm_master_lock list is empty, so they cannot possibly
- * do any master requests yet... TODO
- * ?? should i have a special type of mle just for joining nodes ??
- * ?? could allow them to come in and put their mle
- * on the list and sleep ?? */
-
- /* finally add the lockres to its hash bucket */
- list_add_tail(&res->list, bucket);
- atomic_inc(&dlm_num_resources);
- spin_unlock(&dlm->spinlock);
-
- if (blocked) {
- /* must wait for lock to be mastered elsewhere */
- kfree(mle);
- mle = tmpmle;
- goto wait;
- }
-
- ret = -EINVAL;
- start = 0;
- while (1) {
- bit = find_next_bit (mle->vote_map, NM_MAX_NODES, start);
- if (bit >= NM_MAX_NODES) {
- dlmprintk0("no more nodes\n");
- break;
- }
-
- ret = dlm_do_master_request(mle, bit);
- if (ret < 0) {
- // TODO
- //dlmprintk("dlm_do_master_request returned %d\n", ret);
- }
- if (mle->master != NM_MAX_NODES) {
- // found a master!
- break;
- }
- start = bit+1;
- }
-
-wait:
- while (1) {
- spin_lock(&res->spinlock);
- if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
- // another node has become the owner
- spin_unlock(&res->spinlock);
- break;
- }
- spin_unlock(&res->spinlock);
-
- spin_lock(&mle->spinlock);
- if (mle->master != NM_MAX_NODES) {
- u16 m = mle->master;
- // dlmprintk("node %u is the master!\n", m);
- spin_unlock(&mle->spinlock);
-
- spin_lock(&res->spinlock);
- res->owner = m;
- spin_unlock(&res->spinlock);
- break;
- }
- restart = 0;
- map_changed = (memcmp(mle->vote_map, mle->node_map,
- sizeof(mle->vote_map)) != 0);
- if (memcmp(mle->vote_map, mle->response_map,
- sizeof(mle->vote_map)) == 0) {
- // dlmprintk("every node has responded...\n");
- if (map_changed) {
- dlmprintk0("eek! got all original nodes, but "
- "nodemap changed while collecting "
- "responses\n");
- restart = 1;
- }
-
- if (mle->error) {
- dlmprintk0("ugh. some node hit an error "
- "(-ENOMEM). try the whole thing "
- "again\n");
- mle->error = 0;
- /* TODO: treat this just like the dead node
- * case below, cleanup and start over, but
- * keep the error node around */
- restart = 1;
- }
-
- bit = find_next_bit(mle->maybe_map, NM_MAX_NODES, 0);
- if (bit >= NM_MAX_NODES) {
- /* No other nodes are in-progress. Those nodes
- * should all be locking out this lockid until
- * I assert. They should have put a dummy entry
- * on dlm_master_list. Need to assert myself as
- * the master. */
- // dlmprintk0("I am the only node in-progress!"
- // " asserting myself as master\n");
- assert = 1;
- } else {
- /* other nodes are in-progress */
- if (map_changed &&
- !test_bit(bit, mle->node_map)) {
- /* TODO: need to copy the node_map into
- * the vote_map, zero everything out
- * and start over */
- dlmprintk("need to handle this case. "
- "winning node %u just died\n",
- bit);
- restart = 1;
- }
-
- if (bit > dlm->group_index) {
- // dlmprintk("next in-progress node "
- // "(%u) is higher than me (%u)\n",
- // bit, dlm->group_index);
-
- /* Nodes not in-progress should be
- * locking out this lockid until I
- * assert. In-progress nodes should
- * match me up with their lowest
- * maybe_map bit. Need to assert myself
- * as the master */
- // dlmprintk("I am the lowest node! "
- // "asserting myself as master\n");
- assert = 1;
- } else {
- /* Need to sit around and wait for
- * assert. My lowest maybe_map bit
- * should be the one to assert. Just
- * fall through and sleep. Should be
- * woken by the handler. */
- // dlmprintk("sleeping while waiting "
- // "for %u to assert himself as "
- // "master\n", bit);
- }
- }
- } else {
- if (map_changed) {
- /* TODO: need to handle this */
- dlmprintk0("eek! nodemap changed while "
- "collecting responses\n");
- restart = 1;
- }
- // dlmprintk0("still waiting for all nodes to "
- // "respond...\n");
- }
-
- if (restart && assert)
- assert = 0;
-
- /* make sure to tell any other nodes that i am mastering this */
- if (assert)
- mle->master = dlm->group_index;
-
- spin_unlock(&mle->spinlock);
-
- if (assert) {
- ret = dlm_do_assert_master(mle);
- // dlmprintk("assert returned %d!\n", ret);
- if (ret == 0) {
- spin_lock(&res->spinlock);
- res->owner = dlm->group_index;
- spin_unlock(&res->spinlock);
- // dlmprintk("wooo! i am the owner. phew!\n");
- break;
- } else
- restart = 1;
- }
- if (restart) {
- dlmprintk0("something happened such that the master "
- "process needs to be restarted!\n");
- /* TODO: clear it all out and start over */
- }
-
- atomic_set(&mle->woken, 0);
- ret = util_wait_atomic_eq(&mle->wq, &mle->woken, 1, 5000);
- if (ret == -EINTR) {
- dlmprintk0("interrupted during lock mastery!\n");
- break;
- }
- if (ret == -ETIMEDOUT) {
- dlmprintk("timed out during lock mastery: "
- "vote_map=%0lx, response_map=%0lx\n",
- mle->vote_map[0], mle->response_map[0]);
- continue;
- }
- }
- dlm_put_mle(mle);
-
-wake_waiters:
- spin_lock(&res->spinlock);
- res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
- spin_unlock(&res->spinlock);
- wake_up(&res->wq);
-
-leave:
- return res;
-}
-
-
-
-
-/*
- * locks that can be taken here:
- * dlm->spinlock
- * res->spinlock
- * mle->spinlock
- * dlm_master_list
- *
- * if possible, TRIM THIS DOWN!!!
- */
-int dlm_master_request_handler(net_msg *msg, u32 len, void *data)
-{
- u8 response = DLM_MASTER_RESP_MAYBE;
- dlm_ctxt *dlm = data;
- dlm_lock_resource *res;
- dlm_master_request *request = (dlm_master_request *) msg->buf;
- dlm_master_list_entry *mle = NULL, *tmpmle = NULL;
- struct qstr lockname;
- int found;
- struct list_head *iter;
-
- dlm_master_request_to_host(request);
- lockname.name = request->name;
- lockname.len = request->namelen;
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
-way_up_top:
- spin_lock(&dlm->spinlock);
- res = __dlm_lookup_lock(dlm, &lockname);
- if (res) {
- spin_unlock(&dlm->spinlock);
-
- /* take care of the easy cases up front */
- spin_lock(&res->spinlock);
- if (res->owner == dlm->group_index) {
- spin_unlock(&res->spinlock);
- // dlmprintk0("this node is the master\n");
- response = DLM_MASTER_RESP_YES;
- if (mle)
- kfree(mle);
- goto send_response;
- } else if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
- spin_unlock(&res->spinlock);
- // dlmprintk("node %u is the master\n", res->owner);
- response = DLM_MASTER_RESP_NO;
- if (mle)
- kfree(mle);
- goto send_response;
- }
-
- /* ok, there is no owner. either this node is
- * being blocked, or it is actively trying to
- * master this lock. */
- if (!(res->state & DLM_LOCK_RES_IN_PROGRESS)) {
- dlmprintk0("bug! lock with no owner should be "
- "in-progress!\n");
- BUG();
- }
-
- // dlmprintk0("lockres is in progress...\n");
- found = 0;
- spin_lock(&dlm_master_lock);
- list_for_each(iter, &dlm_master_list) {
- tmpmle = list_entry(iter, dlm_master_list_entry, list);
- if (!dlm_mle_equal(dlm, tmpmle, &lockname))
- continue;
-
- dlm_get_mle(tmpmle);
- spin_lock(&tmpmle->spinlock);
- if (tmpmle->type == DLM_MLE_BLOCK) {
- // dlmprintk0("this node is waiting for "
- // "lockres to be mastered\n");
- response = DLM_MASTER_RESP_NO;
- } else {
- // dlmprintk0("this node is attempting to "
- // "master lockres\n");
- response = DLM_MASTER_RESP_MAYBE;
- }
- set_bit(request->node_idx, tmpmle->maybe_map);
- spin_unlock(&tmpmle->spinlock);
-
- spin_unlock(&dlm_master_lock);
- spin_unlock(&res->spinlock);
-
- dlm_put_mle(tmpmle);
- if (mle)
- kfree(mle);
- goto send_response;
- }
- spin_unlock(&dlm_master_lock);
- spin_unlock(&res->spinlock);
- dlmprintk0("bug bug bug!!! no mle found for this lock!\n");
- BUG();
- }
-
- /*
- * lockres doesn't exist on this node
- * if there is an MLE_BLOCK, return NO
- * if there is an MLE_MASTER, return MAYBE
- * otherwise, add an MLE_BLOCK, return NO
- */
- found = 0;
- spin_lock(&dlm_master_lock);
- list_for_each(iter, &dlm_master_list) {
- tmpmle = list_entry(iter, dlm_master_list_entry, list);
- if (!dlm_mle_equal(dlm, tmpmle, &lockname))
- continue;
- dlm_get_mle(tmpmle);
- found = 1;
- break;
- }
-
- if (!found) {
- /* this lockid has never been seen on this node yet */
- // dlmprintk0("no mle found\n");
- if (!mle) {
- spin_unlock(&dlm_master_lock);
- spin_unlock(&dlm->spinlock);
-
- mle = kmalloc(sizeof(dlm_master_list_entry) +
- lockname.len, GFP_KERNEL);
- if (!mle) {
- // bad bad bad... this sucks.
- response = DLM_MASTER_RESP_ERROR;
- goto send_response;
- }
- if (dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL,
- &lockname, 0)) {
- dlmprintk0("eeek!\n");
- response = DLM_MASTER_RESP_ERROR;
- dlm_put_mle(mle);
- goto send_response;
- }
- goto way_up_top;
- }
-
- // dlmprintk0("this is second time thru, already allocated, "
- // "add the block.\n");
- set_bit(request->node_idx, mle->maybe_map);
- list_add(&mle->list, &dlm_master_list);
- response = DLM_MASTER_RESP_NO;
- } else {
- // dlmprintk0("mle was found\n");
- spin_lock(&tmpmle->spinlock);
- if (tmpmle->type == DLM_MLE_BLOCK)
- response = DLM_MASTER_RESP_NO;
- else
- response = DLM_MASTER_RESP_MAYBE;
- set_bit(request->node_idx, tmpmle->maybe_map);
- spin_unlock(&tmpmle->spinlock);
- dlm_put_mle(tmpmle);
- }
- spin_unlock(&dlm_master_lock);
- spin_unlock(&dlm->spinlock);
-
-send_response:
- //ret = dlm_do_master_request_resp(dlm, &lockname, response,
- // request->node_idx);
- //dlmprintk("response returned %d\n", ret);
- //dlmprintk("sending response %d to other node\n", response);
- return response;
-}
-
-/* NOTE: when doing node recovery, run the dlm_master_list looking for the
- * dead node in any maybe_map... clear that bit, and if now empty, clear the
- * whole thing */
-
-/*
- * locks that can be taken here:
- * mle->spinlock
- * dlm_master_list
- *
- */
-int dlm_master_request_resp_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_master_list_entry *mle = NULL;
- dlm_master_request_resp *resp = (dlm_master_request_resp *) msg->buf;
- int found = 0, wake = 0;
- struct list_head *iter;
- struct qstr lockname;
-
- dlm_master_request_resp_to_host(resp);
- lockname.name = resp->name;
- lockname.len = resp->namelen;
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- spin_lock(&dlm_master_lock);
- list_for_each(iter, &dlm_master_list) {
- mle = list_entry(iter, dlm_master_list_entry, list);
- if (!dlm_mle_equal(dlm, mle, &lockname)) {
- mle = NULL;
- continue;
- }
-
- dlm_get_mle(mle);
- if (mle->type == DLM_MLE_BLOCK) {
- dlmprintk0("eek! cannot get a response for a block!\n");
- break;
- }
- found = 1;
- wake = 0;
- spin_lock(&mle->spinlock);
- switch (resp->response) {
- case DLM_MASTER_RESP_YES:
- set_bit(resp->node_idx, mle->response_map);
- // dlmprintk("woot! node %u is the master!\n",
- // resp->node_idx);
- mle->master = resp->node_idx;
- wake = 1;
- break;
- case DLM_MASTER_RESP_NO:
- // dlmprintk("node %u is not the master, not "
- // "in-progress\n", resp->node_idx);
- set_bit(resp->node_idx, mle->response_map);
- if (memcmp(mle->response_map, mle->vote_map,
- sizeof(mle->vote_map))==0)
- wake = 1;
- break;
- case DLM_MASTER_RESP_MAYBE:
- // dlmprintk("node %u is not the master, but IS"
- // " in-progress\n", resp->node_idx);
- set_bit(resp->node_idx, mle->response_map);
- set_bit(resp->node_idx, mle->maybe_map);
- if (memcmp(mle->response_map, mle->vote_map,
- sizeof(mle->vote_map))==0)
- wake = 1;
- break;
- case DLM_MASTER_RESP_ERROR:
- dlmprintk("node %u hit an -ENOMEM! try this "
- "whole thing again\n",
- resp->node_idx);
- mle->error = 1;
- wake = 1;
- break;
- default:
- dlmprintk("bad response! %u\n", resp->response);
- break;
- }
- if (wake) {
- atomic_set(&mle->woken, 1);
- wake_up(&mle->wq);
- }
- spin_unlock(&mle->spinlock);
- break;
- }
- spin_unlock(&dlm_master_lock);
-
- if (found)
- dlm_put_mle(mle);
- else
- dlmprintk0("hrrm... got a master resp but found no matching "
- "request\n");
- return 0;
-}
-
-/*
- * locks that can be taken here:
- * dlm->spinlock
- * res->spinlock
- * mle->spinlock
- * dlm_master_list
- *
- * if possible, TRIM THIS DOWN!!!
- */
-int dlm_assert_master_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_master_list_entry *mle = NULL;
- dlm_assert_master *assert = (dlm_assert_master *)msg->buf;
- dlm_lock_resource *res;
- int bit;
- struct list_head *iter;
- struct qstr lockname;
-
- dlm_assert_master_to_host(assert);
- lockname.name = assert->name;
- lockname.len = assert->namelen;
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- spin_lock(&dlm->spinlock);
-
- /* find the MLE */
- spin_lock(&dlm_master_lock);
- list_for_each(iter, &dlm_master_list) {
- mle = list_entry(iter, dlm_master_list_entry, list);
- if (dlm_mle_equal(dlm, mle, &lockname)) {
- dlm_get_mle(mle);
- break;
- }
- mle = NULL;
- }
- if (!mle) {
- dlmprintk("EEEEEEK! just got an assert_master from %u, but no "
- "MLE for it!\n",
- assert->node_idx);
- spin_unlock(&dlm_master_lock);
- goto check_lockres;
- }
- bit = find_next_bit (mle->maybe_map, NM_MAX_NODES, 0);
- if (bit >= NM_MAX_NODES) {
- dlmprintk("EEK! no bits set in the maybe_map, but %u is "
- "asserting!\n", assert->node_idx);
- BUG();
- } else if (bit != assert->node_idx) {
- /* TODO: is this ok? */
- dlmprintk("EEK! expected %u to be the master, but %u is "
- "asserting!\n", bit, assert->node_idx);
- BUG();
- }
- spin_unlock(&dlm_master_lock);
-
- /* ok everything checks out with the MLE
- * now check to see if there is a lockres */
-check_lockres:
- res = __dlm_lookup_lock(dlm, &lockname);
- if (res) {
- spin_lock(&res->spinlock);
- if (!mle) {
- if (res->owner != assert->node_idx) {
- dlmprintk("EEEEeeEEeeEEEK! assert_master from "
- "%u, but current owner is %u!\n",
- assert->node_idx, res->owner);
- BUG();
- }
- } else {
- if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
- dlmprintk("EEEEEEEEEEEEEEEEEK!!! got "
- "assert_master from node %u, but %u "
- "is the owner!\n", assert->node_idx,
- res->owner);
- dlmprintk0("goodnite!\n");
- BUG();
- }
- if (!(res->state & DLM_LOCK_RES_IN_PROGRESS)) {
- dlmprintk("bug! got assert from %u, but lock "
- "with no owner should be "
- "in-progress!\n", assert->node_idx);
- BUG();
- }
- }
- spin_unlock(&res->spinlock);
- }
- spin_unlock(&dlm->spinlock);
-
- // dlmprintk("woo! got an assert_master from node %u!\n",
- // assert->node_idx);
- if (mle) {
- spin_lock(&mle->spinlock);
- mle->master = assert->node_idx;
- atomic_set(&mle->woken, 1);
- wake_up(&mle->wq);
- spin_unlock(&mle->spinlock);
-
- /* if this is the last put, it will be removed from the list */
- dlm_put_mle(mle);
- }
- return 0;
-}
-
-
-static int dlm_do_master_request(dlm_master_list_entry *mle, int to)
-{
- struct inode *inode = NULL;
- dlm_ctxt *dlm = mle->dlm;
- dlm_master_request request;
- int ret, response=0;
-
- memset(&request, 0, sizeof(request));
- request.node_idx = dlm->group_index;
- if (mle->type == DLM_MLE_BLOCK) {
- request.namelen = mle->u.name.len;
- strncpy(request.name, mle->u.name.name, request.namelen);
- } else {
- request.namelen = mle->u.res->lockname.len;
- strncpy(request.name, mle->u.res->lockname.name,
- request.namelen);
- }
-
- ret = -EINVAL;
- inode = nm_get_group_node_by_index(dlm->group, to);
- if (inode) {
- dlm_master_request_to_net(&request);
- ret = net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key,
- &request, sizeof(request),
- inode, &response);
- iput(inode);
- if (ret >= 0) {
- spin_lock(&mle->spinlock);
- switch (response) {
- case DLM_MASTER_RESP_YES:
- set_bit(to, mle->response_map);
- // dlmprintk("woot! node %u is the "
- // "master!\n", to);
- mle->master = to;
- break;
- case DLM_MASTER_RESP_NO:
- // dlmprintk("node %u is not the "
- // "master, not in-progress\n", to);
- set_bit(to, mle->response_map);
- break;
- case DLM_MASTER_RESP_MAYBE:
- // dlmprintk("node %u is not the "
- // "master, but IS in-progress\n", to);
- set_bit(to, mle->response_map);
- set_bit(to, mle->maybe_map);
- break;
- case DLM_MASTER_RESP_ERROR:
- dlmprintk("node %u hit an -ENOMEM! "
- "try everything again\n", to);
- mle->error = 1;
- break;
- default:
- dlmprintk("bad response! %u\n",
- response);
- ret = -EINVAL;
- break;
- }
- spin_unlock(&mle->spinlock);
- } else {
- dlmprintk("net_send_message returned %d!\n", ret);
- }
- } else {
- dlmprintk("nm_get_group_node_by_index failed to find inode "
- "for node %d!\n", to);
- }
- return ret;
-}
-
-static int dlm_do_master_request_resp(dlm_ctxt *dlm, struct qstr *name,
- int response, int to)
-{
- struct inode *inode = NULL;
- dlm_master_request_resp resp;
- int ret;
-
- memset(&resp, 0, sizeof(resp));
- resp.node_idx = dlm->group_index;
- resp.response = response;
- resp.namelen = name->len;
- strncpy(resp.name, name->name, name->len);
-
- inode = nm_get_group_node_by_index(dlm->group, to);
- if (!inode)
- return -EINVAL;
-
- dlm_master_request_resp_to_net(&resp);
- ret = net_send_message(DLM_MASTER_REQUEST_RESP_MSG, dlm->key,
- &resp, sizeof(resp), inode, NULL);
- iput(inode);
- return ret;
-}
-
-/*
- * NOTE: this can be used for debugging
- * can periodically run all locks owned by this node
- * and re-assert across the cluster...
- */
-static int dlm_do_assert_master(dlm_master_list_entry *mle)
-{
- struct inode *inode = NULL;
- dlm_ctxt *dlm = mle->dlm;
- dlm_assert_master assert;
- int to, start = 0, ret = 0, tmpret;
-
- while (1) {
- to = find_next_bit (mle->vote_map, NM_MAX_NODES, start);
- if (to >= NM_MAX_NODES) {
- // dlmprintk0("no more nodes\n");
- break;
- }
- // dlmprintk("sending assert master to %d\n", to);
-
- memset(&assert, 0, sizeof(assert));
- assert.node_idx = dlm->group_index;
- if (mle->type == DLM_MLE_BLOCK) {
- assert.namelen = mle->u.name.len;
- strncpy(assert.name, mle->u.name.name, assert.namelen);
- } else {
- assert.namelen = mle->u.res->lockname.len;
- strncpy(assert.name, mle->u.res->lockname.name,
- assert.namelen);
- }
-
- inode = nm_get_group_node_by_index(dlm->group, to);
- if (!inode) {
- tmpret = -EINVAL;
- dlmprintk("could not get nm info for node %d! "
- "need to retry this whole thing\n", to);
- ret = tmpret;
- break;
- }
-
- dlm_assert_master_to_net(&assert);
- tmpret = net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key,
- &assert, sizeof(assert), inode, NULL);
- iput(inode);
-
- if (tmpret < 0) {
- // TODO
- // dlmprintk("assert_master returned %d!\n", tmpret);
- ret = tmpret;
- break;
- }
- start = to+1;
- }
-
- return ret;
-}
-
-
-
-
-
-
-static void dlm_mle_node_down(struct inode *group, struct inode *node,
- int idx, void *data)
-{
- //int ret;
- //struct inode *node = ptr2;
-
- dlm_master_list_entry *mle;
- dlm_ctxt *dlm;
-
- mle = data;
- if (!mle) {
- dlmprintk0("eek! NULL mle!\n");
- return;
- }
- if (!mle->dlm) {
- dlmprintk0("eek! NULL dlm\n");
- return;
- }
- dlm = mle->dlm;
- if (dlm->group != group)
- return;
-
- spin_lock(&mle->spinlock);
-
- if (!test_bit(idx, mle->node_map))
- dlmprintk("node %u already removed from nodemap!\n", idx);
- else
- clear_bit(idx, mle->node_map);
-
-#if 0
- if (test_bit(idx, mle->recovery_map))
- dlmprintk("node %u already added to recovery map!\n", idx);
- else
- set_bit(idx, mle->recovery_map);
-#endif
- spin_unlock(&mle->spinlock);
-}
-
-static void dlm_mle_node_up(struct inode *group, struct inode *node,
- int idx, void *data)
-{
- //struct inode *node = ptr2;
- dlm_master_list_entry *mle;
- dlm_ctxt *dlm;
-
- mle = data;
- if (!mle) {
- dlmprintk0("eek! NULL mle!\n");
- return;
- }
- if (!mle->dlm) {
- dlmprintk0("eek! NULL dlm\n");
- return;
- }
- dlm = mle->dlm;
- if (dlm->group != group)
- return;
-
- spin_lock(&mle->spinlock);
-
-#if 0
- if (test_bit(idx, mle->recovery_map))
- dlmprintk("BUG!!! node up message on node "
- "in recovery (%u)!!!\n", idx);
- else
-#endif
- {
- if (test_bit(idx, mle->node_map))
- dlmprintk("node %u already in node map!!!\n", idx);
- else
- set_bit(idx, mle->node_map);
- }
-
- spin_unlock(&mle->spinlock);
-}
Deleted: trunk/fs/ocfs2/cluster/dlmmod.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmmod.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmmod.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,802 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmmod.c
- *
- * standalone DLM module
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR("Oracle Corporation");
-//MODULE_DESCRIPTION("Oracle DLM");
-
-
-/*
- *
- * spinlock lock ordering: if multiple locks are needed, obey this ordering:
- * dlm_domain_lock -> dlm_ctxt -> dlm_lock_resource -> dlm_lock
- *
- */
-
-
-static int __init dlm_driver_entry (void);
-static int dlm_read_params(void);
-static void __exit dlm_driver_exit (void);
-
-
-
-LIST_HEAD(dlm_domains);
-spinlock_t dlm_domain_lock = SPIN_LOCK_UNLOCKED;
-u16 dlm_global_index = NM_MAX_NODES;
-static spinlock_t dlm_cookie_lock = SPIN_LOCK_UNLOCKED;
-static u64 dlm_next_cookie = 1;
-
-
-
-
-/* ----------------------------------------------------------------- */
-
-extern spinlock_t dlm_master_lock;
-extern struct list_head dlm_master_list;
-/* ----------------------------------------------------------------- */
-
-
-
-
-/*
- * dlm_driver_entry()
- *
- * Driver entry point. Called on insmod.
- */
-static int __init dlm_driver_entry (void)
-{
- int status;
-
-
- dlmprintk0("Loaded dlm Driver module\n");
- status = dlm_read_params();
- if (status < 0)
- return -1;
-
- dlm_global_index = nm_this_node(NULL);
- if (dlm_global_index == NM_MAX_NODES)
- return -1;
-
- return 0;
-} /* dlm_driver_entry */
-
-/*
- * dlm_read_params()
- *
- * Read insmod params
- */
-static int dlm_read_params(void)
-{
- int status = 0;
- return status;
-} /* dlm_read_params */
-
-
-/*
- * dlm_driver_exit()
- *
- * Called on rmmod
- */
-static void __exit dlm_driver_exit (void)
-{
- dlmprintk0("Unloaded dlm Driver module\n");
- return;
-} /* dlm_driver_exit */
-
-
-/* fetch next node-local (u8 nodenum + u56 cookie) into u64 */
-static inline void dlm_get_next_cookie(u16 node_num, u64 *cookie)
-{
- /* why did I make node_num 16 bit to begin with? */
- u64 tmpnode = (u8)(node_num & (u16)0x00ff);
-
- /* shift single byte of node num into top 8 bits */
- tmpnode <<= 56;
-
- spin_lock(&dlm_cookie_lock);
- *cookie = (dlm_next_cookie | tmpnode);
- if (++dlm_next_cookie & 0xff00000000000000ull) {
- dlmprintk0("eek! this node's cookie will now wrap!\n");
- dlm_next_cookie = 1;
- }
- spin_unlock(&dlm_cookie_lock);
-}
-
-
-dlm_status dlmlock(dlm_ctxt *dlm, int mode, dlm_lockstatus *lksb, int flags,
- char *name, dlm_astlockfunc_t *ast, void *data,
- dlm_bastlockfunc_t *bast)
-{
- dlm_status status;
- dlm_lock_resource *res;
- dlm_lock *lock = NULL;
- char *buf = NULL;
- int convert = 0, recovery = 0;
- struct qstr q;
-
- if (!lksb)
- return DLM_BADARGS;
-
- status = DLM_BADPARAM;
- if (mode != LKM_EXMODE && mode != LKM_PRMODE && mode != LKM_NLMODE)
- goto error_status;
-
- if (flags & ~LKM_VALID_FLAGS)
- goto error_status;
-
- convert = (flags & LKM_CONVERT);
- recovery = (flags & LKM_RECOVERY);
-
- if (recovery && (!dlm_is_recovery_lock(name, strlen(name)) ||
- convert) ) {
- goto error_status;
- }
- if (convert && (flags & LKM_LOCAL)) {
- dlmprintk0("strange LOCAL convert request!\n");
- goto error_status;
- }
-
- if (convert) {
- /* CONVERT request */
-
- /* if converting, must pass in a valid dlm_lock */
- if (!lksb->lockid || !lksb->lockid->lockres)
- goto error_status;
- lock = lksb->lockid;
-
- /* XXX: for ocfs2 purposes, the ast/bast/astdata/lksb are
- * static after the original lock call. convert requests will
- * ensure that everything is the same, or return DLM_BADARGS.
- * this means that DLM_DENIED_NOASTS will never be returned.
- */
-#warning differs from spec here!
-
- if (lock->lksb != lksb || lock->ast != ast ||
- lock->bast != bast || lock->astdata != data) {
- status = DLM_BADARGS;
- dlmprintk("ERROR new args: lksb=%p, ast=%p, bast=%p, "
- "astdata=%p\n", lksb, ast, bast, data);
- dlmprintk(" orig args: lksb=%p, ast=%p, bast=%p, "
- "astdata=%p\n", lock->lksb, lock->ast,
- lock->bast, lock->astdata);
- goto error_status;
- }
- res = lock->lockres;
- down_read(&dlm->recovery_sem);
-
- if (res->owner == dlm->group_index)
- status = dlmconvert_master(dlm, res, lock, flags, mode);
- else
- status = dlmconvert_remote(dlm, res, lock, flags, mode);
-
- } else {
- /* LOCK request */
- status = DLM_BADARGS;
- if (!name)
- goto error;
-
- status = DLM_IVBUFLEN;
- q.len = strlen(name);
- if (q.len > DLM_LOCKID_NAME_MAX)
- goto error;
-
- /* take care of all allocs before any locking */
- status = DLM_SYSERR;
- buf = kmalloc(q.len+1, GFP_KERNEL); /* lockres name */
- if (!buf)
- goto error;
-
- memcpy(buf, name, q.len);
- buf[q.len] = 0;
- q.name = buf;
- q.hash = full_name_hash(q.name, q.len);
-
- lock = kmalloc(sizeof(dlm_lock), GFP_KERNEL); /* dlm_lock */
- if (!lock)
- goto error;
-
- lksb->lockid = lock;
-
- if (!recovery)
- down_read(&dlm->recovery_sem);
-
- /* find or create the lock resource */
- res = dlm_get_lock_resource(dlm, &q, flags);
- if (!res) {
- status = DLM_IVLOCKID;
- goto up_error;
- }
-
- dlmprintk("type=%d\n", mode);
- dlmprintk("creating lock: lock=%p res=%p\n", lock, res);
-
- memset(lock, 0, sizeof(dlm_lock));
- INIT_LIST_HEAD(&lock->list);
- INIT_LIST_HEAD(&lock->ast_list);
- spin_lock_init(&lock->spinlock);
- lock->lockres = res;
- lock->type = mode;
- lock->convert_type = LKM_IVMODE;
- lock->highest_blocked = LKM_IVMODE;
- lock->node = dlm->group_index;
- lock->ast = ast;
- lock->bast = bast;
- lock->astdata = data;
- lock->lksb = lksb;
-
- dlm_get_next_cookie(lock->node, &lock->cookie);
-
- if (res->owner == dlm->group_index)
- status = dlmlock_master(dlm, res, lock, flags);
- else
- status = dlmlock_remote(dlm, res, lock, flags);
-
- if (status != DLM_NORMAL)
- goto up_error;
- }
-
- if (!recovery)
- up_read(&dlm->recovery_sem);
- return status;
-
-up_error:
- if (!recovery)
- up_read(&dlm->recovery_sem);
-error:
- if (buf)
- kfree(buf);
- if (lock && !convert) {
- kfree(lock);
- lksb->lockid = NULL;
- }
-
-error_status:
- // this is kind of unnecessary
- lksb->status = status;
- return status;
-}
-EXPORT_SYMBOL(dlmlock);
-
-
-/* there seems to be no point in doing this async
- * since (even for the remote case) there is really
- * no work to queue up... so just do it and fire the
- * unlockast by hand when done... */
-dlm_status dlmunlock(dlm_ctxt *dlm, dlm_lockstatus *lksb, int flags,
- dlm_astunlockfunc_t *unlockast, void *data)
-{
- dlm_status status;
- dlm_lock_resource *res;
- dlm_lock *lock = NULL;
- int call_ast = 0;
-
- dlmprintk0("\n");
-
- if (!lksb)
- return DLM_BADARGS;
-
- if (flags & ~(LKM_CANCEL | LKM_VALBLK | LKM_INVVALBLK))
- return DLM_BADPARAM;
-
- if ((flags & (LKM_VALBLK | LKM_CANCEL)) == (LKM_VALBLK | LKM_CANCEL)) {
- dlmprintk0("VALBLK given with CANCEL: ignoring VALBLK\n");
- flags &= ~LKM_VALBLK;
- }
-
- if (!lksb->lockid || !lksb->lockid->lockres)
- return DLM_BADPARAM;
-
- lock = lksb->lockid;
- res = lock->lockres;
-
- DLM_ASSERT(lock);
- DLM_ASSERT(res);
- dlmprintk("lock=%p res=%p\n", lock, res);
-
- if (res->owner == dlm->group_index) {
- status = dlmunlock_master(dlm, res, lock, lksb, flags,
- &call_ast);
- dlmprintk("done calling dlmunlock_master: returned %d, "
- "call_ast is %d\n", status, call_ast);
- } else {
- status = dlmunlock_remote(dlm, res, lock, lksb, flags,
- &call_ast);
- dlmprintk("done calling dlmunlock_remote: returned %d, "
- "call_ast is %d\n", status, call_ast);
- }
-
- if (call_ast) {
- dlmprintk("calling unlockast(%p, %d)\n",
- data, lksb->status);
- (*unlockast)(data, lksb->status);
- }
- dlmprintk("returning status=%d!\n", status);
- return status;
-}
-EXPORT_SYMBOL(dlmunlock);
-
-
-static dlm_ctxt * __dlm_lookup_domain(char *domain)
-{
- dlm_ctxt *tmp = NULL;
- struct list_head *iter;
-
- list_for_each(iter, &dlm_domains) {
- tmp = list_entry (iter, dlm_ctxt, list);
- if (strncmp(tmp->name, domain, NM_MAX_NAME_LEN)==0)
- break;
- tmp = NULL;
- }
-
- return tmp;
-}
-
-dlm_ctxt * dlm_lookup_domain(char *domain)
-{
- dlm_ctxt *tmp = NULL;
- spin_lock(&dlm_domain_lock);
- tmp = __dlm_lookup_domain(domain);
- spin_unlock(&dlm_domain_lock);
- return tmp;
-}
-
-dlm_lock_resource * __dlm_lookup_lock(dlm_ctxt *dlm, struct qstr *lockname)
-{
- struct list_head *iter;
- dlm_lock_resource *tmpres=NULL;
- struct list_head *bucket;
-
- dlmprintk0("\n");
-
- bucket = &(dlm->resources[lockname->hash & DLM_HASH_MASK]);
-
- /* check for pre-existing lock */
- list_for_each(iter, bucket) {
- tmpres = list_entry(iter, dlm_lock_resource, list);
- if (tmpres->lockname.len == lockname->len &&
- strncmp(tmpres->lockname.name, lockname->name,
- lockname->len) == 0)
- break;
- tmpres = NULL;
- }
- return tmpres;
-}
-
-dlm_lock_resource * dlm_lookup_lock(dlm_ctxt *dlm, struct qstr *lockname)
-{
- dlm_lock_resource *res;
- spin_lock(&dlm->spinlock);
- res = __dlm_lookup_lock(dlm, lockname);
- spin_unlock(&dlm->spinlock);
- return res;
-}
-
-
-
-/*
- * dlm_register_domain: one-time setup per "domain"
- */
-dlm_ctxt * dlm_register_domain(char *domain, char *group_name, u32 key)
-{
- dlm_ctxt *tmp = NULL, *dlm = NULL;
- struct inode *group = NULL;
- int tmpret, i;
-
- if (strlen(domain) > NM_MAX_NAME_LEN) {
- dlmprintk0("domain name length too long\n");
- goto leave;
- }
-
- group = nm_get_group_by_name(group_name);
- if (!group) {
- dlmprintk("no nm group %s for domain %s!\n",
- group_name, domain);
- goto leave;
- }
-
- /*
- * TODO: should i do some type of dlm-group-join business here?
- * I need to have new nodes communicate with other dlm nodes to
- * wait until their master lists are empty before allowing me to
- * join. does this belong here? or in hb?
- * seems like stuff that heartbeat shouldn't care about, cuz we
- * would actually be preventing a node that is "UP" from being
- * part of the dlm group.
- */
- dlm = dlm_lookup_domain(domain);
- if (dlm) {
- /* found a pre-existing domain */
- goto leave;
- }
-
- dlm = kmalloc(sizeof(dlm_ctxt), GFP_KERNEL);
- if (dlm == NULL) {
- dlmprintk0("could not allocate dlm_ctxt\n");
- goto leave;
- }
- memset(dlm, 0, sizeof(dlm_ctxt));
- dlm->name = kmalloc(strlen(domain) + 1, GFP_KERNEL);
- if (dlm->name == NULL) {
- kfree(dlm);
- dlm = NULL;
- dlmprintk0("could not allocate dlm domain name\n");
- goto leave;
- }
- dlm->resources = (struct list_head *) __get_free_page(GFP_KERNEL);
- if (!dlm->resources) {
- kfree(dlm->name);
- kfree(dlm);
- dlm = NULL;
- dlmprintk0("could not allocate dlm hash\n");
- goto leave;
- }
- memset(dlm->resources, 0, PAGE_SIZE);
-
- for (i=0; i<DLM_HASH_SIZE; i++)
- INIT_LIST_HEAD(&dlm->resources[i]);
-
- strcpy(dlm->name, domain);
- spin_lock_init(&dlm->spinlock);
- INIT_LIST_HEAD(&dlm->list);
- INIT_LIST_HEAD(&dlm->dirty_list);
- INIT_LIST_HEAD(&dlm->reco.resources);
- INIT_LIST_HEAD(&dlm->reco.received);
- util_thread_info_init(&dlm->thread);
- util_thread_info_init(&dlm->reco.thread);
- init_rwsem(&dlm->recovery_sem);
- dlm->group = group;
- dlm->group_index = nm_this_node(group);
- dlm->key = key;
- dlm->reco.new_master = NM_INVALID_SLOT_NUM;
- dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
- dlm->reco.sending_node = NM_INVALID_SLOT_NUM;
- dlm->reco.next_seq = 0;
-
- spin_lock(&dlm_domain_lock);
- tmp = __dlm_lookup_domain(domain);
- if (tmp) {
- spin_unlock(&dlm_domain_lock);
- /* found a pre-existing domain */
- kfree(dlm->name);
- kfree(dlm);
- dlm = NULL;
- goto leave;
- }
-
- /* add the new domain */
- list_add_tail(&dlm->list, &dlm_domains);
- spin_unlock(&dlm_domain_lock);
-
- tmpret = hb_register_callback(HB_NODE_DOWN_CB, dlm_hb_node_down_cb, dlm,
- DLM_HB_NODE_DOWN_PRI);
- if (tmpret)
- goto error;
- tmpret = hb_register_callback(HB_NODE_UP_CB, dlm_hb_node_up_cb, dlm,
- DLM_HB_NODE_UP_PRI);
- if (tmpret)
- goto error;
-
- /* TODO: need to use hb_fill_node_map to fill a temporary votemap
- * then communicate with each of these nodes that I want to come up
- * FOR THIS DLM. there may be many nodes in this group heartbeating
- * but they may not care about this particular dlm instance. once
- * everyone has come back with a response that i have been added or
- * that they are not a member I can put together the REAL node map
- * for this dlm in dlm->node_map */
- /* TODO: I guess we can fill this here as a superset of possible nodes
- * so that the hb_callbacks above have something to work on in the
- * meantime, then trim out the nodes that are not part of this dlm
- * once we know */
- /* TODO: I may need to register a special net handler on insmod of dlm.o
- * with a key of 0 so that I can respond to requests even if I am not
- * part of a dlm group. this would still leave a gap in time between
- * the start of heartbeating and the insmod dlm.o, unless I change the
- * module loading stuff in clusterbo to include dlm.o (which would work
- * fine) */
-#warning WRONG WRONG WRONG
- tmpret = hb_fill_node_map(group, dlm->node_map, NM_MAX_NODES);
- if (tmpret)
- goto error;
-
- dlmprintk("hb_fill_node_map returned node map:\n");
- BUG_ON(ARRAY_SIZE(dlm->node_map) & 3); /* better be mult of 4 :) */
- for(i = 0; i < ARRAY_SIZE(dlm->node_map); i += 4)
- dlmprintk("%0lx%0lx%0lx%0lx\n",
- dlm->node_map[i], dlm->node_map[i + 1],
- dlm->node_map[i + 2], dlm->node_map[i + 3]);
-
-#if 0
- tmpret = net_register_handler("reco-request",
- DLM_NET_RECOVERY_REQUEST_MSG_TYPE,
- key, sizeof(dlm_reco_request),
- dlm_recovery_request_handler, dlm);
- if (tmpret)
- goto error;
- tmpret = net_register_handler("reco-lock-arr-req",
- DLM_NET_RECOVERY_LOCK_ARR_REQ_MSG_TYPE,
- key, sizeof(dlm_reco_lock_arr_req),
- dlm_recovery_lock_arr_req_handler, dlm);
- if (tmpret)
- goto error;
- tmpret = net_register_handler("reco-response",
- DLM_NET_RECOVERY_RESPONSE_MSG_TYPE,
- key, sizeof(dlm_reco_response),
- dlm_recovery_response_handler, dlm);
- if (tmpret)
- goto error;
-#endif
-
- tmpret = net_register_handler(DLM_MASTER_REQUEST_RESP_MSG, key, 0,
- sizeof(dlm_master_request_resp),
- dlm_master_request_resp_handler,
- dlm);
- if (tmpret)
- goto error;
-
- tmpret = net_register_handler(DLM_MASTER_REQUEST_MSG, key, 0,
- sizeof(dlm_master_request),
- dlm_master_request_handler,
- dlm);
-
- if (tmpret)
- goto error;
-
- tmpret = net_register_handler(DLM_ASSERT_MASTER_MSG, key, 0,
- sizeof(dlm_assert_master),
- dlm_assert_master_handler,
- dlm);
- if (tmpret)
- goto error;
- tmpret = net_register_handler(DLM_CREATE_LOCK_MSG, key, 0,
- sizeof(dlm_create_lock),
- dlm_create_lock_handler,
- dlm);
- if (tmpret)
- goto error;
- tmpret = net_register_handler(DLM_CONVERT_LOCK_MSG, key,
- NET_HND_VAR_LEN,
- DLM_CONVERT_LOCK_MAX_LEN,
- dlm_convert_lock_handler,
- dlm);
- if (tmpret)
- goto error;
-
- tmpret = net_register_handler(DLM_UNLOCK_LOCK_MSG, key,
- NET_HND_VAR_LEN,
- DLM_UNLOCK_LOCK_MAX_LEN,
- dlm_unlock_lock_handler,
- dlm);
- if (tmpret)
- goto error;
-
- tmpret = net_register_handler(DLM_PROXY_AST_MSG, key,
- NET_HND_VAR_LEN,
- DLM_PROXY_AST_MAX_LEN,
- dlm_proxy_ast_handler,
- dlm);
- if (tmpret)
- goto error;
-
- tmpret = dlm_launch_thread(dlm);
- if (tmpret == 0)
- goto leave;
-
-error:
- hb_unregister_callback(HB_NODE_UP_CB, dlm_hb_node_up_cb, dlm);
- hb_unregister_callback(HB_NODE_DOWN_CB, dlm_hb_node_down_cb, dlm);
- spin_lock(&dlm_domain_lock);
- list_del(&dlm->list);
- spin_unlock(&dlm_domain_lock);
- free_page((unsigned long)dlm->resources);
- kfree(dlm->name);
- kfree(dlm);
- dlm = NULL;
-
-leave:
- if (!dlm && group)
- iput(group);
- return dlm;
-}
-EXPORT_SYMBOL(dlm_register_domain);
-
-void dlm_unregister_domain(dlm_ctxt *dlm)
-{
- // fill me in please
-}
-EXPORT_SYMBOL(dlm_unregister_domain);
-
-void dlm_init_lockres(dlm_lock_resource *res, struct qstr *lockname)
-{
- memset(res, 0, sizeof(dlm_lock_resource));
- res->lockname.name = lockname->name;
- res->lockname.len = lockname->len;
- res->lockname.hash = lockname->hash;
- init_waitqueue_head(&res->wq);
- spin_lock_init(&res->spinlock);
- INIT_LIST_HEAD(&res->list);
- INIT_LIST_HEAD(&res->granted);
- INIT_LIST_HEAD(&res->converting);
- INIT_LIST_HEAD(&res->blocked);
- INIT_LIST_HEAD(&res->dirty);
- INIT_LIST_HEAD(&res->recovering);
-
- res->owner = DLM_LOCK_RES_OWNER_UNKNOWN;
- res->state |= DLM_LOCK_RES_IN_PROGRESS;
-}
-
-
-
-
-/* will exit holding res->spinlock, but may drop in function */
-void dlm_wait_on_lockres(dlm_lock_resource *res)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- add_wait_queue(&res->wq, &wait);
-repeat:
- set_current_state(TASK_UNINTERRUPTIBLE);
-
- spin_lock(&res->spinlock);
- if (res->state & DLM_LOCK_RES_IN_PROGRESS) {
- spin_unlock(&res->spinlock);
- schedule();
- goto repeat;
- }
- remove_wait_queue(&res->wq, &wait);
- current->state = TASK_RUNNING;
-}
-
-/* will exit holding res->spinlock, but may drop in function */
-void __dlm_wait_on_lockres(dlm_lock_resource *res)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- add_wait_queue(&res->wq, &wait);
-repeat:
- set_current_state(TASK_UNINTERRUPTIBLE);
- if (res->state & DLM_LOCK_RES_IN_PROGRESS) {
- spin_unlock(&res->spinlock);
- schedule();
- spin_lock(&res->spinlock);
- goto repeat;
- }
- remove_wait_queue(&res->wq, &wait);
- current->state = TASK_RUNNING;
-}
-
-
-
-
-
-void dlm_dump_everything(void)
-{
- dlm_ctxt *dlm;
- struct list_head *iter;
-
- dlmprintk("dumping ALL dlm state for node %s\n",
- system_utsname.nodename);
- spin_lock(&dlm_domain_lock);
- list_for_each(iter, &dlm_domains) {
- dlm = list_entry (iter, dlm_ctxt, list);
- dlm_dump_dlm(dlm);
- }
- spin_unlock(&dlm_domain_lock);
-}
-
-void dlm_dump_dlm(dlm_ctxt *dlm)
-{
- dlm_lock_resource *res;
- dlm_lock *lock;
- struct list_head *iter, *iter2;
- struct list_head *bucket;
- int i;
-
- dlmprintk("dlm_ctxt: %s, group=%u, key=%u\n",
- dlm->name, dlm->group_index, dlm->key);
- dlmprintk0("some bug here... should not have to check for this...\n");
- if (!dlm || !dlm->name) {
- dlmprintk("wtf... dlm=%p\n", dlm);
- return;
- }
-
- spin_lock(&dlm->spinlock);
- for (i=0; i<DLM_HASH_SIZE; i++) {
- bucket = &(dlm->resources[i]);
- list_for_each(iter, bucket) {
- res = list_entry(iter, dlm_lock_resource, list);
- dlmprintk("lockres: %*s, owner=%u, state=%u\n",
- res->lockname.len, res->lockname.name,
- res->owner, res->state);
- spin_lock(&res->spinlock);
- dlmprintk0(" granted queue: \n");
- list_for_each(iter2, &res->granted) {
- lock = list_entry(iter2, dlm_lock, list);
- spin_lock(&lock->spinlock);
- dlmprintk(" type=%d, conv=%d, node=%u, "
- "cookie=%llu\n", lock->type,
- lock->convert_type, lock->node,
- lock->cookie);
- spin_unlock(&lock->spinlock);
- }
- dlmprintk0(" converting queue: \n");
- list_for_each(iter2, &res->converting) {
- lock = list_entry(iter2, dlm_lock, list);
- spin_lock(&lock->spinlock);
- dlmprintk(" type=%d, conv=%d, node=%u, "
- "cookie=%llu\n", lock->type,
- lock->convert_type, lock->node,
- lock->cookie);
- spin_unlock(&lock->spinlock);
- }
- dlmprintk0(" blocked queue: \n");
- list_for_each(iter2, &res->blocked) {
- lock = list_entry(iter2, dlm_lock, list);
- spin_lock(&lock->spinlock);
- dlmprintk(" type=%d, conv=%d, node=%u, "
- "cookie=%llu\n", lock->type,
- lock->convert_type, lock->node,
- lock->cookie);
- spin_unlock(&lock->spinlock);
- }
- spin_unlock(&res->spinlock);
- }
- }
- spin_unlock(&dlm->spinlock);
-}
-
-module_init (dlm_driver_entry);
-module_exit (dlm_driver_exit);
Deleted: trunk/fs/ocfs2/cluster/dlmmod.h
===================================================================
--- trunk/fs/ocfs2/cluster/dlmmod.h 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmmod.h 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,677 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmmod.h
- *
- * Function prototypes
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#ifndef CLUSTER_DLMMOD_H
-#define CLUSTER_DLMMOD_H
-
-
-
-#if 0
-#define dlmprintk(x, arg...)
-#define dlmprintk0(x)
-#else
-#define dlmprintk(x, arg...) printk("(dlm:%d)(%s:%d) " x, current->pid, __FUNCTION__, __LINE__, ##arg)
-#define dlmprintk0(x) printk("(dlm:%d)(%s:%d) " x, current->pid, __FUNCTION__, __LINE__)
-#endif
-
-
-
-
-#define DLM_HB_NODE_DOWN_PRI (0xf000000)
-#define DLM_HB_NODE_UP_PRI (0x8000000)
-
-#define DLM_LVB_LEN 64
-#define DLM_LOCKID_NAME_MAX 32
-
-#define DLM_DOMAIN_NAME_MAX_LEN 255
-#define DLM_LOCK_RES_OWNER_UNKNOWN NM_MAX_NODES
-#define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes
-#define DLM_THREAD_MS 200 // flush at least every 200 ms
-
-#define DLM_HASH_BITS 7
-#define DLM_HASH_SIZE (1 << DLM_HASH_BITS)
-#define DLM_HASH_MASK (DLM_HASH_SIZE - 1)
-
-typedef enum _dlm_ast_type {
- DLM_AST = 0,
- DLM_BAST,
- DLM_ASTUNLOCK
-} dlm_ast_type;
-
-
-#define LKM_IVMODE (-1) /* invalid mode */
-#define LKM_NLMODE 0 /* null lock */
-#define LKM_CRMODE 1 /* concurrent read */ /* unsupported */
-#define LKM_CWMODE 2 /* concurrent write */ /* unsupported */
-#define LKM_PRMODE 3 /* protected read */
-#define LKM_PWMODE 4 /* protected write */ /* unsupported */
-#define LKM_EXMODE 5 /* exclusive */
-#define LKM_MAXMODE 5
-#define LKM_MODEMASK 0xff
-
-
-/* reserved: flags used by the "real" dlm, only a few are supported by this dlm */
-#define LKM_ORPHAN 0x00000010 /* this lock is orphanable */ /* unsupported */
-#define LKM_PARENTABLE 0x00000020 /* this lock was orphaned */ /* unsupported */
-#define LKM_BLOCK 0x00000040 /* blocking lock request */ /* unsupported */
-#define LKM_LOCAL 0x00000080 /* local lock request */
-#define LKM_VALBLK 0x00000100 /* lock value block request */
-#define LKM_NOQUEUE 0x00000200 /* non blocking request */
-#define LKM_CONVERT 0x00000400 /* conversion request */
-#define LKM_NODLCKWT 0x00000800 /* this lock wont deadlock */ /* unsupported */
-#define LKM_UNLOCK 0x00001000 /* deallocate this lock */
-#define LKM_CANCEL 0x00002000 /* cancel conversion request */
-#define LKM_DEQALL 0x00004000 /* remove all locks held by proc */ /* unsupported */
-#define LKM_INVVALBLK 0x00008000 /* invalidate lock value block */
-#define LKM_SYNCSTS 0x00010000 /* return synchronous status if poss */ /* unsupported */
-#define LKM_TIMEOUT 0x00020000 /* lock request contains timeout */ /* unsupported */
-#define LKM_SNGLDLCK 0x00040000 /* request can self-deadlock */ /* unsupported */
-#define LKM_FINDLOCAL 0x00080000 /* find local lock request */ /* unsupported */
-#define LKM_PROC_OWNED 0x00100000 /* owned by process, not group */ /* unsupported */
-#define LKM_XID 0x00200000 /* use transaction id for deadlock */ /* unsupported */
-#define LKM_XID_CONFLICT 0x00400000 /* do not allow lock inheritance */ /* unsupported */
-#define LKM_FORCE 0x00800000 /* force unlock flag */
-#define LKM_REVVALBLK 0x01000000 /* temporary solution: re-validate lock value block */ /* unsupported */
-/* unused */
-#define LKM_UNUSED1 0x00000001 /* unused */
-#define LKM_UNUSED2 0x00000002 /* unused */
-#define LKM_UNUSED3 0x00000004 /* unused */
-#define LKM_UNUSED4 0x00000008 /* unused */
-#define LKM_UNUSED5 0x02000000 /* unused */
-#define LKM_UNUSED6 0x04000000 /* unused */
-#define LKM_UNUSED7 0x08000000 /* unused */
-#define LKM_UNUSED8 0x10000000 /* unused */
-/* ocfs2 extensions: internal only; should never be used by caller */
-#define LKM_PUT_LVB 0x20000000 /* extension: lvb is being passed, should be applied to lockres */
-#define LKM_GET_LVB 0x40000000 /* extension: lvb should be copied from lockres when lock granted */
-#define LKM_RECOVERY 0x80000000 /* extension: flag for recovery lock, used to avoid recovery rwsem */
-
-#define LKM_VALID_FLAGS (LKM_VALBLK | LKM_CONVERT | LKM_UNLOCK | \
- LKM_CANCEL | LKM_INVVALBLK | LKM_FORCE | \
- LKM_RECOVERY | LKM_LOCAL | LKM_NOQUEUE)
-
-#define DLM_RECOVERY_LOCK_NAME "$RECOVERY"
-#define DLM_RECOVERY_LOCK_NAME_LEN 9
-
-static inline int dlm_is_recovery_lock(char *lock_name, int name_len)
-{
- if (name_len == DLM_RECOVERY_LOCK_NAME_LEN &&
- strncmp(lock_name, DLM_RECOVERY_LOCK_NAME, DLM_RECOVERY_LOCK_NAME_LEN)==0)
- return 1;
- return 0;
-}
-
-typedef enum _dlm_status {
- DLM_NORMAL = 0, /* 0: request in progress */
- DLM_GRANTED, /* 1: request granted */
- DLM_DENIED, /* 2: request denied */
- DLM_DENIED_NOLOCKS, /* 3: request denied, out of system resources */
- DLM_WORKING, /* 4: async request in progress */
- DLM_BLOCKED, /* 5: lock request blocked */
- DLM_BLOCKED_ORPHAN, /* 6: lock request blocked by a orphan lock*/
- DLM_DENIED_GRACE_PERIOD, /* 7: topological change in progress */
- DLM_SYSERR, /* 8: system error */
- DLM_NOSUPPORT, /* 9: unsupported */
- DLM_CANCELGRANT, /* 10: can't cancel convert: already granted */
- DLM_IVLOCKID, /* 11: bad lockid */
- DLM_SYNC, /* 12: synchronous request granted */
- DLM_BADTYPE, /* 13: bad resource type */
- DLM_BADRESOURCE, /* 14: bad resource handle */
- DLM_MAXHANDLES, /* 15: no more resource handles */
- DLM_NOCLINFO, /* 16: can't contact cluster manager */
- DLM_NOLOCKMGR, /* 17: can't contact lock manager */
- DLM_NOPURGED, /* 18: can't contact purge daemon */
- DLM_BADARGS, /* 19: bad api args */
- DLM_VOID, /* 20: no status */
- DLM_NOTQUEUED, /* 21: NOQUEUE was specified and request failed */
- DLM_IVBUFLEN, /* 22: invalid resource name length */
- DLM_CVTUNGRANT, /* 23: attempted to convert ungranted lock */
- DLM_BADPARAM, /* 24: invalid lock mode specified */
- DLM_VALNOTVALID, /* 25: value block has been invalidated */
- DLM_REJECTED, /* 26: request rejected, unrecognized client */
- DLM_ABORT, /* 27: blocked lock request cancelled */
- DLM_CANCEL, /* 28: conversion request cancelled */
- DLM_IVRESHANDLE, /* 29: invalid resource handle */
- DLM_DEADLOCK, /* 30: deadlock recovery refused this request */
- DLM_DENIED_NOASTS, /* 31: failed to allocate AST */
- DLM_FORWARD, /* 32: request must wait for primary's response */
- DLM_TIMEOUT, /* 33: timeout value for lock has expired */
- DLM_IVGROUPID, /* 34: invalid group specification */
- DLM_VERS_CONFLICT, /* 35: version conflicts prevent request handling */
- DLM_BAD_DEVICE_PATH, /* 36: Locks device does not exist or path wrong */
- DLM_NO_DEVICE_PERMISSION, /* 37: Client has insufficient pers for device */
- DLM_NO_CONTROL_DEVICE, /* 38: Cannot set options on opened device */
- DLM_MAXSTATS, /* 39: upper limit for return code validation */
-
- DLM_RECOVERING /* 40: our lame addition to allow caller to fail a lock
- request if it is being recovered */
-} dlm_status;
-
-
-
-typedef struct _dlm_recovery_ctxt
-{
- struct list_head resources;
- struct list_head received; // list of dlm_reco_lock_infos received from other nodes during recovery
- u16 new_master;
- u16 dead_node;
- u16 sending_node;
- u32 next_seq;
- util_thread_info thread;
- unsigned long node_map[BITS_TO_LONGS(NM_MAX_NODES)];
-} dlm_recovery_ctxt;
-
-
-struct _dlm_ctxt
-{
- struct list_head list;
- struct list_head *resources;
- struct list_head dirty_list;
- spinlock_t spinlock;
- struct rw_semaphore recovery_sem;
- char *name;
- util_thread_info thread;
- struct inode *group;
- u32 key;
- u16 group_index;
- unsigned long node_map[BITS_TO_LONGS(NM_MAX_NODES)];
- unsigned long recovery_map[BITS_TO_LONGS(NM_MAX_NODES)];
- dlm_recovery_ctxt reco;
-};
-
-#define DLM_LOCK_RES_UNINITED 0x00000001
-#define DLM_LOCK_RES_RECOVERING 0x00000002
-#define DLM_LOCK_RES_READY 0x00000004
-#define DLM_LOCK_RES_DIRTY 0x00000008
-#define DLM_LOCK_RES_IN_PROGRESS 0x00000010
-
-typedef struct _dlm_lock_resource
-{
- struct list_head list;
-
- /* please keep these next 3 in this order
- * some funcs want to iterate over all lists */
- struct list_head granted;
- struct list_head converting;
- struct list_head blocked;
-
- struct list_head dirty;
- struct list_head recovering; // dlm_recovery_ctxt.resources list
- spinlock_t spinlock;
- wait_queue_head_t wq;
- u16 owner; // node which owns the lock resource, or unknown
- u16 state;
- struct qstr lockname;
- char lvb[DLM_LVB_LEN];
-} dlm_lock_resource;
-
-typedef void (dlm_astlockfunc_t)(void *);
-typedef void (dlm_bastlockfunc_t)(void *, int);
-typedef void (dlm_astunlockfunc_t)(void *, dlm_status);
-
-typedef struct _dlm_lockstatus dlm_lockstatus;
-
-typedef struct _dlm_lock
-{
- struct list_head list;
- struct list_head ast_list;
- dlm_lock_resource *lockres;
- spinlock_t spinlock;
-
- s8 type;
- s8 convert_type;
- s8 highest_blocked;
- s8 reserved1;
- u16 node;
- u16 reserved2;
-
- dlm_astlockfunc_t *ast; // ast and bast must be callable while holding a spinlock!
- dlm_bastlockfunc_t *bast;
- void *astdata;
- u64 cookie;
- dlm_lockstatus *lksb;
-} dlm_lock;
-
-
-#define DLM_LKSB_KERNEL_ALLOCATED 0x01 // allocated on master node on behalf of remote node
-#define DLM_LKSB_PUT_LVB 0x02
-#define DLM_LKSB_GET_LVB 0x04
-#define DLM_LKSB_UNUSED2 0x08
-#define DLM_LKSB_UNUSED3 0x10
-#define DLM_LKSB_UNUSED4 0x20
-#define DLM_LKSB_UNUSED5 0x40
-#define DLM_LKSB_UNUSED6 0x80
-
-struct _dlm_lockstatus {
- dlm_status status; // can we just change this to a u8 or u16?
- u32 flags;
- dlm_lock *lockid;
- char lvb[DLM_LVB_LEN];
-};
-
-enum {
- DLM_MLE_BLOCK,
- DLM_MLE_MASTER
-};
-
-typedef struct _dlm_lock_name
-{
- u8 len;
- u8 name[0]; // [DLM_LOCKID_NAME_MAX]
-} dlm_lock_name;
-
-/* good god this needs to be trimmed down */
-typedef struct _dlm_master_list_entry
-{
- struct list_head list;
- dlm_ctxt *dlm;
- spinlock_t spinlock;
- wait_queue_head_t wq;
- atomic_t woken;
- atomic_t refcnt;
- unsigned long maybe_map[BITS_TO_LONGS(NM_MAX_NODES)];
- unsigned long vote_map[BITS_TO_LONGS(NM_MAX_NODES)];
- unsigned long response_map[BITS_TO_LONGS(NM_MAX_NODES)];
- unsigned long node_map[BITS_TO_LONGS(NM_MAX_NODES)];
- u16 master;
- u8 error;
- u8 type; // BLOCK or MASTER
- union {
- dlm_lock_resource *res;
- dlm_lock_name name;
- } u;
-} dlm_master_list_entry;
-
-
-
-#define DLM_MASTER_REQUEST_MSG 500
-#define DLM_MASTER_REQUEST_RESP_MSG 501
-#define DLM_ASSERT_MASTER_MSG 502
-#define DLM_CREATE_LOCK_MSG 503
-#define DLM_CONVERT_LOCK_MSG 504
-#define DLM_PROXY_AST_MSG 505
-#define DLM_UNLOCK_LOCK_MSG 506
-
-#define DLM_RECO_NODE_DATA_MSG 507
-
-
-typedef struct _dlm_reco_node_data
-{
- int state;
- u16 node_num;
- struct list_head list;
- struct list_head granted;
- struct list_head converting;
- struct list_head blocked;
-} dlm_reco_node_data;
-
-enum {
- DLM_RECO_NODE_DATA_DEAD = -1,
- DLM_RECO_NODE_DATA_INIT = 0,
- DLM_RECO_NODE_DATA_REQUESTING,
- DLM_RECO_NODE_DATA_REQUESTED,
- DLM_RECO_NODE_DATA_RECEIVING,
- DLM_RECO_NODE_DATA_DONE,
- DLM_RECO_NODE_DATA_FINALIZE_SENT,
-};
-
-
-enum {
- DLM_MASTER_RESP_NO,
- DLM_MASTER_RESP_YES,
- DLM_MASTER_RESP_MAYBE,
- DLM_MASTER_RESP_ERROR
-};
-
-
-typedef struct _dlm_master_request
-{
- u16 node_idx;
- u8 namelen;
- u8 pad1;
- u8 name[NM_MAX_NAME_LEN];
-} dlm_master_request;
-
-typedef struct _dlm_master_request_resp
-{
- u16 node_idx;
- u8 response;
- u8 namelen;
- u8 name[NM_MAX_NAME_LEN];
-} dlm_master_request_resp;
-
-typedef struct _dlm_assert_master
-{
- u16 node_idx;
- u8 namelen;
- u8 pad1;
- u8 name[NM_MAX_NAME_LEN];
-} dlm_assert_master;
-
-typedef struct _dlm_create_lock
-{
- u64 cookie;
- u32 flags;
- u16 node_idx;
- s8 requested_type;
- u8 namelen;
- u8 name[NM_MAX_NAME_LEN];
-} dlm_create_lock;
-
-typedef struct _dlm_convert_lock
-{
- u64 cookie;
- u32 flags;
- u16 node_idx;
- s8 requested_type;
- u8 namelen;
- u8 name[NM_MAX_NAME_LEN];
- s8 lvb[0];
-} dlm_convert_lock;
-#define DLM_CONVERT_LOCK_MAX_LEN (sizeof(dlm_convert_lock) + DLM_LVB_LEN)
-
-typedef struct _dlm_unlock_lock
-{
- u64 cookie;
- u32 flags;
- u16 node_idx;
- u8 namelen;
- u8 pad1;
- u8 name[NM_MAX_NAME_LEN];
- s8 lvb[0];
-} dlm_unlock_lock;
-#define DLM_UNLOCK_LOCK_MAX_LEN (sizeof(dlm_unlock_lock) + DLM_LVB_LEN)
-
-typedef struct _dlm_proxy_ast
-{
- u64 cookie;
- u32 flags;
- u16 node_idx;
- u16 pad1;
- u8 type;
- u8 blocked_type;
- u8 namelen;
- u8 pad2;
- u8 name[NM_MAX_NAME_LEN];
- s8 lvb[0];
-} dlm_proxy_ast;
-#define DLM_PROXY_AST_MAX_LEN (sizeof(dlm_proxy_ast) + DLM_LVB_LEN)
-
-
-static inline void dlm_master_request_to_net(dlm_master_request *m)
-{
- m->node_idx = htons(m->node_idx);
-}
-static inline void dlm_master_request_to_host(dlm_master_request *m)
-{
- m->node_idx = ntohs(m->node_idx);
-}
-
-static inline void dlm_master_request_resp_to_net(dlm_master_request_resp *m)
-{
- m->node_idx = htons(m->node_idx);
-}
-static inline void dlm_master_request_resp_to_host(dlm_master_request_resp *m)
-{
- m->node_idx = ntohs(m->node_idx);
-}
-
-static inline void dlm_assert_master_to_net(dlm_assert_master *m)
-{
- m->node_idx = htons(m->node_idx);
-}
-static inline void dlm_assert_master_to_host(dlm_assert_master *m)
-{
- m->node_idx = ntohs(m->node_idx);
-}
-
-static inline void dlm_create_lock_to_net(dlm_create_lock *c)
-{
- c->cookie = cpu_to_be64(c->cookie);
- c->flags = htonl(c->flags);
- c->node_idx = htons(c->node_idx);
-}
-static inline void dlm_create_lock_to_host(dlm_create_lock *c)
-{
- c->cookie = be64_to_cpu(c->cookie);
- c->flags = ntohl(c->flags);
- c->node_idx = ntohs(c->node_idx);
-}
-
-static inline void dlm_convert_lock_to_net(dlm_convert_lock *c)
-{
- c->cookie = cpu_to_be64(c->cookie);
- c->flags = htonl(c->flags);
- c->node_idx = htons(c->node_idx);
-}
-static inline void dlm_convert_lock_to_host(dlm_convert_lock *c)
-{
- c->cookie = be64_to_cpu(c->cookie);
- c->flags = ntohl(c->flags);
- c->node_idx = ntohs(c->node_idx);
-}
-
-static inline void dlm_unlock_lock_to_net(dlm_unlock_lock *u)
-{
- u->cookie = cpu_to_be64(u->cookie);
- u->flags = htonl(u->flags);
- u->node_idx = htons(u->node_idx);
-}
-static inline void dlm_unlock_lock_to_host(dlm_unlock_lock *u)
-{
- u->cookie = be64_to_cpu(u->cookie);
- u->flags = ntohl(u->flags);
- u->node_idx = ntohs(u->node_idx);
-}
-
-static inline void dlm_proxy_ast_to_net(dlm_proxy_ast *a)
-{
- a->cookie = cpu_to_be64(a->cookie);
- a->flags = htonl(a->flags);
- a->node_idx = htons(a->node_idx);
-}
-static inline void dlm_proxy_ast_to_host(dlm_proxy_ast *a)
-{
- a->cookie = be64_to_cpu(a->cookie);
- a->flags = ntohl(a->flags);
- a->node_idx = ntohs(a->node_idx);
-}
-
-
-int dlm_create_lock_handler(net_msg *msg, u32 len, void *data);
-int dlm_convert_lock_handler(net_msg *msg, u32 len, void *data);
-int dlm_proxy_ast_handler(net_msg *msg, u32 len, void *data);
-
-int dlm_unlock_lock_handler(net_msg *msg, u32 len, void *data);
-
-
-
-
-
-void dlm_shuffle_lists(dlm_ctxt *dlm, dlm_lock_resource *res);
-void dlm_thread_run_lock_resources(dlm_ctxt *dlm);
-int dlm_launch_thread(dlm_ctxt *dlm);
-void dlm_complete_thread(dlm_ctxt *dlm);
-
-dlm_status dlmlock(dlm_ctxt *dlm, int mode, dlm_lockstatus *lksb, int flags, char *name,
- dlm_astlockfunc_t *ast, void *data, dlm_bastlockfunc_t *bast);
-
-dlm_status dlmlock_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags);
-dlm_status dlmlock_remote(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags);
-
-dlm_status dlmconvert_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type);
-dlm_status dlmconvert_remote(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, int flags, int type);
-
-dlm_status dlmunlock(dlm_ctxt *dlm, dlm_lockstatus *lksb, int flags,
- dlm_astunlockfunc_t *unlockast, void *data);
-dlm_status dlmunlock_common(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int flags, int *call_ast, int master_node);
-static inline dlm_status dlmunlock_master(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int flags, int *call_ast)
-{
- return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 1);
-}
-
-static inline dlm_status dlmunlock_remote(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int flags, int *call_ast)
-{
- return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 0);
-}
-
-
-dlm_ctxt * dlm_register_domain(char *domain, char *group_name, u32 key);
-void dlm_unregister_domain(dlm_ctxt *dlm);
-dlm_lock_resource * dlm_get_lock_resource(dlm_ctxt *dlm, struct qstr *lockname, int flags);
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
-int dlm_refresh_lock_resource(dlm_ctxt *dlm, dlm_lock_resource *res);
-int dlm_do_ast(dlm_ctxt *dlm, dlm_lock_resource *res, dlm_lock *lock);
-int dlm_do_bast(dlm_ctxt *dlm, dlm_lock_resource *res, dlm_lock *lock, int blocked_type);
-u16 dlm_nm_this_node(dlm_ctxt *dlm);
-void dlm_kick_thread(dlm_ctxt *dlm, dlm_lock_resource *res);
-
-int dlm_nm_init(dlm_ctxt *dlm);
-int dlm_heartbeat_init(dlm_ctxt *dlm);
-
-dlm_lock_resource * dlm_lookup_lock(dlm_ctxt *dlm, struct qstr *lockname);
-dlm_ctxt * dlm_lookup_domain(char *domain);
-
-void dlm_hb_node_down_cb(struct inode *group, struct inode *node, int idx, void *data);
-void dlm_hb_node_up_cb(struct inode *group, struct inode *node, int idx, void *data);
-int dlm_hb_node_dead(dlm_ctxt *dlm, int node);
-int dlm_hb_node_up(dlm_ctxt *dlm, int node);
-int __dlm_hb_node_dead(dlm_ctxt *dlm, int node);
-int __dlm_hb_node_up(dlm_ctxt *dlm, int node);
-
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
-int dlm_master_request_handler(net_msg *msg, u32 len, void *data);
-int dlm_master_request_resp_handler(net_msg *msg, u32 len, void *data);
-int dlm_assert_master_handler(net_msg *msg, u32 len, void *data);
-dlm_lock_resource * __dlm_lookup_lock(dlm_ctxt *dlm, struct qstr *lockname);
-void dlm_init_lockres(dlm_lock_resource *res, struct qstr *lockname);
-void dlm_wait_on_lockres(dlm_lock_resource *res);
-void dlm_dump_everything(void);
-void dlm_dump_dlm(dlm_ctxt *dlm);
-
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
-
-void dlm_wait_on_lockres(dlm_lock_resource *res);
-void __dlm_wait_on_lockres(dlm_lock_resource *res);
-
-
-
-
-static inline const char * dlm_lock_mode_name(int mode)
-{
- switch (mode) {
- case LKM_EXMODE:
- return "EX";
- case LKM_PRMODE:
- return "PR";
- case LKM_NLMODE:
- return "NL";
- }
- return "UNKNOWN";
-}
-
-
-static inline int dlm_lock_compatible(int existing, int request)
-{
- /* NO_LOCK compatible with all */
- if (request == LKM_NLMODE ||
- existing == LKM_NLMODE)
- return 1;
-
- /* EX incompatible with all non-NO_LOCK */
- if (request == LKM_EXMODE)
- return 0;
-
- /* request must be PR, which is compatible with PR */
- if (existing == LKM_PRMODE)
- return 1;
-
- return 0;
-}
-
-static inline int dlm_lock_on_list(struct list_head *head, dlm_lock *lock)
-{
- struct list_head *iter;
- dlm_lock *tmplock;
-
- list_for_each(iter, head) {
- tmplock = list_entry(iter, dlm_lock, list);
- if (tmplock == lock)
- return 1;
- }
- return 0;
-}
-
-static inline int dlm_mle_equal(dlm_ctxt *dlm, dlm_master_list_entry *mle, struct qstr *lockname)
-{
- dlm_lock_resource *res;
-
- if (dlm != mle->dlm)
- return 0;
-
- if (mle->type == DLM_MLE_BLOCK) {
- if (lockname->len != mle->u.name.len ||
- strncmp(lockname->name, mle->u.name.name, lockname->len)!=0)
- return 0;
- } else {
- res = mle->u.res;
- if (res->lockname.hash != lockname->hash ||
- res->lockname.len != lockname->len ||
- strncmp(res->lockname.name, lockname->name, lockname->len)!=0)
- return 0;
- }
- return 1;
-}
-
-static inline dlm_status dlm_err_to_dlm_status(int err)
-{
- dlm_status ret;
- if (err == -ENOMEM)
- ret = DLM_SYSERR;
- else if (err == -ETIMEDOUT || net_link_down(err, NULL))
- ret = DLM_NOLOCKMGR;
- else if (err == -EINVAL)
- ret = DLM_BADPARAM;
- else if (err == -ENAMETOOLONG)
- ret = DLM_IVBUFLEN;
- else
- ret = DLM_BADARGS;
- return ret;
-}
-
-#endif /* CLUSTER_DLMMOD_H */
Deleted: trunk/fs/ocfs2/cluster/dlmrecovery.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmrecovery.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmrecovery.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,947 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmrecovery.c
- *
- * recovery stuff
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-static void dlm_do_local_recovery_cleanup(dlm_ctxt *dlm, u16 dead_node, int locked);
-
-int dlm_recovery_thread(void *data);
-void dlm_complete_recovery_thread(dlm_ctxt *dlm);
-int dlm_launch_recovery_thread(dlm_ctxt *dlm);
-void dlm_kick_recovery_thread(dlm_ctxt *dlm);
-
-u16 dlm_pick_recovery_master(dlm_ctxt *dlm, u16 *new_dead_node);
-static int dlm_remaster_locks_local(dlm_ctxt *dlm);
-int dlm_init_recovery_area(dlm_ctxt *dlm);
-int dlm_request_all_locks(dlm_ctxt *dlm, u16 request_from, u16 dead_node);
-void dlm_destroy_recovery_area(dlm_ctxt *dlm, u16 dead_node);
-
-#define DLM_RECOVERY_THREAD_MS 2000
-
-
-#ifdef LOUSY_RECOVERY
-
-/*
- * RECOVERY THREAD
- */
-
-void dlm_kick_recovery_thread(dlm_ctxt *dlm)
-{
- /* wake the recovery thread
- * this will wake the reco thread in one of three places
- * 1) sleeping with no recovery happening
- * 2) sleeping with recovery mastered elsewhere
- * 3) recovery mastered here, waiting on reco data */
- atomic_set(&dlm->reco.thread.woken, 1);
- wake_up(&dlm->reco.thread.thread_wq);
-}
-
-/* Launch the recovery thread */
-int dlm_launch_recovery_thread(dlm_ctxt *dlm)
-{
- dlmprintk0("starting recovery thread...\n");
- dlm->reco.thread.pid = kernel_thread (dlm_recovery_thread, dlm, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
- if (dlm->reco.thread.pid < 0) {
- dlmprintk("unable to launch recovery thread, error=%d", dlm->reco.thread.pid);
- return -EINVAL;
- }
- dlmprintk0("recovery thread running...\n");
- return 0;
-}
-
-void dlm_complete_recovery_thread(dlm_ctxt *dlm)
-{
- dlmprintk0 ("waiting for recovery thread to exit....");
- send_sig (SIGINT, dlm->reco.thread.task, 0);
- wait_for_completion (&dlm->reco.thread.complete);
- dlmprintk0 ("recovery thread exited\n");
- dlm->reco.thread.task = NULL;
-}
-
- /*
- * this is lame, but here's how recovery works...
- * 1) all recovery threads cluster wide will work on recovering
- * ONE node at a time
- * 2) negotiate who will take over all the locks for the dead node.
- * thats right... ALL the locks.
- * 3) once a new master is chosen, everyone scans all locks
- * and moves aside those mastered by the dead guy
- * 4) each of these locks should be locked until recovery is done
- * 5) the new master collects up all of secondary lock queue info
- * one lock at a time, forcing each node to communicate back
- * before continuing
- * 6) each secondary lock queue responds with the full known lock info
- * 7) once the new master has run all its locks, it sends a ALLDONE!
- * message to everyone
- * 8) upon receiving this message, the secondary queue node unlocks
- * and responds to the ALLDONE
- * 9) once the new master gets responses from everyone, he unlocks
- * everything and recovery for this dead node is done
- *10) go back to 2) while there are still dead nodes
- *
- */
-
-
-
-int dlm_recovery_thread(void *data)
-{
- int status, i;
- int cnt = 0, dlm_num;
- struct list_head *iter, *iter2, *tmpiter;
- dlm_lock_resource *res;
- char name[12];
- dlm_ctxt *dlm = data;
- u16 tmp;
-
-
- dlm_num = nm_get_group_global_index(dlm->group);
- sprintf(name, "dlmreco-%03u", dlm_num);
- util_daemonize (name, strlen(name), 1);
- dlm->reco.thread.task = current;
-
- while (1) {
- spin_lock(&dlm->spinlock);
-
- /* check to see if the new master has died */
- if (dlm->reco.new_master != NM_INVALID_SLOT_NUM &&
- test_bit(dlm->reco.new_master, dlm->recovery_map)) {
- dlmprintk("new master %u died while recovering %u!\n",
- dlm->reco.new_master, dlm->reco.dead_node);
- // unset the new_master, leave dead_node
- dlm->reco.new_master = NM_INVALID_SLOT_NUM;
- }
-
- /* select a target to recover */
- if (dlm->reco.dead_node == NM_INVALID_SLOT_NUM) {
- dlm->reco.dead_node = find_next_bit (dlm->recovery_map, NM_MAX_NODES, 0);
- if (dlm->reco.dead_node >= NM_MAX_NODES)
- dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
- } else if (!test_bit(dlm->reco.dead_node, dlm->recovery_map)) {
- // BUG?
- dlmprintk("dead_node %u no longer in recovery map!\n",
- dlm->reco.dead_node);
- dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
- }
-
- if (dlm->reco.dead_node == NM_INVALID_SLOT_NUM) {
- dlmprintk0("nothing to recover! sleeping now!\n");
- spin_unlock(&dlm->spinlock);
- goto sleep;
- }
- spin_unlock(&dlm->spinlock);
-
- /* take write barrier */
- /* (stops the list reshuffling thread, proxy ast handling) */
- down_write(&dlm->recovery_sem);
-
- /* choose a new master */
- if (dlm->reco.new_master == NM_INVALID_SLOT_NUM) {
- u16 new_dead_node = dlm->reco.dead_node;
- dlm->reco.new_master = dlm_pick_recovery_master(dlm, &new_dead_node);
- if (new_dead_node != dlm->reco.dead_node) {
- // master wants to recover a different node
- dlm->reco.dead_node = new_dead_node;
-
- // do local cleanup if heartbeat has not added the
- // node to the recovery map yet
- spin_lock(&dlm->spinlock);
- if (!test_bit(dlm->reco.dead_node, dlm->recovery_map)) {
- dlm_do_local_recovery_cleanup(dlm, dlm->reco.dead_node, 1);
- set_bit(dlm->reco.dead_node, dlm->recovery_map);
- clear_bit(dlm->reco.dead_node, dlm->node_map);
- }
- spin_unlock(&dlm->spinlock);
- }
- }
-
- dlmprintk("RECOVERY! new_master=%u, this node=%u, dead_node=%u\n",
- dlm->reco.new_master, dlm->group_index, dlm->reco.dead_node);
-
- if (dlm->reco.new_master != dlm->group_index) {
- /* it is safe to start everything back up here
- * because all of the dead node's lock resources
- * have been marked as in-recovery */
- up_write(&dlm->recovery_sem);
-
- // sit around until new_master is dead or done
- // we will get signalled by the waitqueue either way
- dlmprintk("new_master %u is recovering dead_node %u... waiting...\n",
- dlm->reco.new_master, dlm->reco.dead_node);
-sleep:
- atomic_set(&dlm->reco.thread.woken, 0);
- status = util_wait_atomic_eq(&dlm->reco.thread.thread_wq,
- &dlm->reco.thread.woken,
- 1, DLM_RECOVERY_THREAD_MS);
- if (status == 0 || status == -ETIMEDOUT) {
- if (atomic_read(&dlm->reco.thread.woken))
- dlmprintk0("aha!!! recovery thread woken!\n");
- else
- dlmprintk0("timed out waiting, running again\n");
- continue;
- }
- dlmprintk("recovery thread got %d while waiting\n", status);
- break;
- }
-
- /* new_master == dlm->group_index */
- status = dlm_remaster_locks_local(dlm);
- if (status < 0) {
- dlmprintk("error remastering locks for node %u!!!! retrying!\n",
- dlm->reco.dead_node);
- } else {
- // success! see if any other nodes need recovery
- spin_lock(&dlm->spinlock);
- clear_bit(dlm->reco.dead_node, dlm->recovery_map);
- spin_unlock(&dlm->spinlock);
- dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
- dlm->reco.new_master = NM_INVALID_SLOT_NUM;
- dlm->reco.sending_node = NM_INVALID_SLOT_NUM;
- dlm->reco.next_seq = 0;
- }
- up_write(&dlm->recovery_sem);
- // continue and look for another dead node
- }
-
- flush_scheduled_work();
- complete (&dlm->reco.thread.complete);
- dlmprintk0("quitting recovery thread!!!!!!\n");
- return 0;
-}
-
-/* +- if this node is NOT the new master... */
-/* +--- if master's dead_node is not the one we chose, do local cleanup again with proper dead_node */
-/* +--- wait for poll messages from new master: register net message handler, it will do the work */
-/* +--- check for death of new master */
-/* +--- if dead, unregister the handler, unset new_master, keep dead_node and goto "select a target" */
-/* |- on request, send header with number of packets, get response, then start blasting packets */
-/* |- retransmit any missed packets on request */
-/* |- once ALL DONE is received, run all locks again */
-/* +--- unset the RECOVERING flag */
-/* +--- set the new owner as new_master */
-/* +--- remove dead_node from recovery map */
-/* +--- unset new_master and dead_node and start all over */
-
-static spinlock_t dlm_reco_state_lock = SPIN_LOCK_UNLOCKED;
-
-
-static int dlm_remaster_locks_local(dlm_ctxt *dlm)
-{
- int num_nodes = NM_MAX_NODES, next=0, status = 0;
- dlm_reco_node_data *ndata;
- struct list_head *iter;
- int all_nodes_done;
-
-
-/* +- if this node is the new master, init the temp recovery area */
-/* |- poll each live node for lock state */
-/* |- collect the data from each node until node says it's done, or dead */
-/* +--- if node died, throw away temp recovery area, keep new_master and dead_node, goto "select a target" */
-/* |- apply all temp area changes to real lock */
-/* +- send ALL DONE message to each node */
-
- status = dlm_init_recovery_area(dlm);
- if (status < 0)
- return status;
-
- spin_lock(&dlm_reco_state_lock);
- list_for_each(iter, &dlm->reco.node_data) {
- ndata = list_entry (iter, dlm_reco_node_data, list);
- DLM_ASSERT(ndata->state == DLM_RECO_NODE_DATA_INIT);
- ndata->state = DLM_RECO_NODE_DATA_REQUESTING;
-
- status = dlm_request_all_locks(dlm, ndata->node_num, dlm->reco.dead_node);
- if (status < 0) {
- dlm_destroy_recovery_area(dlm, dlm->reco.dead_node);
- return status;
- }
-
- switch (ndata->state) {
- case DLM_RECO_NODE_DATA_INIT:
- case DLM_RECO_NODE_DATA_FINALIZE_SENT:
- case DLM_RECO_NODE_DATA_REQUESTED:
- DLM_ASSERT(0);
- break;
- case DLM_RECO_NODE_DATA_DEAD:
- dlmprintk("eek. node %u died after requesting recovery info for node %u\n",
- ndata->node_num, dlm->reco.dead_node);
- spin_unlock(&dlm_reco_state_lock);
- // start all over
- dlm_destroy_recovery_area(dlm, dlm->reco.dead_node);
- return -EAGAIN;
- case DLM_RECO_NODE_DATA_REQUESTING:
- ndata->state = DLM_RECO_NODE_DATA_REQUESTED;
- dlmprintk("now receiving recovery data from node %u for dead node %u\n",
- ndata->node_num, dlm->reco.dead_node);
- break;
- case DLM_RECO_NODE_DATA_RECEIVING:
- dlmprintk("already receiving recovery data from node %u for dead node %u\n",
- ndata->node_num, dlm->reco.dead_node);
- break;
- case DLM_RECO_NODE_DATA_DONE:
- dlmprintk("already DONE receiving recovery data from node %u for dead node %u\n",
- ndata->node_num, dlm->reco.dead_node);
- break;
- }
- }
- spin_unlock(&dlm_reco_state_lock);
-
- /* nodes should be sending reco data now
- * just need to wait */
-
- while (1) {
- /* wait to be signalled, with periodic timeout
- * to check for node death */
- atomic_set(&dlm->reco.thread.woken, 0);
- ret = util_wait_atomic_eq(&dlm->reco.thread.thread_wq,
- &dlm->reco.thread.woken, 1,
- DLM_RECOVERY_THREAD_MS);
- if (ret == 0 || ret == -ETIMEDOUT) {
- if (atomic_read(&dlm->reco.thread.woken))
- dlmprintk0("waiting on reco data... aha!!! recovery thread woken!\n");
- else
- dlmprintk0("waiting on reco data... timed out waiting\n");
- }
-
- /* either way, recheck all the nodes now to see if we are
- * done, or if anyone died */
- all_nodes_done = 1;
- spin_lock(&dlm_reco_state_lock);
- list_for_each(iter, &dlm->reco.node_data) {
- ndata = list_entry (iter, dlm_reco_node_data, list);
-
- switch (ndata->state) {
- case DLM_RECO_NODE_DATA_INIT:
- case DLM_RECO_NODE_DATA_REQUESTING:
- DLM_ASSERT(0);
- break;
- case DLM_RECO_NODE_DATA_DEAD:
- dlmprintk("eek. node %u died after requesting recovery info for node %u\n",
- ndata->node_num, dlm->reco.dead_node);
- spin_unlock(&dlm_reco_state_lock);
- // start all over
- dlm_destroy_recovery_area(dlm, dlm->reco.dead_node);
- return -EAGAIN;
- case DLM_RECO_NODE_DATA_RECEIVING:
- case DLM_RECO_NODE_DATA_REQUESTED:
- all_nodes_done = 0;
- break;
- case DLM_RECO_NODE_DATA_DONE:
- break;
- case DLM_RECO_NODE_DATA_FINALIZE_SENT:
- break;
- }
- }
- spin_unlock(&dlm_reco_state_lock);
-
- if (all_nodes_done) {
- /* all nodes are now in DLM_RECO_NODE_DATA_DONE state
- * just send a finalize message to everyone and
- * clean up */
- ret = dlm_finalize_recovery(dlm);
- if (ret < 0) {
- dlmprintk("dlm_finalize_recovery returned %d\n", ret);
- }
- dlm_destroy_recovery_area(dlm, dlm->reco.dead_node);
- status = ret;
- break;
- }
- }
-
- return status;
-}
-
-int dlm_init_recovery_area(dlm_ctxt *dlm)
-{
- int num=0, ret;
- dlm_reco_node_data *ndata;
- LIST_HEAD(tmplist);
-
- spin_lock(&dlm->spinlock);
- memcpy(dlm->reco.node_map, dlm->node_map, sizeof(dlm->node_map));
- /* nodes can only be removed (by dying) after dropping
- * this lock, and death will be trapped later, so this should do */
- spin_unlock(&dlm->spinlock);
-
- while (1) {
- num = find_next_bit (dlm->reco.node_map, NM_MAX_NODES, num);
- if (num >= NM_MAX_NODES) {
- break;
- }
- DLM_ASSERT(num != dead_node);
-
- ndata = kmalloc(sizeof(dlm_reco_node_data), GFP_KERNEL);
- if (!ndata) {
- dlm_destroy_recovery_area(dlm, dead_node);
- return -ENOMEM;
- }
- memset(ndata, 0, sizeof(dlm_reco_node_data));
- ndata->node_num = num;
- ndata->state = DLM_RECO_NODE_DATA_INIT;
- LIST_HEAD_INIT(&ndata->granted);
- LIST_HEAD_INIT(&ndata->converting);
- LIST_HEAD_INIT(&ndata->blocked);
- spin_lock(&dlm_reco_state_lock);
- list_add_tail(&ndata->list, &dlm->reco.node_data);
- spin_unlock(&dlm_reco_state_lock);
- num++;
- }
-
- return 0;
-}
-
-void dlm_destroy_recovery_area(dlm_ctxt *dlm, u16 dead_node)
-{
- struct list_head *iter, *iter2;
- dlm_reco_node_data *ndata;
- LIST_HEAD(tmplist);
-
- spin_lock(&dlm_reco_state_lock);
- list_splice_init(&dlm->reco.node_data, &tmplist);
- spin_unlock(&dlm_reco_state_lock);
-
-#warning this probably needs to be smarter
- list_for_each_safe(iter, iter2, &tmplist) {
- ndata = list_entry (iter, dlm_reco_node_data, list);
- kfree(ndata);
- }
-}
-
-int dlm_request_all_locks(dlm_ctxt *dlm, u16 request_from, u16 dead_node)
-{
- dlmprintk("dlm_request_all_locks: dead node is %u, sending request to %u\n",
- dead_node, request_from);
- // send message
- // sleep until all received or error
- return 0;
-}
-
-typedef struct _dlm_reco_request_locks
-{
- u16 dead_node;
-} dlm_reco_request_locks;
-
-typedef struct _dlm_reco_node_data
-{
-} dlm_reco_node_data;
-
-int dlm_request_all_locks_handler(net_msg *msg, u32 len, void *data)
-{
-#if 0
- int status;
- dlm_ctxt *dlm = data;
- dlm_lock_resource *res;
- dlm_lock *lock = NULL;
- dlm_proxy_ast *past = (dlm_proxy_ast *) msg->buf;
- struct qstr lockname = { .name=past->name, .len=past->namelen };
- struct list_head *iter, *head=NULL;
- u64 cookie = past->cookie;
- u32 flags = past->flags;
-
- if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
- (LKM_PUT_LVB|LKM_GET_LVB)) {
- dlmprintk("both PUT and GET lvb specified\n");
- return DLM_BADARGS;
- }
-
- dlmprintk("lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" :
- (flags & LKM_GET_LVB ? "get lvb" : "none"));
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- dlmprintk("type=%d, blocked_type=%d\n", past->type, past->blocked_type);
-
- if (past->type != DLM_AST &&
- past->type != DLM_BAST) {
- dlmprintk("Eeeek unknown ast type! %d, cookie=%llu, name=%*s\n",
- past->type, cookie, lockname.len, lockname.name);
- return 0;
- }
-
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res) {
- dlmprintk("eek! got %sast for unknown lockres! cookie=%llu, name=%*s, namelen=%d\n",
- past->type == DLM_AST ? "" : "b", cookie, lockname.len, lockname.name, lockname.len);
- return 0;
- }
-#endif
-
-}
-
-int dlm_reco_node_data_handler(net_msg *msg, u32 len, void *data)
-{
-#if 0
- int status;
- dlm_ctxt *dlm = data;
- dlm_lock_resource *res;
- dlm_lock *lock = NULL;
- dlm_proxy_ast *past = (dlm_proxy_ast *) msg->buf;
- struct qstr lockname = { .name=past->name, .len=past->namelen };
- struct list_head *iter, *head=NULL;
- u64 cookie = past->cookie;
- u32 flags = past->flags;
-
- if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
- (LKM_PUT_LVB|LKM_GET_LVB)) {
- dlmprintk("both PUT and GET lvb specified\n");
- return DLM_BADARGS;
- }
-
- dlmprintk("lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" :
- (flags & LKM_GET_LVB ? "get lvb" : "none"));
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- dlmprintk("type=%d, blocked_type=%d\n", past->type, past->blocked_type);
-
- if (past->type != DLM_AST &&
- past->type != DLM_BAST) {
- dlmprintk("Eeeek unknown ast type! %d, cookie=%llu, name=%*s\n",
- past->type, cookie, lockname.len, lockname.name);
- return 0;
- }
-
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res) {
- dlmprintk("eek! got %sast for unknown lockres! cookie=%llu, name=%*s, namelen=%d\n",
- past->type == DLM_AST ? "" : "b", cookie, lockname.len, lockname.name, lockname.len);
- return 0;
- }
-#endif
-}
-
-
-
-int dlm_recovery_request_handler(net_msg *msg, u32 len, void *data);
-int dlm_recovery_response_handler(net_msg *msg, u32 len, void *data);
-int dlm_recovery_lock_arr_req_handler(net_msg *msg, u32 len, void *data);
-
-typedef struct _dlm_reco_lock_info
-{
- u16 node;
- u16 unused1;
- u64 cookie;
- s8 type;
- s8 convert_type;
- u8 list;
- u8 lockname_len;
- u8 lockname[DLM_LOCKID_NAME_MAX];
-} dlm_reco_lock_info;
-
-enum {
- DLM_RECO_MASTER_REQUEST,
- DLM_RECO_XMIT_LOCKS_REQUEST,
- DLM_RECO_XMIT_LOCK_HDR_REQUEST,
- DLM_RECO_XMIT_LOCK_ARR_REQUEST,
- DLM_RECO_XMIT_COMPLETE_REQUEST,
- DLM_RECO_ALL_DONE_REQUEST
-};
-
-enum {
- DLM_RECO_NO_RESPONSE,
- DLM_RECO_YES_RESPONSE
-};
-
-#define DLM_LOCKS_PER_PACKET 40
-
-typedef struct _dlm_reco_lock_arr_req
-{
- u8 request_type;
- u8 num_locks;
- u16 dead_node;
- u32 seqnum;
- dlm_reco_lock_info lock[DLM_LOCKS_PER_PACKET];
-} dlm_reco_lock_arr_req;
-
-typedef struct _dlm_reco_request
-{
- u8 request_type;
- u8 unused1;
- u16 dead_node;
- u32 num;
-} dlm_reco_request;
-
-typedef struct _dlm_reco_response
-{
- u8 response_type;
- u8 unused1[7];
-} dlm_reco_response;
-
-static inline int dlm_reco_lock_info_valid(dlm_reco_lock_info *info)
-{
- if (info->type != LKM_NLMODE &&
- info->type != LKM_PRMODE &&
- info->type != LKM_EXMODE)
- return 0;
- if (info->convert_type != LKM_NLMODE &&
- info->convert_type != LKM_PRMODE &&
- info->convert_type != LKM_EXMODE)
- return 0;
- if (info->list > 2)
- return 0;
- return 1;
-}
-
-static inline int dlm_check_reco_lock_arr_msg(net_msg *msg, dlm_ctxt *dlm, int *out_of_order);
-
-static inline int dlm_check_reco_lock_arr_msg(net_msg *msg, dlm_ctxt *dlm, int *out_of_order)
-{
- int ret = -EINVAL;
- dlm_reco_lock_arr_req *req = (dlm_reco_lock_arr_req *)msg->buf;
-
- /* check a bunch of ugly conditions */
- *out_of_order = 0;
- if (req->num_locks > DLM_LOCKS_PER_PACKET) {
- dlmprintk("num_locks too large! %u\n", req->num_locks);
- } else if (req->seqnum != dlm->reco.next_seq) {
- dlmprintk("expected seq %lu from node %u, got %lu\n",
- dlm->reco.next_seq, msg->src_node,
- req->seqnum);
- *out_of_order = 1;
- } else if (dlm->reco.dead_node != req->dead_node) {
- dlmprintk("bad lock array: dead node=%u, sent=%u\n",
- dlm->reco.dead_node != req->dead_node);
- } else if (dlm->reco.new_master != dlm->group_index) {
- dlmprintk0("this node is not the recovery master!\n");
- } else if (dlm->reco.sending_node != msg->src_node ||
- dlm->group_index == msg->dest_node) {
- dlmprintk0("eek. sending_node=%u, actual=%u, dest=%u, me=%u\n",
- dlm->reco.sending_node, msg->src_node,
- msg->dest_node, dlm->group_index);
- } else
- ret = 0;
- return ret;
-}
-
-
-int dlm_recovery_lock_arr_req_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_reco_lock_arr_req *req = (dlm_reco_lock_arr_req *)msg->buf;
- dlm_lock_resource *res = NULL;
- dlm_reco_lock_info *info;
- dlm_lock **newlocks = NULL;
- dlm_lock *lock = NULL;
- int ret, i, out_of_order = 0;
-
- ret = 0;
- if (req->num_locks == 0)
- goto send_response;
-
- /* check to see if it's worth kmallocing */
- spin_lock(&dlm->spinlock);
- ret = dlm_check_reco_lock_arr_msg(msg, dlm, &out_of_order);
- spin_unlock(&dlm->spinlock);
- if (ret < 0)
- goto send_response;
-
- newlocks = kmalloc(req->num_locks * sizeof(dlm_lock *), GFP_KERNEL);
- if (!newlocks) {
- dlmprintk0("failed to alloc temp lock array!\n");
- ret = -ENOMEM;
- goto send_response;
- }
- memset(newlocks, 0, req->num_locks * sizeof(dlm_lock *));
- for (i=0; i<req->num_locks; i++) {
- info = &(req->lock[i]);
- if (!dlm_reco_lock_info_valid(info)) {
- ret = -EINVAL;
- goto send_response;
- }
- lock = newlocks[i] = kmem_cache_alloc(dlm_lock_cache, GFP_KERNEL);
- if (!newlocks[i]) {
- ret = -ENOMEM;
- goto send_response;
- }
- memset(lock, 0, sizeof(dlm_lock));
- LIST_HEAD_INIT(&lock->list);
- LIST_HEAD_INIT(&lock->ast_list);
- spin_lock_init(&lock->spinlock);
- lock->type = info->type;
- lock->convert_type = info->convert_type;
- lock->node = dlm->group_index;
- //atomic_set(&lock->ast_lock, 0);
- //atomic_set(&lock->bast_lock, 0);
- lock->ast = NULL;
- lock->bast = NULL;
- lock->astdata = (void *)info->list; // cheating here...
- lock->cookie = info->cookie;
- }
-
- spin_lock(&dlm->spinlock);
- /* ok now that everything is allocated and the lock has
- * been taken again, recheck all those stupid conditions */
- ret = dlm_check_reco_lock_arr_msg(msg, dlm, &out_of_order);
- if (ret < 0) {
- spin_unlock(&dlm->spinlock);
- goto send_response;
- }
- for (i=0; i<req->num_locks; i++) {
- info = &(req->lock[i]);
- lock = newlocks[i];
- list_add_tail(&lock->list, &dlm->reco.received);
- }
- spin_unlock(&dlm->spinlock);
-
-send_response:
- if (newlocks) {
- if (ret < 0) {
- for (i=0; i<req->num_locks; i++)
- if (newlocks[i])
- kmem_cache_free(dlm_reco_lock_info_cache, newlocks[i]);
- }
- kfree(newlocks);
- }
-
- return ret;
-}
-int dlm_recovery_request_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
-}
-int dlm_recovery_response_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
-}
-
-
-
-
-
-static int dlm_send_reco_request(dlm_ctxt *dlm, dlm_reco_request *buf, u16 to, struct inode *node)
-{
- int ret;
- net_msg *msg = net_package_message(DLM_NET_RECOVERY_REQUEST_MSG_TYPE,
- dlm->key, buf, sizeof(*buf),
- dlm->group_index, to);
- if (!msg)
- return -ENOMEM;
- ret = net_send_udp_msg (node, msg, sizeof(*buf));
- kfree(msg);
- return ret;
-}
-
-static int dlm_recover_domain(dlm_ctxt *dlm)
-{
-
-
- return 0;
-}
-
-
-#endif /* LOUSY_RECOVERY */
-
-#warning may need to change kfree to put_lock and refcounting here
-static void dlm_do_local_recovery_cleanup(dlm_ctxt *dlm, u16 dead_node, int locked)
-{
- struct list_head *iter, *iter2, *tmpiter;
- dlm_lock_resource *res;
- dlm_lock *lock;
- int i;
- struct list_head *bucket;
-
- if (!locked)
- spin_lock(&dlm->spinlock);
-
- for (i=0; i<DLM_HASH_SIZE; i++) {
- bucket = &(dlm->resources[i]);
- list_for_each(iter, bucket) {
- res = list_entry (iter, dlm_lock_resource, list);
- spin_lock(&res->spinlock);
- if (res->owner == dead_node) {
- res->state |= DLM_LOCK_RES_RECOVERING;
- list_del(&res->recovering);
- list_add_tail(&res->recovering, &dlm->reco.resources);
- } else if (res->owner == dlm->group_index) {
- list_for_each_safe(iter2, tmpiter, &res->granted) {
- lock = list_entry (iter2, dlm_lock, list);
- if (lock->node == dead_node) {
- list_del(&lock->list);
- kfree(lock);
- }
- }
- list_for_each_safe(iter2, tmpiter, &res->converting) {
- lock = list_entry (iter2, dlm_lock, list);
- if (lock->node == dead_node) {
- list_del(&lock->list);
- kfree(lock);
- }
- }
- list_for_each_safe(iter2, tmpiter, &res->blocked) {
- lock = list_entry (iter2, dlm_lock, list);
- if (lock->node == dead_node) {
- list_del(&lock->list);
- kfree(lock);
- }
- }
- }
- spin_unlock(&res->spinlock);
- }
- }
-
- if (!locked)
- spin_unlock(&dlm->spinlock);
-}
-
-
-void dlm_hb_node_down_cb(struct inode *group, struct inode *node, int idx, void *data)
-{
- //int ret;
- //struct inode *group = ptr1;
- //struct inode *node = ptr2;
- dlm_ctxt *dlm = data;
-
- spin_lock(&dlm->spinlock);
-
- if (!test_bit(idx, dlm->node_map))
- dlmprintk("node %u already removed from nodemap!\n", idx);
- else {
- dlmprintk("node %u being removed from nodemap!\n", idx);
- clear_bit(idx, dlm->node_map);
- }
-
- if (test_bit(idx, dlm->recovery_map))
- dlmprintk("node %u already added to recovery map!\n", idx);
- else {
- set_bit(idx, dlm->recovery_map);
- dlm_do_local_recovery_cleanup(dlm, idx, 1);
- }
- spin_unlock(&dlm->spinlock);
-}
-
-void dlm_hb_node_up_cb(struct inode *group, struct inode *node, int idx, void *data)
-{
- //struct inode *group = ptr1;
- //struct inode *node = ptr2;
- dlm_ctxt *dlm = data;
-
- spin_lock(&dlm->spinlock);
-
- if (test_bit(idx, dlm->recovery_map)) {
- dlmprintk("BUG!!! node up message on node in recovery (%u)!!!\n", idx);
- } else {
- if (test_bit(idx, dlm->node_map))
- dlmprintk("node %u already in node map!!!\n", idx);
- else {
- dlmprintk("node %u being added to node map!!!\n", idx);
- set_bit(idx, dlm->node_map);
- }
- }
-
- spin_unlock(&dlm->spinlock);
-}
-
-int __dlm_hb_node_dead(dlm_ctxt *dlm, int node)
-{
- if (test_bit(node, dlm->recovery_map))
- return 1;
- return 0;
-}
-
-int __dlm_hb_node_up(dlm_ctxt *dlm, int node)
-{
- if (test_bit(node, dlm->node_map))
- return 1;
- return 0;
-}
-
-int dlm_hb_node_dead(dlm_ctxt *dlm, int node)
-{
- int ret;
- spin_lock(&dlm->spinlock);
- ret = __dlm_hb_node_dead(dlm, node);
- spin_unlock(&dlm->spinlock);
- return ret;
-}
-
-int dlm_hb_node_up(dlm_ctxt *dlm, int node)
-{
- int ret;
- spin_lock(&dlm->spinlock);
- ret = __dlm_hb_node_up(dlm, node);
- spin_unlock(&dlm->spinlock);
- return ret;
-}
-
-u16 dlm_pick_recovery_master(dlm_ctxt *dlm, u16 *new_dead_node)
-{
- u16 master = 0;
-#if 0
- dlm_status ret;
- dlm_lockstatus lksb;
-
- ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY,
- DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast);
-
- if (ret == DLM_NORMAL) {
- // I am master
- // send message to all nodes saying that I am beginning a recovery session for node XX,
- // then call dlmunlock???
-
- } else if (ret == DLM_NOTQUEUED) {
- // another node is master
- // wait on reco.new_master != NM_INVALID_SLOT_NUM
- }
-
- // at this point, every node in this domain should have reco.new_master and .dead_node set, even
- // if they have not discovered the dead node on their own
- //
- //
- // atomic_set(&dlm->reco.thread.woken, 0);
- // 232 status = util_wait_atomic_eq(&dlm->reco.thread.thread_wq,
- // 233 &dlm->reco.thread.woken,
- // 234 1, DLM_RECOVERY_THREAD_MS);
- //
-#endif
- return master;
-}
Deleted: trunk/fs/ocfs2/cluster/dlmthread.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmthread.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmthread.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,326 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmthread.c
- *
- * standalone DLM module
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-extern spinlock_t dlm_domain_lock;
-extern struct list_head dlm_domains;
-extern u16 dlm_global_index;
-
-static int dlm_thread(void *data);
-
-#define dlm_lock_is_remote(dlm, lock) ((lock)->node != (dlm)->group_index)
-
-/*
- * DLM THREAD
- */
-
-void dlm_shuffle_lists(dlm_ctxt *dlm, dlm_lock_resource *res)
-{
- dlm_lock *lock, *target;
- struct list_head *iter, *tmpiter;
- LIST_HEAD(bast_list);
- struct list_head *head;
- s8 hi;
-
- dlmprintk("shuffle res %*s\n", res->lockname.len, res->lockname.name);
-
- spin_lock(&res->spinlock);
-
-#if 0
- {
- int g=0, c=0, b=0;
- list_for_each(iter, &res->granted) {
- g++;
- }
- list_for_each(iter, &res->converting) {
- c++;
- }
- list_for_each(iter, &res->blocked) {
- b++;
- }
- dlmprintk("(%d) granted: %d, converting: %d, blocked: %d\n",
- current->pid, g, c, b);
- }
-#endif
-
-converting:
- if (list_empty(&res->converting))
- goto blocked;
- dlmprintk("res %*s has locks on a convert queue\n", res->lockname.len,
- res->lockname.name);
-
- target = list_entry(res->converting.next, dlm_lock, list);
- if (target->convert_type == LKM_IVMODE) {
- dlmprintk0("eeek!!! converting a lock with no "
- "convert_type!!!!\n");
- BUG();
- }
- head = &res->granted;
- list_for_each(iter, head) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock==target)
- continue;
- if (!dlm_lock_compatible(lock->type, target->convert_type)) {
- if (lock->highest_blocked == LKM_IVMODE)
- list_add(&lock->ast_list, &bast_list);
- if (lock->highest_blocked < target->convert_type)
- lock->highest_blocked = target->convert_type;
- }
- }
- head = &res->converting;
- list_for_each(iter, head) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock==target)
- continue;
- if (!dlm_lock_compatible(lock->type, target->convert_type)) {
- if (lock->highest_blocked == LKM_IVMODE)
- list_add(&lock->ast_list, &bast_list);
- if (lock->highest_blocked < target->convert_type)
- lock->highest_blocked = target->convert_type;
- }
- }
-
- /* we can convert the lock */
- if (list_empty(&bast_list)) {
- spin_lock(&target->spinlock);
- DLM_ASSERT(target->highest_blocked == LKM_IVMODE);
-
- dlmprintk("calling ast for converting lock: %*s, have: %d, "
- "granting: %d, node: %u\n", res->lockname.len,
- res->lockname.name, target->type,
- target->convert_type, target->node);
-
- target->type = target->convert_type;
- target->convert_type = LKM_IVMODE;
- list_del(&target->list);
- list_add_tail(&target->list, &res->granted);
-
- DLM_ASSERT(target->lksb);
- target->lksb->status = DLM_NORMAL;
-
- spin_unlock(&target->spinlock);
-
- if (dlm_do_ast(dlm, res, target) < 0)
- dlmprintk0("eek\n");
- /* go back and check for more */
- goto converting;
- }
-
-blocked:
- if (list_empty(&res->blocked)) {
- goto basts;
- }
- target = list_entry(res->blocked.next, dlm_lock, list);
-
- head = &res->granted;
- list_for_each(iter, head) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock==target)
- continue;
- if (!dlm_lock_compatible(lock->type, target->type)) {
- if (lock->highest_blocked == LKM_IVMODE)
- list_add(&lock->ast_list, &bast_list);
- if (lock->highest_blocked < target->type)
- lock->highest_blocked = target->type;
- }
- }
-
- head = &res->converting;
- list_for_each(iter, head) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock==target)
- continue;
- if (!dlm_lock_compatible(lock->type, target->type)) {
- if (lock->highest_blocked == LKM_IVMODE)
- list_add(&lock->ast_list, &bast_list);
- if (lock->highest_blocked < target->type)
- lock->highest_blocked = target->type;
- }
- }
-
- /* we can grant the blocked lock (only
- * possible if converting list empty) */
- if (list_empty(&bast_list)) {
- spin_lock(&target->spinlock);
- DLM_ASSERT(target->highest_blocked == LKM_IVMODE);
-
- dlmprintk("calling ast for blocked lock: %*s, granting: %d, "
- "node: %u\n", res->lockname.len, res->lockname.name,
- target->type, target->node);
-
- // target->type is already correct
- list_del(&target->list);
- list_add_tail(&target->list, &res->granted);
-
- DLM_ASSERT(target->lksb);
- target->lksb->status = DLM_NORMAL;
-
- spin_unlock(&target->spinlock);
-
- if (dlm_do_ast(dlm, res, target) < 0)
- dlmprintk0("eek\n");
- /* go back and check for more */
- goto converting;
- }
-
-basts:
- list_for_each_safe(iter, tmpiter, &bast_list) {
- lock = list_entry(iter, dlm_lock, ast_list);
- spin_lock(&lock->spinlock);
- DLM_ASSERT(lock->highest_blocked > LKM_IVMODE);
- hi = lock->highest_blocked;
- lock->highest_blocked = LKM_IVMODE;
- list_del(&lock->ast_list);
- spin_unlock(&lock->spinlock);
-
- dlmprintk("delivering a bast for this lockres (blocked = %d\n",
- hi);
- if (dlm_do_bast(dlm, res, lock, hi) < 0)
- dlmprintk0("eeek\n");
- }
- spin_unlock(&res->spinlock);
-}
-
-
-/* must have NO locks when calling this */
-void dlm_kick_thread(dlm_ctxt *dlm, dlm_lock_resource *res)
-{
- if (res) {
- spin_lock(&dlm->spinlock);
- spin_lock(&res->spinlock);
- if (!(res->state & DLM_LOCK_RES_DIRTY)) {
- list_add_tail(&res->dirty, &dlm->dirty_list);
- res->state |= DLM_LOCK_RES_DIRTY;
- }
- spin_unlock(&res->spinlock);
- spin_unlock(&dlm->spinlock);
- }
-
- /* wake the dlm thread */
- atomic_set(&dlm->thread.woken, 1);
- wake_up(&dlm->thread.thread_wq);
-}
-
-/* Launch the NM thread for the mounted volume */
-int dlm_launch_thread(dlm_ctxt *dlm)
-{
- dlmprintk0("starting dlm thread...\n");
- dlm->thread.pid = kernel_thread (dlm_thread, dlm,
- CLONE_FS | CLONE_FILES |
- CLONE_SIGHAND);
- if (dlm->thread.pid < 0) {
- dlmprintk("unable to launch dlm thread, error=%d",
- dlm->thread.pid);
- return -EINVAL;
- }
- dlmprintk("dlm thread running for %s...\n", dlm->name);
- return 0;
-}
-
-void dlm_complete_thread(dlm_ctxt *dlm)
-{
- dlmprintk0 ("waiting for dlm thread to exit....");
- send_sig (SIGINT, dlm->thread.task, 0);
- wait_for_completion (&dlm->thread.complete);
- dlmprintk0 ("dlm thread exited\n");
- dlm->thread.task = NULL;
-}
-
-
-
-
-static int dlm_thread(void *data)
-{
- struct list_head *iter, *tmpiter;
- dlm_lock_resource *res;
- dlm_ctxt *dlm = data;
-
- util_daemonize ("dlm_thread", strlen("dlm_thread"), 1);
- dlm->thread.task = current;
-
- while (1) {
- atomic_set(&dlm->thread.woken, 0);
-
- down_read(&dlm->recovery_sem);
- spin_lock(&dlm->spinlock);
- list_for_each_safe(iter, tmpiter, &dlm->dirty_list) {
- res = list_entry(iter, dlm_lock_resource, dirty);
- /* don't shuffle secondary queues */
- if (res->owner != dlm->group_index)
- continue;
- spin_lock(&res->spinlock);
- list_del(&res->dirty);
- res->state &= ~DLM_LOCK_RES_DIRTY;
- spin_unlock(&res->spinlock);
-
- dlm_shuffle_lists(dlm, res);
- }
- spin_unlock(&dlm->spinlock);
- up_read(&dlm->recovery_sem);
-
- wait_event_interruptible(dlm->thread.thread_wq,
- atomic_read(&dlm->thread.woken));
-
- if (signal_pending(current)) {
- dlmprintk("DLM thread got signal while waiting\n");
- break;
- }
- }
-
- flush_scheduled_work();
- complete (&dlm->thread.complete);
- dlmprintk0("quitting DLM thread!!!!!!\n");
- return 0;
-}
Deleted: trunk/fs/ocfs2/cluster/dlmunlock.c
===================================================================
--- trunk/fs/ocfs2/cluster/dlmunlock.c 2005-01-21 01:44:51 UTC (rev 1818)
+++ trunk/fs/ocfs2/cluster/dlmunlock.c 2005-01-21 01:50:08 UTC (rev 1819)
@@ -1,404 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * dlmunlock.c
- *
- * underlying calls for unlocking locks
- *
- * Copyright (C) 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- */
-
-#include "warning_hack.h"
-
-#include "dlm_compat.h"
-#include "util.h"
-#include "dlmcommon.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#include <linux/random.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
-#include <linux/blkdev.h>
-#include <linux/socket.h>
-#include <linux/inet.h>
-#include <linux/spinlock.h>
-
-
-#include "heartbeat.h"
-#include "nodemanager.h"
-#include "tcp.h"
-#include "dlmmod.h"
-
-
-#define DLM_UNLOCK_FREE_LOCK 0x00000001
-#define DLM_UNLOCK_CALL_AST 0x00000002
-#define DLM_UNLOCK_REMOVE_LOCK 0x00000004
-#define DLM_UNLOCK_REGRANT_LOCK 0x00000008
-
-
-static dlm_status dlm_get_cancel_actions(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int *actions);
-static dlm_status dlm_get_unlock_actions(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int *actions);
-
-static dlm_status dlm_send_remote_unlock_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock,
- dlm_lockstatus *lksb,
- int flags);
-
-
-
-/*
- * locking:
- * caller needs: none
- * taken: res->spinlock and lock->spinlock taken and dropped
- * held on exit: none
- * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network
- */
-dlm_status dlmunlock_common(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int flags, int *call_ast, int master_node)
-{
- dlm_status status;
- int actions = 0;
-
- dlmprintk0("\n");
-
- if (master_node)
- DLM_ASSERT(res->owner == dlm->group_index);
- else
- DLM_ASSERT(res->owner != dlm->group_index);
-
- spin_lock(&res->spinlock);
- if (res->state & DLM_LOCK_RES_IN_PROGRESS) {
- if (!master_node) {
- /* TODO: should we return -EAGAIN or something here? */
- dlmprintk0("lockres in progress! eek!\n");
- }
-#warning THIS CAN SLEEP!!!
- __dlm_wait_on_lockres(res);
- res->state |= DLM_LOCK_RES_IN_PROGRESS;
- }
- spin_lock(&lock->spinlock);
-
- if (res->state & DLM_LOCK_RES_RECOVERING) {
- /* !!!!! */
- status = DLM_RECOVERING;
- goto leave;
- }
-
- /* according to spec and opendlm code
- * flags & LKM_CANCEL != 0: must be converting or blocked
- * flags & LKM_CANCEL == 0: must be granted
- * iow, to unlock a converting lock, you must first LKM_CANCEL
- * the convert, then call the unlock again with no LKM_CANCEL
- */
-
- if (flags & LKM_CANCEL) {
- status = dlm_get_cancel_actions(dlm, res, lock, lksb, &actions);
- } else {
- status = dlm_get_unlock_actions(dlm, res, lock, lksb, &actions);
- if (master_node && status == DLM_NORMAL) {
- /* make the final update to the lvb */
- if (lksb->flags & DLM_LKSB_PUT_LVB)
- memcpy(res->lvb, lksb->lvb, DLM_LVB_LEN);
- }
- }
-
- if (status != DLM_NORMAL)
- goto leave;
-
- if (!master_node) {
- /* drop locks and send message */
- spin_unlock(&lock->spinlock);
- spin_unlock(&res->spinlock);
- status = dlm_send_remote_unlock_request(dlm, res, lock,
- lksb, flags);
- spin_lock(&res->spinlock);
- spin_lock(&lock->spinlock);
- }
-
- if (actions & DLM_UNLOCK_REMOVE_LOCK)
- list_del(&lock->list);
- if (actions & DLM_UNLOCK_REGRANT_LOCK)
- list_add_tail(&lock->list, &res->granted);
-
-
-leave:
- res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
- spin_unlock(&lock->spinlock);
- spin_unlock(&res->spinlock);
- wake_up(&res->wq);
-
-
- if (actions & DLM_UNLOCK_FREE_LOCK) {
-#warning this must change to proper refcounting
- /* TODO: refcounting... tho for now this will work because
- * the middle layer is keeping track of everything */
- kfree(lock);
- lksb->lockid = NULL;
- }
- if (actions & DLM_UNLOCK_CALL_AST)
- *call_ast = 1;
-
- /* if cancel or unlock succeeded, lvb work is done */
- if (status == DLM_NORMAL)
- lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
-
- return status;
-}
-
-
-
-
-
-/*
- * locking:
- * caller needs: none
- * taken: none
- * held on exit: none
- * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network
- */
-static dlm_status dlm_send_remote_unlock_request(dlm_ctxt *dlm,
- dlm_lock_resource *res,
- dlm_lock *lock,
- dlm_lockstatus *lksb,
- int flags)
-{
- struct inode *inode = NULL;
- dlm_unlock_lock unlock;
- int tmpret;
- dlm_status ret;
- int status = 0;
- struct iovec iov[2];
- size_t iovlen = 1;
-
-
- dlmprintk0("\n");
-
- memset(&unlock, 0, sizeof(unlock));
- unlock.node_idx = dlm->group_index;
- unlock.flags = flags;
- unlock.cookie = lock->cookie;
- unlock.namelen = res->lockname.len;
- strncpy(unlock.name, res->lockname.name, unlock.namelen);
-
- iov[0].iov_len = sizeof(dlm_unlock_lock);
- iov[0].iov_base = &unlock;
-
- if (flags & LKM_PUT_LVB) {
- /* extra data to send if we are updating lvb */
- iov[1].iov_len = DLM_LVB_LEN;
- iov[1].iov_base = lock->lksb->lvb;
- iovlen++;
- }
-
- ret = DLM_NOLOCKMGR;
- lksb->status = DLM_NOLOCKMGR;
- inode = nm_get_group_node_by_index(dlm->group, res->owner);
- if (inode) {
- dlm_unlock_lock_to_net(&unlock);
- tmpret = net_send_message_iov(DLM_UNLOCK_LOCK_MSG, dlm->key,
- iov, iovlen, inode, &status);
- if (tmpret >= 0) {
- // successfully sent and received
- if (status == DLM_CANCELGRANT)
- ret = DLM_NORMAL;
- else
- ret = status;
- lksb->status = status;
- } else {
- dlmprintk("error occurred in net_send_message: %d\n",
- tmpret);
- ret = dlm_err_to_dlm_status(tmpret);
- lksb->status = ret;
- }
- iput(inode);
- }
-
- return ret;
-}
-
-/*
- * locking:
- * caller needs: none
- * taken: takes and drops res->spinlock
- * held on exit: none
- * returns: DLM_NORMAL, DLM_BADARGS, DLM_IVLOCKID,
- * return value from dlmunlock_master
- */
-int dlm_unlock_lock_handler(net_msg *msg, u32 len, void *data)
-{
- dlm_ctxt *dlm = data;
- dlm_unlock_lock *unlock = (dlm_unlock_lock *)msg->buf;
- dlm_lock_resource *res;
- struct list_head *iter;
- dlm_lock *lock = NULL;
- dlm_status status = DLM_NORMAL;
- int found = 0, i;
- dlm_lockstatus *lksb = NULL;
- int ignore;
- struct qstr lockname;
- u32 flags;
- struct list_head *queue;
-
- dlm_unlock_lock_to_host(unlock);
- lockname.name = unlock->name;
- lockname.len = unlock->namelen;
- flags = unlock->flags;
-
- if (flags & LKM_GET_LVB) {
- dlmprintk0("bad args! GET_LVB specified on unlock!\n");
- return DLM_BADARGS;
- }
-
- if ((flags & (LKM_PUT_LVB|LKM_CANCEL)) == (LKM_PUT_LVB|LKM_CANCEL)) {
- dlmprintk0("bad args! cannot modify lvb on a CANCEL "
- "request!\n");
- return DLM_BADARGS;
- }
-
- dlmprintk("lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" : "none");
-
- lockname.hash = full_name_hash(lockname.name, lockname.len);
-
- status = DLM_IVLOCKID;
- res = dlm_lookup_lock(dlm, &lockname);
- if (!res)
- goto not_found;
-
- queue=&res->granted;
- found = 0;
- spin_lock(&res->spinlock);
- for (i=0; i<3; i++) {
- list_for_each(iter, queue) {
- lock = list_entry(iter, dlm_lock, list);
- if (lock->cookie == unlock->cookie &&
- lock->node == unlock->node_idx) {
- found = 1;
- break;
- }
- }
- if (found)
- break;
- /* scan granted -> converting -> blocked queues */
- queue++;
- }
- spin_unlock(&res->spinlock);
- if (!found)
- goto not_found;
-
- /* lock was found on queue */
- lksb = lock->lksb;
- /* unlockast only called on originating node */
- if (flags & LKM_PUT_LVB) {
- lksb->flags |= DLM_LKSB_PUT_LVB;
- memcpy(&lksb->lvb[0], &unlock->lvb[0], DLM_LVB_LEN);
- }
-#warning BUG! THIS CAN SLEEP!!!
- /* so either we should respond with EAGAIN in dlmunlock_master
- * and skip the __dlm_wait_on_lockres, or this message type
- * should be dispatched */
- status = dlmunlock_master(dlm, res, lock, lksb, flags, &ignore);
- if (flags & LKM_PUT_LVB)
- lksb->flags &= ~DLM_LKSB_PUT_LVB;
-
-not_found:
- if (!found)
- dlmprintk("failed to find lock to unlock! cookie=%llu\n",
- unlock->cookie);
- else {
- /* send the lksb->status back to the other node */
- status = lksb->status;
- }
-
- return status;
-}
-
-
-static dlm_status dlm_get_cancel_actions(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int *actions)
-{
- dlm_status status;
-
- if (dlm_lock_on_list(&res->blocked, lock)) {
- /* cancel this outright */
- lksb->status = DLM_NORMAL;
- status = DLM_NORMAL;
- *actions = (DLM_UNLOCK_FREE_LOCK |
- DLM_UNLOCK_CALL_AST |
- DLM_UNLOCK_REMOVE_LOCK);
- } else if (dlm_lock_on_list(&res->converting, lock)) {
- /* cancel the request, put back on granted */
- lksb->status = DLM_NORMAL;
- status = DLM_NORMAL;
- *actions = (DLM_UNLOCK_CALL_AST |
- DLM_UNLOCK_REMOVE_LOCK |
- DLM_UNLOCK_REGRANT_LOCK);
- } else if (dlm_lock_on_list(&res->granted, lock)) {
- /* too late, already granted. DLM_CANCELGRANT */
- lksb->status = DLM_CANCELGRANT;
- status = DLM_NORMAL;
- *actions = DLM_UNLOCK_CALL_AST;
- } else {
- /* err. um. eek! */
- dlmprintk0("lock to cancel is not on any list! bug!\n");
- lksb->status = DLM_IVLOCKID;
- status = DLM_IVLOCKID;
- *actions = 0;
- }
- return status;
-}
-
-static dlm_status dlm_get_unlock_actions(dlm_ctxt *dlm, dlm_lock_resource *res,
- dlm_lock *lock, dlm_lockstatus *lksb,
- int *actions)
-{
- dlm_status status;
-
- /* unlock request */
- if (!dlm_lock_on_list(&res->granted, lock)) {
- lksb->status = DLM_DENIED;
- status = DLM_DENIED;
- *actions = 0;
- } else {
- /* unlock granted lock */
- lksb->status = DLM_NORMAL;
- status = DLM_NORMAL;
- *actions = (DLM_UNLOCK_FREE_LOCK |
- DLM_UNLOCK_CALL_AST |
- DLM_UNLOCK_REMOVE_LOCK);
- }
- return status;
-}
-
Copied: trunk/fs/ocfs2/dlm/Makefile (from rev 1818, trunk/fs/ocfs2/cluster/Makefile)
Copied: trunk/fs/ocfs2/dlm/dlm_compat.h (from rev 1818, trunk/fs/ocfs2/cluster/dlm_compat.h)
Copied: trunk/fs/ocfs2/dlm/dlmast.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmast.c)
Copied: trunk/fs/ocfs2/dlm/dlmcommon.h (from rev 1818, trunk/fs/ocfs2/cluster/dlmcommon.h)
Copied: trunk/fs/ocfs2/dlm/dlmconvert.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmconvert.c)
Copied: trunk/fs/ocfs2/dlm/dlmlock.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmlock.c)
Copied: trunk/fs/ocfs2/dlm/dlmmaster.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmmaster.c)
Copied: trunk/fs/ocfs2/dlm/dlmmod.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmmod.c)
Copied: trunk/fs/ocfs2/dlm/dlmmod.h (from rev 1818, trunk/fs/ocfs2/cluster/dlmmod.h)
Copied: trunk/fs/ocfs2/dlm/dlmrecovery.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmrecovery.c)
Copied: trunk/fs/ocfs2/dlm/dlmthread.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmthread.c)
Copied: trunk/fs/ocfs2/dlm/dlmunlock.c (from rev 1818, trunk/fs/ocfs2/cluster/dlmunlock.c)
Copied: trunk/fs/ocfs2/dlm/util.c (from rev 1818, trunk/fs/ocfs2/cluster/util.c)
Copied: trunk/fs/ocfs2/dlm/util.h (from rev 1818, trunk/fs/ocfs2/cluster/util.h)
Copied: trunk/fs/ocfs2/dlm/warning_hack.h (from rev 1818, trunk/fs/ocfs2/cluster/warning_hack.h)
More information about the Ocfs2-commits
mailing list