[Ocfs2-commits] mfasheh commits r2705 - in branches/ocfs2-1.0: . fs fs/debugfs fs/debugfs/include fs/debugfs/include/linux fs/ocfs2 fs/ocfs2/cluster kapi-compat/include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 18 15:52:20 CST 2005


Author: mfasheh
Signed-off-by: jlbec
Signed-off-by: zab
Date: 2005-11-18 15:52:17 -0600 (Fri, 18 Nov 2005)
New Revision: 2705

Added:
   branches/ocfs2-1.0/fs/debugfs/
   branches/ocfs2-1.0/fs/debugfs/Makefile
   branches/ocfs2-1.0/fs/debugfs/debugfs_compat.c
   branches/ocfs2-1.0/fs/debugfs/debugfs_compat.h
   branches/ocfs2-1.0/fs/debugfs/file.c
   branches/ocfs2-1.0/fs/debugfs/include/
   branches/ocfs2-1.0/fs/debugfs/include/linux/
   branches/ocfs2-1.0/fs/debugfs/include/linux/debugfs.h
   branches/ocfs2-1.0/fs/debugfs/inode.c
   branches/ocfs2-1.0/kapi-compat/include/kzalloc.h
Modified:
   branches/ocfs2-1.0/Config.make.in
   branches/ocfs2-1.0/configure.in
   branches/ocfs2-1.0/fs/Makefile
   branches/ocfs2-1.0/fs/ocfs2/Makefile
   branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c
   branches/ocfs2-1.0/fs/ocfs2/dlmglue.c
   branches/ocfs2-1.0/fs/ocfs2/dlmglue.h
   branches/ocfs2-1.0/fs/ocfs2/extent_map.c
   branches/ocfs2-1.0/fs/ocfs2/ocfs2.h
   branches/ocfs2-1.0/fs/ocfs2/super.c
Log:
* backport svn r2704 from ocfs2-1.2
  -Add per mount dlmglue lockres state tracking via debugfs
  -Add a debugfs backport module for vendor kernels which don't
   ship with debugfs

Signed-off-by: jlbec
Signed-off-by: zab



Modified: branches/ocfs2-1.0/Config.make.in
===================================================================
--- branches/ocfs2-1.0/Config.make.in	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/Config.make.in	2005-11-18 21:52:17 UTC (rev 2705)
@@ -56,6 +56,8 @@
 IDR_GET_NEW_RETURNS_ID = @IDR_GET_NEW_RETURNS_ID@
 INET_SK_RETURNS_INET_OPT = @INET_SK_RETURNS_INET_OPT@
 
+BUILD_DEBUGFS_BACKPORT = @BUILD_DEBUGFS_BACKPORT@
+
 OCFS_DEBUG = @OCFS_DEBUG@
 
 ifneq ($(OCFS_DEBUG),)

Modified: branches/ocfs2-1.0/configure.in
===================================================================
--- branches/ocfs2-1.0/configure.in	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/configure.in	2005-11-18 21:52:17 UTC (rev 2705)
@@ -13,7 +13,7 @@
 EXTRA_VERSION=
 
 # Adjust this only to bump the RPM packaging version
-RPM_VERSION=1
+RPM_VERSION=1.1
 
 # Required version of ocfs-tools
 TOOLS_REQUIRED_VERSION=1.0.0
@@ -211,6 +211,16 @@
 fi
 AC_SUBST(ARCH_XEN)
 
+AC_MSG_CHECKING(for debugfs)
+BUILD_DEBUGFS_BACKPORT=
+if test -f "$KERNELINC/linux/debugfs.h"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no; your build will include a backported debugfs module)
+  BUILD_DEBUGFS_BACKPORT=yes
+fi
+AC_SUBST(BUILD_DEBUGFS_BACKPORT)
+
 OCFS2_CHECK_KERNEL(generic_drop_inode, fs.h,
   have_generic_drop_inode=yes, have_generic_drop_inode=no)
 if test "x$have_generic_drop_inode" != "xyes"; then
@@ -225,6 +235,8 @@
 
 OCFS2_KERNEL_COMPAT(assert_spin_locked, spinlock.h)
 
+OCFS2_KERNEL_COMPAT(kzalloc, slab.h)
+
 OCFS2_CHECK_KERNEL([kref_init with release callback], kref.h,
   kref_compat_header="kref_put.h", kref_compat_header="kref_init.h",
   [kref_init.*release])

Modified: branches/ocfs2-1.0/fs/Makefile
===================================================================
--- branches/ocfs2-1.0/fs/Makefile	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/Makefile	2005-11-18 21:52:17 UTC (rev 2705)
@@ -18,6 +18,10 @@
 #
 SAFE_SUBDIRS := configfs ocfs2
 
+ifdef BUILD_DEBUGFS_BACKPORT
+SAFE_SUBDIRS += debugfs
+endif
+
 ifneq ($(KERNELRELEASE),)
 #
 # Called under kbuild 2.6


Property changes on: branches/ocfs2-1.0/fs/debugfs
___________________________________________________________________
Name: svn:ignore
   + cscope*
stamp-md5
.*.sw?
.*.cmd
*.ko
debugfs.mod.c
.tmp_versions
.*.d
.*.tmp


Added: branches/ocfs2-1.0/fs/debugfs/Makefile
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/Makefile	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/Makefile	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,59 @@
+
+ifeq ($(KERNELRELEASE),)
+TOPDIR = ../..
+
+include $(TOPDIR)/Preamble.make
+else
+# We are included by kbuild, and the is pre-"Kbuild"-files.
+
+OUR_TOPDIR	:= $(M)/..
+
+include $(OUR_TOPDIR)/Config.make
+
+CPPFLAGS := -I$(OUR_TOPDIR)/include $(CPPFLAGS)
+endif
+
+# Always set this if asked to build the backport module
+EXTRA_CFLAGS += -DCONFIG_DEBUG_FS
+EXTRA_CFLAGS += -I$(OUR_TOPDIR)/fs/debugfs/include
+
+INSTALL_MOD_DIR := fs/debugfs
+
+obj-m		:= debugfs.o
+debugfs-objs	:= inode.o file.o debugfs_compat.o
+
+ifeq ($(KERNELRELEASE),)
+#
+# Called from a regular "make".
+#
+DEBUGFS_HEADERS	=		\
+	debugfs.h		\
+	debugfs_compat.h
+
+DEBUGFS_SOURCES = 		\
+	file.c			\
+	inode.c			\
+	debugfs_compat.c
+
+DEBUGFS_OBJECTS = $(subst .c,.o,$(DEBUGFS_SOURCES))
+
+DIST_FILES = $(DEBUGFS_SOURCES) $(DEBUGFS_HEADERS)
+
+ALL_RULES = build-modules
+
+CLEAN_RULES = clean-modules
+
+INSTALL_RULES = install-modules
+
+build-modules:
+	$(MAKE) -C $(TOPDIR)/fs build-modules
+
+install-modules:
+	$(MAKE) -C $(TOPDIR)/fs install-modules
+
+clean-modules:
+	$(MAKE) -C $(TOPDIR)/fs clean-modules
+
+include $(TOPDIR)/Postamble.make
+
+endif

Added: branches/ocfs2-1.0/fs/debugfs/debugfs_compat.c
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/debugfs_compat.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/debugfs_compat.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,152 @@
+#include <linux/module.h>
+#include <linux/pagemap.h>
+#include <linux/mount.h>
+#include <linux/vfs.h>
+#include <asm/uaccess.h>
+
+#include "debugfs_compat.h"
+
+/*
+ * "nonseekable_open is so trivial, it's not worth putting in the kapi
+ * compat stuff just for the one use in this file.
+ * This code ripped from fs/open.c in the 2.6.14 kernel
+ */
+
+/* And of course, these FMODE_* may not be defined in older
+ * kernels. */
+#ifndef FMODE_LSEEK
+#define FMODE_LSEEK	4
+#endif
+#ifndef FMODE_PREAD
+#define FMODE_PREAD	8
+#endif
+#ifndef FMODE_PWRITE
+#define FMODE_PWRITE	FMODE_PREAD	/* These go hand in hand */
+#endif
+
+/*
+ * This is used by subsystems that don't want seekable
+ * file descriptors
+ */
+static int compat_nonseekable_open(struct inode *inode, struct file *filp)
+{
+	filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
+	return 0;
+}
+
+/* 
+ * Ripped from fs/libfs.c in the 2.6.14 kernel.
+ */
+
+ssize_t compat_simple_read_from_buffer(void __user *to, size_t count,
+				       loff_t *ppos, const void *from,
+				       size_t available)
+{
+	loff_t pos = *ppos;
+	if (pos < 0)
+		return -EINVAL;
+	if (pos >= available)
+		return 0;
+	if (count > available - pos)
+		count = available - pos;
+	if (copy_to_user(to, from + pos, count))
+		return -EFAULT;
+	*ppos = pos + count;
+	return count;
+}
+
+/* Simple attribute files */
+
+struct simple_attr {
+	u64 (*get)(void *);
+	void (*set)(void *, u64);
+	char get_buf[24];	/* enough to store a u64 and "\n\0" */
+	char set_buf[24];
+	void *data;
+	const char *fmt;	/* format for read operation */
+	struct semaphore sem;	/* protects access to these buffers */
+};
+
+/* simple_attr_open is called by an actual attribute open file operation
+ * to set the attribute specific access operations. */
+int simple_attr_open(struct inode *inode, struct file *file,
+		     u64 (*get)(void *), void (*set)(void *, u64),
+		     const char *fmt)
+{
+	struct simple_attr *attr;
+
+	attr = kmalloc(sizeof(*attr), GFP_KERNEL);
+	if (!attr)
+		return -ENOMEM;
+
+	attr->get = get;
+	attr->set = set;
+	attr->data = inode->u.generic_ip;
+	attr->fmt = fmt;
+	init_MUTEX(&attr->sem);
+
+	file->private_data = attr;
+
+	return compat_nonseekable_open(inode, file);
+}
+
+int simple_attr_close(struct inode *inode, struct file *file)
+{
+	kfree(file->private_data);
+	return 0;
+}
+
+/* read from the buffer that is filled with the get function */
+ssize_t simple_attr_read(struct file *file, char __user *buf,
+			 size_t len, loff_t *ppos)
+{
+	struct simple_attr *attr;
+	size_t size;
+	ssize_t ret;
+
+	attr = file->private_data;
+
+	if (!attr->get)
+		return -EACCES;
+
+	down(&attr->sem);
+	if (*ppos) /* continued read */
+		size = strlen(attr->get_buf);
+	else	  /* first read */
+		size = scnprintf(attr->get_buf, sizeof(attr->get_buf),
+				 attr->fmt,
+				 (unsigned long long)attr->get(attr->data));
+
+	ret = compat_simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
+	up(&attr->sem);
+	return ret;
+}
+
+/* interpret the buffer as a number to call the set function with */
+ssize_t simple_attr_write(struct file *file, const char __user *buf,
+			  size_t len, loff_t *ppos)
+{
+	struct simple_attr *attr;
+	u64 val;
+	size_t size;
+	ssize_t ret;
+
+	attr = file->private_data;
+
+	if (!attr->set)
+		return -EACCES;
+
+	down(&attr->sem);
+	ret = -EFAULT;
+	size = min(sizeof(attr->set_buf) - 1, len);
+	if (copy_from_user(attr->set_buf, buf, size))
+		goto out;
+
+	ret = len; /* claim we got the whole input */
+	attr->set_buf[size] = '\0';
+	val = simple_strtol(attr->set_buf, NULL, 0);
+	attr->set(attr->data, val);
+out:
+	up(&attr->sem);
+	return ret;
+}

Added: branches/ocfs2-1.0/fs/debugfs/debugfs_compat.h
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/debugfs_compat.h	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/debugfs_compat.h	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,55 @@
+/* Ripped from include/linux/fs.h in the 2.6.14 kernel. */
+
+#ifndef _DEBUGFS_COMPAT_H
+#define _DEBUGFS_COMPAT_H
+
+/*
+ * simple attribute files
+ *
+ * These attributes behave similar to those in sysfs:
+ *
+ * Writing to an attribute immediately sets a value, an open file can be
+ * written to multiple times.
+ *
+ * Reading from an attribute creates a buffer from the value that might get
+ * read with multiple read calls. When the attribute has been read
+ * completely, no further read calls are possible until the file is opened
+ * again.
+ *
+ * All attributes contain a text representation of a numeric value
+ * that are accessed with the get() and set() functions.
+ */
+#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)		\
+static int __fops ## _open(struct inode *inode, struct file *file)	\
+{									\
+	__simple_attr_check_format(__fmt, 0ull);			\
+	return simple_attr_open(inode, file, __get, __set, __fmt);	\
+}									\
+static struct file_operations __fops = {				\
+	.owner	 = THIS_MODULE,						\
+	.open	 = __fops ## _open,					\
+	.release = simple_attr_close,					\
+	.read	 = simple_attr_read,					\
+	.write	 = simple_attr_write,					\
+};
+
+static inline void __attribute__((format(printf, 1, 2)))
+__simple_attr_check_format(const char *fmt, ...)
+{
+	/* don't do anything, just let the compiler check the arguments; */
+}
+
+int simple_attr_open(struct inode *inode, struct file *file,
+		     u64 (*get)(void *), void (*set)(void *, u64),
+		     const char *fmt);
+int simple_attr_close(struct inode *inode, struct file *file);
+ssize_t simple_attr_read(struct file *file, char __user *buf,
+			 size_t len, loff_t *ppos);
+ssize_t simple_attr_write(struct file *file, const char __user *buf,
+			  size_t len, loff_t *ppos);
+
+ssize_t compat_simple_read_from_buffer(void __user *to, size_t count,
+				       loff_t *ppos, const void *from,
+				       size_t available);
+
+#endif /* _DEBUGFS_COMPAT_H */

Added: branches/ocfs2-1.0/fs/debugfs/file.c
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/file.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/file.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,255 @@
+/*
+ *  file.c - part of debugfs, a tiny little debug file system
+ *
+ *  Copyright (C) 2004 Greg Kroah-Hartman <greg at kroah.com>
+ *  Copyright (C) 2004 IBM Inc.
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License version
+ *	2 as published by the Free Software Foundation.
+ *
+ *  debugfs is for people to use instead of /proc or /sys.
+ *  See Documentation/DocBook/kernel-api for more details.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/pagemap.h>
+#include <linux/debugfs.h>
+
+#include "debugfs_compat.h"
+
+static ssize_t default_read_file(struct file *file, char __user *buf,
+				 size_t count, loff_t *ppos)
+{
+	return 0;
+}
+
+static ssize_t default_write_file(struct file *file, const char __user *buf,
+				   size_t count, loff_t *ppos)
+{
+	return count;
+}
+
+static int default_open(struct inode *inode, struct file *file)
+{
+	if (inode->u.generic_ip)
+		file->private_data = inode->u.generic_ip;
+
+	return 0;
+}
+
+struct file_operations debugfs_file_operations = {
+	.read =		default_read_file,
+	.write =	default_write_file,
+	.open =		default_open,
+};
+
+static void debugfs_u8_set(void *data, u64 val)
+{
+	*(u8 *)data = val;
+}
+static u64 debugfs_u8_get(void *data)
+{
+	return *(u8 *)data;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
+
+/**
+ * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
+ *
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ *         from.
+ *
+ * This function creates a file in debugfs with the given name that
+ * contains the value of the variable @value.  If the @mode variable is so
+ * set, it can be read from, and written to.
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_u8(const char *name, mode_t mode,
+				 struct dentry *parent, u8 *value)
+{
+	return debugfs_create_file(name, mode, parent, value, &fops_u8);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_u8);
+
+static void debugfs_u16_set(void *data, u64 val)
+{
+	*(u16 *)data = val;
+}
+static u64 debugfs_u16_get(void *data)
+{
+	return *(u16 *)data;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
+
+/**
+ * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
+ *
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ *         from.
+ *
+ * This function creates a file in debugfs with the given name that
+ * contains the value of the variable @value.  If the @mode variable is so
+ * set, it can be read from, and written to.
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_u16(const char *name, mode_t mode,
+				  struct dentry *parent, u16 *value)
+{
+	return debugfs_create_file(name, mode, parent, value, &fops_u16);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_u16);
+
+static void debugfs_u32_set(void *data, u64 val)
+{
+	*(u32 *)data = val;
+}
+static u64 debugfs_u32_get(void *data)
+{
+	return *(u32 *)data;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
+
+/**
+ * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
+ *
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ *         from.
+ *
+ * This function creates a file in debugfs with the given name that
+ * contains the value of the variable @value.  If the @mode variable is so
+ * set, it can be read from, and written to.
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_u32(const char *name, mode_t mode,
+				 struct dentry *parent, u32 *value)
+{
+	return debugfs_create_file(name, mode, parent, value, &fops_u32);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_u32);
+
+static ssize_t read_file_bool(struct file *file, char __user *user_buf,
+			      size_t count, loff_t *ppos)
+{
+	char buf[3];
+	u32 *val = file->private_data;
+	
+	if (*val)
+		buf[0] = 'Y';
+	else
+		buf[0] = 'N';
+	buf[1] = '\n';
+	buf[2] = 0x00;
+	return compat_simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static ssize_t write_file_bool(struct file *file, const char __user *user_buf,
+			       size_t count, loff_t *ppos)
+{
+	char buf[32];
+	int buf_size;
+	u32 *val = file->private_data;
+
+	buf_size = min(count, (sizeof(buf)-1));
+	if (copy_from_user(buf, user_buf, buf_size))
+		return -EFAULT;
+
+	switch (buf[0]) {
+	case 'y':
+	case 'Y':
+	case '1':
+		*val = 1;
+		break;
+	case 'n':
+	case 'N':
+	case '0':
+		*val = 0;
+		break;
+	}
+	
+	return count;
+}
+
+static struct file_operations fops_bool = {
+	.read =		read_file_bool,
+	.write =	write_file_bool,
+	.open =		default_open,
+};
+
+/**
+ * debugfs_create_bool - create a file in the debugfs filesystem that is used to read and write a boolean value.
+ *
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ *         from.
+ *
+ * This function creates a file in debugfs with the given name that
+ * contains the value of the variable @value.  If the @mode variable is so
+ * set, it can be read from, and written to.
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_bool(const char *name, mode_t mode,
+				   struct dentry *parent, u32 *value)
+{
+	return debugfs_create_file(name, mode, parent, value, &fops_bool);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_bool);
+

Added: branches/ocfs2-1.0/fs/debugfs/include/linux/debugfs.h
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/include/linux/debugfs.h	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/include/linux/debugfs.h	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,99 @@
+/*
+ *  debugfs.h - a tiny little debug file system
+ *
+ *  Copyright (C) 2004 Greg Kroah-Hartman <greg at kroah.com>
+ *  Copyright (C) 2004 IBM Inc.
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License version
+ *	2 as published by the Free Software Foundation.
+ *
+ *  debugfs is for people to use instead of /proc or /sys.
+ *  See Documentation/DocBook/kernel-api for more details.
+ */
+
+#ifndef _DEBUGFS_H_
+#define _DEBUGFS_H_
+
+#include <linux/fs.h>
+
+#include <linux/types.h>
+
+struct file_operations;
+
+#if defined(CONFIG_DEBUG_FS)
+struct dentry *debugfs_create_file(const char *name, mode_t mode,
+				   struct dentry *parent, void *data,
+				   struct file_operations *fops);
+
+struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
+
+void debugfs_remove(struct dentry *dentry);
+
+struct dentry *debugfs_create_u8(const char *name, mode_t mode,
+				 struct dentry *parent, u8 *value);
+struct dentry *debugfs_create_u16(const char *name, mode_t mode,
+				  struct dentry *parent, u16 *value);
+struct dentry *debugfs_create_u32(const char *name, mode_t mode,
+				  struct dentry *parent, u32 *value);
+struct dentry *debugfs_create_bool(const char *name, mode_t mode,
+				  struct dentry *parent, u32 *value);
+
+#else
+
+#include <linux/err.h>
+
+/* 
+ * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
+ * so users have a chance to detect if there was a real error or not.  We don't
+ * want to duplicate the design decision mistakes of procfs and devfs again.
+ */
+
+static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
+						 struct dentry *parent,
+						 void *data,
+						 struct file_operations *fops)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct dentry *debugfs_create_dir(const char *name,
+						struct dentry *parent)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline void debugfs_remove(struct dentry *dentry)
+{ }
+
+static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
+					       struct dentry *parent,
+					       u8 *value)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
+						struct dentry *parent,
+						u16 *value)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
+						struct dentry *parent,
+						u32 *value)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
+						 struct dentry *parent,
+						 u32 *value)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+#endif
+
+#endif

Added: branches/ocfs2-1.0/fs/debugfs/inode.c
===================================================================
--- branches/ocfs2-1.0/fs/debugfs/inode.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/debugfs/inode.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,308 @@
+/*
+ *  file.c - part of debugfs, a tiny little debug file system
+ *
+ *  Copyright (C) 2004 Greg Kroah-Hartman <greg at kroah.com>
+ *  Copyright (C) 2004 IBM Inc.
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License version
+ *	2 as published by the Free Software Foundation.
+ *
+ *  debugfs is for people to use instead of /proc or /sys.
+ *  See Documentation/DocBook/kernel-api for more details.
+ *
+ */
+
+/* uncomment to get debug messages from the debug filesystem, ah the irony. */
+/* #define DEBUG */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/mount.h>
+#include <linux/pagemap.h>
+#include <linux/init.h>
+#include <linux/namei.h>
+#include <linux/debugfs.h>
+
+#define DEBUGFS_MAGIC	0x64626720
+
+/* declared over in file.c */
+extern struct file_operations debugfs_file_operations;
+
+static struct vfsmount *debugfs_mount;
+static int debugfs_mount_count;
+
+static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev)
+{
+	struct inode *inode = new_inode(sb);
+
+	if (inode) {
+		inode->i_mode = mode;
+		inode->i_uid = 0;
+		inode->i_gid = 0;
+		inode->i_blksize = PAGE_CACHE_SIZE;
+		inode->i_blocks = 0;
+		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+		switch (mode & S_IFMT) {
+		default:
+			init_special_inode(inode, mode, dev);
+			break;
+		case S_IFREG:
+			inode->i_fop = &debugfs_file_operations;
+			break;
+		case S_IFDIR:
+			inode->i_op = &simple_dir_inode_operations;
+			inode->i_fop = &simple_dir_operations;
+
+			/* directory inodes start off with i_nlink == 2 (for "." entry) */
+			inode->i_nlink++;
+			break;
+		}
+	}
+	return inode; 
+}
+
+/* SMP-safe */
+static int debugfs_mknod(struct inode *dir, struct dentry *dentry,
+			 int mode, dev_t dev)
+{
+	struct inode *inode = debugfs_get_inode(dir->i_sb, mode, dev);
+	int error = -EPERM;
+
+	if (dentry->d_inode)
+		return -EEXIST;
+
+	if (inode) {
+		d_instantiate(dentry, inode);
+		dget(dentry);
+		error = 0;
+	}
+	return error;
+}
+
+static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+	int res;
+
+	mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
+	res = debugfs_mknod(dir, dentry, mode, 0);
+	if (!res)
+		dir->i_nlink++;
+	return res;
+}
+
+static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode)
+{
+	mode = (mode & S_IALLUGO) | S_IFREG;
+	return debugfs_mknod(dir, dentry, mode, 0);
+}
+
+static inline int debugfs_positive(struct dentry *dentry)
+{
+	return dentry->d_inode && !d_unhashed(dentry);
+}
+
+static int debug_fill_super(struct super_block *sb, void *data, int silent)
+{
+	static struct tree_descr debug_files[] = {{""}};
+
+	return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
+}
+
+static struct super_block *debug_get_sb(struct file_system_type *fs_type,
+				        int flags, const char *dev_name,
+					void *data)
+{
+	return get_sb_single(fs_type, flags, data, debug_fill_super);
+}
+
+static struct file_system_type debug_fs_type = {
+	.owner =	THIS_MODULE,
+	.name =		"debugfs",
+	.get_sb =	debug_get_sb,
+	.kill_sb =	kill_litter_super,
+};
+
+static int debugfs_create_by_name(const char *name, mode_t mode,
+				  struct dentry *parent,
+				  struct dentry **dentry)
+{
+	int error = 0;
+
+	/* If the parent is not specified, we create it in the root.
+	 * We need the root dentry to do this, which is in the super 
+	 * block. A pointer to that is in the struct vfsmount that we
+	 * have around.
+	 */
+	if (!parent ) {
+		if (debugfs_mount && debugfs_mount->mnt_sb) {
+			parent = debugfs_mount->mnt_sb->s_root;
+		}
+	}
+	if (!parent) {
+		pr_debug("debugfs: Ah! can not find a parent!\n");
+		return -EFAULT;
+	}
+
+	*dentry = NULL;
+	down(&parent->d_inode->i_sem);
+	*dentry = lookup_one_len(name, parent, strlen(name));
+	if (!IS_ERR(dentry)) {
+		if ((mode & S_IFMT) == S_IFDIR)
+			error = debugfs_mkdir(parent->d_inode, *dentry, mode);
+		else 
+			error = debugfs_create(parent->d_inode, *dentry, mode);
+	} else
+		error = PTR_ERR(dentry);
+	up(&parent->d_inode->i_sem);
+
+	return error;
+}
+
+/**
+ * debugfs_create_file - create a file in the debugfs filesystem
+ *
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @data: a pointer to something that the caller will want to get to later
+ *        on.  The inode.u.generic_ip pointer will point to this value on
+ *        the open() call.
+ * @fops: a pointer to a struct file_operations that should be used for
+ *        this file.
+ *
+ * This is the basic "create a file" function for debugfs.  It allows for a
+ * wide range of flexibility in createing a file, or a directory (if you
+ * want to create a directory, the debugfs_create_dir() function is
+ * recommended to be used instead.)
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_file(const char *name, mode_t mode,
+				   struct dentry *parent, void *data,
+				   struct file_operations *fops)
+{
+	struct dentry *dentry = NULL;
+	int error;
+
+	pr_debug("debugfs: creating file '%s'\n",name);
+
+	error = simple_pin_fs("debugfs", &debugfs_mount, &debugfs_mount_count);
+	if (error)
+		goto exit;
+
+	error = debugfs_create_by_name(name, mode, parent, &dentry);
+	if (error) {
+		dentry = NULL;
+		goto exit;
+	}
+
+	if (dentry->d_inode) {
+		if (data)
+			dentry->d_inode->u.generic_ip = data;
+		if (fops)
+			dentry->d_inode->i_fop = fops;
+	}
+exit:
+	return dentry;
+}
+EXPORT_SYMBOL_GPL(debugfs_create_file);
+
+/**
+ * debugfs_create_dir - create a directory in the debugfs filesystem
+ *
+ * @name: a pointer to a string containing the name of the directory to
+ *        create.
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this paramater is NULL, then the
+ *          directory will be created in the root of the debugfs filesystem.
+ *
+ * This function creates a directory in debugfs with the given name.
+ *
+ * This function will return a pointer to a dentry if it succeeds.  This
+ * pointer must be passed to the debugfs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.)  If an error occurs, NULL will be returned.
+ *
+ * If debugfs is not enabled in the kernel, the value -ENODEV will be
+ * returned.  It is not wise to check for this value, but rather, check for
+ * NULL or !NULL instead as to eliminate the need for #ifdef in the calling
+ * code.
+ */
+struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
+{
+	return debugfs_create_file(name, 
+				   S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
+				   parent, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_dir);
+
+/**
+ * debugfs_remove - removes a file or directory from the debugfs filesystem
+ *
+ * @dentry: a pointer to a the dentry of the file or directory to be
+ *          removed.
+ *
+ * This function removes a file or directory in debugfs that was previously
+ * created with a call to another debugfs function (like
+ * debufs_create_file() or variants thereof.)
+ *
+ * This function is required to be called in order for the file to be
+ * removed, no automatic cleanup of files will happen when a module is
+ * removed, you are responsible here.
+ */
+void debugfs_remove(struct dentry *dentry)
+{
+	struct dentry *parent;
+	
+	if (!dentry)
+		return;
+
+	parent = dentry->d_parent;
+	if (!parent || !parent->d_inode)
+		return;
+
+	down(&parent->d_inode->i_sem);
+	if (debugfs_positive(dentry)) {
+		if (dentry->d_inode) {
+			if (S_ISDIR(dentry->d_inode->i_mode))
+				simple_rmdir(parent->d_inode, dentry);
+			else
+				simple_unlink(parent->d_inode, dentry);
+		dput(dentry);
+		}
+	}
+	up(&parent->d_inode->i_sem);
+	simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+}
+EXPORT_SYMBOL_GPL(debugfs_remove);
+
+static int __init debugfs_init(void)
+{
+	int retval;
+
+	retval = register_filesystem(&debug_fs_type);
+	return retval;
+}
+
+static void __exit debugfs_exit(void)
+{
+	simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+	unregister_filesystem(&debug_fs_type);
+}
+
+core_initcall(debugfs_init);
+module_exit(debugfs_exit);
+MODULE_LICENSE("GPL");
+

Modified: branches/ocfs2-1.0/fs/ocfs2/Makefile
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/Makefile	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/Makefile	2005-11-18 21:52:17 UTC (rev 2705)
@@ -26,6 +26,11 @@
 EXTRA_CFLAGS += -DJOURNAL_ACCESS_WITH_CREDITS
 endif
 
+ifdef BUILD_DEBUGFS_BACKPORT
+EXTRA_CFLAGS += -DCONFIG_DEBUG_FS
+EXTRA_CFLAGS += -I$(OUR_TOPDIR)/fs/debugfs/include
+endif
+
 EXTRA_CFLAGS += -DOCFS2_DELETE_INODE_WORKAROUND
 
 #

Modified: branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/cluster/heartbeat.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -104,6 +104,12 @@
 	struct list_head	ds_live_item;
 };
 
+struct o2hb_track_blocker {
+	const char	*tb_why;
+	struct timeval	tb_start;
+	struct timeval	tb_end;
+};
+
 /* each thread owns a region.. when we're asked to tear down the region
  * we ask the thread to stop, who cleans up the region */
 struct o2hb_region {
@@ -148,13 +154,111 @@
 	 * being checked because we temporarily have to zero out the
 	 * crc field. */
 	struct o2hb_disk_heartbeat_block *hr_tmp_block;
+
+	unsigned int hr_curr_blocker;
+#define O2HB_NUM_BLOCKER_TRACKS 24
+	struct o2hb_track_blocker hb_blocker[O2HB_NUM_BLOCKER_TRACKS];
 };
 
+static spinlock_t o2hb_blocker_lock = SPIN_LOCK_UNLOCKED;
+
 struct o2hb_bio_wait_ctxt {
 	atomic_t          wc_num_reqs;
 	struct completion wc_io_complete;
 };
 
+static unsigned int o2hb_elapsed_msecs(struct timeval *start,
+				       struct timeval *end);
+
+static void o2hb_print_one_blocker(unsigned int index,
+				   struct o2hb_track_blocker *blocker)
+{
+	unsigned int elapsed_ms;
+
+	/* this will not have been initialized if we never used that
+	 * blocker */
+	if (!blocker->tb_why)
+		return;
+
+	elapsed_ms = o2hb_elapsed_msecs(&blocker->tb_start, &blocker->tb_end);
+
+	printk(KERN_EMERG "Index %u: took %u ms to do %s\n",
+	       index, elapsed_ms, blocker->tb_why);
+}
+
+static void o2hb_print_blockers(struct o2hb_region *reg)
+{
+	unsigned int i;
+	unsigned int cur;
+	struct o2hb_track_blocker *blocker;
+
+	spin_lock(&o2hb_blocker_lock);
+
+	cur = reg->hr_curr_blocker;
+	printk(KERN_EMERG "Heartbaet thread (%d) printing last %u blocking "
+	       "operations (cur = %u):\n", current->pid,
+	       O2HB_NUM_BLOCKER_TRACKS, cur);
+
+	blocker = &reg->hb_blocker[cur];
+	if (blocker->tb_end.tv_sec == 0) {
+		printk(KERN_EMERG "Heartbeat thread stuck at %s, stuffing "
+		       "current time into that blocker (index %u)\n",
+		       blocker->tb_why, cur);
+		do_gettimeofday(&blocker->tb_end);
+	}
+
+	for(i = (cur + 1); i < O2HB_NUM_BLOCKER_TRACKS; i++)
+		o2hb_print_one_blocker(i, &reg->hb_blocker[i]);
+
+	for(i = 0; i <= cur; i++)
+		o2hb_print_one_blocker(i, &reg->hb_blocker[i]);
+
+	spin_unlock(&o2hb_blocker_lock);
+}
+
+static void o2hb_mlog_blocking(struct o2hb_region *reg,
+			       struct timeval *start,
+			       const char *msg)
+{
+	struct o2hb_track_blocker *blocker = &reg->hb_blocker[reg->hr_curr_blocker];
+
+	spin_lock(&o2hb_blocker_lock);
+
+	mlog(ML_HEARTBEAT, "reg %.*s|%llu: thread %s cur %u\n",
+	     BDEVNAME_SIZE, reg->hr_dev_name, reg->hr_start_block, msg,
+	     reg->hr_curr_blocker);
+	do_gettimeofday(start);
+
+	blocker->tb_why = msg;
+	blocker->tb_start = *start;
+	/* helps us track the completion of this thread */
+	memset(&blocker->tb_end, 0, sizeof(blocker->tb_end));
+	spin_unlock(&o2hb_blocker_lock);
+}
+
+static void o2hb_mlog_blocking_done(struct o2hb_region *reg,
+				    struct timeval *start)
+{
+	struct timeval end;
+	unsigned int elapsed_ms;
+	struct o2hb_track_blocker *blocker = &reg->hb_blocker[reg->hr_curr_blocker];
+
+	spin_lock(&o2hb_blocker_lock);
+
+	do_gettimeofday(&end);
+	elapsed_ms = o2hb_elapsed_msecs(start, &end);
+
+	mlog(ML_HEARTBEAT, "reg %.*s|%llu done after %d ms cur %u\n",
+	     BDEVNAME_SIZE, reg->hr_dev_name, reg->hr_start_block, elapsed_ms,
+	     reg->hr_curr_blocker);
+
+	blocker->tb_end = end;
+	reg->hr_curr_blocker++;
+	if (reg->hr_curr_blocker >= O2HB_NUM_BLOCKER_TRACKS)
+		reg->hr_curr_blocker = 0;
+	spin_unlock(&o2hb_blocker_lock);
+}
+
 static void o2hb_write_timeout(void *arg)
 {
 	struct o2hb_region *reg = arg;
@@ -162,6 +266,9 @@
 	mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u "
 	     "milliseconds\n", reg->hr_dev_name,
 	     jiffies_to_msecs(jiffies - reg->hr_last_timeout_start)); 
+
+	o2hb_print_blockers(reg);
+
 	o2quo_disk_timeout();
 }
 
@@ -233,7 +340,8 @@
 static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
 				      struct o2hb_bio_wait_ctxt *wc,
 				      unsigned int start_slot,
-				      unsigned int num_slots)
+				      unsigned int num_slots,
+				      int write)
 {
 	int i, nr_vecs, len, first_page, last_page;
 	unsigned int vec_len, vec_start;
@@ -241,14 +349,20 @@
 	unsigned int spp = reg->hr_slots_per_page;
 	struct bio *bio;
 	struct page *page;
+	struct timeval start;
 
 	nr_vecs = (num_slots + spp - 1) / spp;
 
+	if (write)
+		o2hb_mlog_blocking(reg, &start, "bio alloc write");
+	else
+		o2hb_mlog_blocking(reg, &start, "bio alloc read");
 	/* Testing has shown this allocation to take long enough under
 	 * GFP_KERNEL that the local node can get fenced. It would be
 	 * nicest if we could pre-allocate these bios and avoid this
 	 * all together. */
 	bio = bio_alloc(GFP_ATOMIC, nr_vecs);
+	o2hb_mlog_blocking_done(reg, &start);
 	if (!bio) {
 		mlog(ML_ERROR, "Could not alloc slots BIO!\n");
 		bio = ERR_PTR(-ENOMEM);
@@ -276,7 +390,12 @@
 		mlog(ML_HB_BIO, "page %d, vec_len = %u, vec_start = %u\n",
 		     i, vec_len, vec_start);
 
+		if (write)
+			o2hb_mlog_blocking(reg, &start, "bio add page write");
+		else
+			o2hb_mlog_blocking(reg, &start, "bio add page read");
 		len = bio_add_page(bio, page, vec_len, vec_start);
+		o2hb_mlog_blocking_done(reg, &start);
 		if (len != vec_len) {
 			bio_put(bio);
 			bio = ERR_PTR(-EIO);
@@ -353,10 +472,13 @@
 	struct o2hb_bio_wait_ctxt wc;
 	struct bio **bios;
 	struct bio *bio;
+	struct timeval start;
 
 	o2hb_compute_request_limits(reg, max_slots, &num_bios, &slots_per_bio);
 
+	o2hb_mlog_blocking(reg, &start, "allocating bios for read");
 	bios = kcalloc(num_bios, sizeof(struct bio *), GFP_KERNEL);
+	o2hb_mlog_blocking_done(reg, &start);
 	if (!bios) {
 		status = -ENOMEM;
 		mlog_errno(status);
@@ -373,7 +495,7 @@
 		if (max_slots < (start_slot + num_slots))
 			num_slots = max_slots - start_slot;
 
-		bio = o2hb_setup_one_bio(reg, &wc, start_slot, num_slots);
+		bio = o2hb_setup_one_bio(reg, &wc, start_slot, num_slots, 0);
 		if (IS_ERR(bio)) {
 			o2hb_bio_wait_dec(&wc, num_bios - i);
 
@@ -383,13 +505,17 @@
 		}
 		bios[i] = bio;
 
+		o2hb_mlog_blocking(reg, &start, "submit_bio for read");
 		submit_bio(READ, bio);
+		o2hb_mlog_blocking_done(reg, &start);
 	}
 
 	status = 0;
 
 bail_and_wait:
+	o2hb_mlog_blocking(reg, &start, "waiting for read completion");
 	o2hb_wait_on_io(reg, &wc);
+	o2hb_mlog_blocking_done(reg, &start);
 
 	if (bios) {
 		for(i = 0; i < num_bios; i++)
@@ -408,19 +534,22 @@
 	int status;
 	unsigned int slot;
 	struct bio *bio;
+	struct timeval start;
 
 	o2hb_bio_wait_init(write_wc, 1);
 
 	slot = o2nm_this_node();
 
-	bio = o2hb_setup_one_bio(reg, write_wc, slot, 1);
+	bio = o2hb_setup_one_bio(reg, write_wc, slot, 1, 1);
 	if (IS_ERR(bio)) {
 		status = PTR_ERR(bio);
 		mlog_errno(status);
 		goto bail;
 	}
 
+	o2hb_mlog_blocking(reg, &start, "submit_bio for write");
 	submit_bio(WRITE, bio);
+	o2hb_mlog_blocking_done(reg, &start);
 
 	*write_bio = bio;
 	status = 0;
@@ -791,13 +920,17 @@
 	unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)];
 	struct bio *write_bio;
 	struct o2hb_bio_wait_ctxt write_wc;
+	struct timeval start;
 
-	if (o2nm_configured_node_map(configured_nodes, sizeof(configured_nodes)))
+	ret = o2nm_configured_node_map(configured_nodes, sizeof(configured_nodes));
+	if (ret) {
+		mlog_errno(ret);
 		return;
+	}
 
 	highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES);
 	if (highest_node >= O2NM_MAX_NODES) {
-		mlog(ML_NOTICE, "ocfs2_heartbeat: no configured nodes found!\n");
+		mlog(ML_ERROR, "ocfs2_heartbeat: no configured nodes found!\n");
 		return;
 	}
 
@@ -829,18 +962,22 @@
 		return;
 	}
 
+	o2hb_mlog_blocking(reg, &start, "checking slots");
 	i = -1;
 	while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) {
 
 		change |= o2hb_check_slot(reg, &reg->hr_slots[i]);
 	}
+	o2hb_mlog_blocking_done(reg, &start);
 
 	/*
 	 * We have to be sure we've advertised ourselves on disk
 	 * before we can go to steady state.  This ensures that
 	 * people we find in our steady state have seen us.
 	 */
+	o2hb_mlog_blocking(reg, &start, "waiting for write completion");
 	o2hb_wait_on_io(reg, &write_wc);
+	o2hb_mlog_blocking_done(reg, &start);
 	bio_put(write_bio);
 	o2hb_arm_write_timeout(reg);
 
@@ -896,7 +1033,8 @@
 	struct timeval before_hb, after_hb;
 	unsigned int elapsed_msec;
 
-	mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running\n");
+	mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running, "
+	     "timeout = %u ms\n", O2HB_MAX_WRITE_TIMEOUT_MS);
 
 	set_user_nice(current, -20);
 
@@ -918,9 +1056,12 @@
 		     after_hb.tv_sec, after_hb.tv_usec, elapsed_msec);
 
 		if (elapsed_msec < reg->hr_timeout_ms) {
+			struct timeval start;
 			/* the kthread api has blocked signals for us so no
 			 * need to record the return value. */
+			o2hb_mlog_blocking(reg, &start, "msleep");
 			msleep_interruptible(reg->hr_timeout_ms - elapsed_msec);
+			o2hb_mlog_blocking_done(reg, &start);
 		}
 	}
 

Modified: branches/ocfs2-1.0/fs/ocfs2/dlmglue.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlmglue.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/dlmglue.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -30,6 +30,8 @@
 #include <linux/smp_lock.h>
 #include <linux/crc32.h>
 #include <linux/kthread.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 
 #include <cluster/heartbeat.h>
 #include <cluster/nodemanager.h>
@@ -216,7 +218,28 @@
 	mlog_exit_void();
 }
 
-static void ocfs2_lock_res_init_common(struct ocfs2_lock_res *res,
+static spinlock_t ocfs2_dlm_tracking_lock = SPIN_LOCK_UNLOCKED;
+
+static void ocfs2_add_lockres_tracking(struct ocfs2_lock_res *res,
+				       struct ocfs2_dlm_debug *dlm_debug)
+{
+	mlog(0, "Add tracking for lockres %s\n", res->l_name);
+
+	spin_lock(&ocfs2_dlm_tracking_lock);
+	list_add(&res->l_debug_list, &dlm_debug->d_lockres_tracking);
+	spin_unlock(&ocfs2_dlm_tracking_lock);
+}
+
+static void ocfs2_remove_lockres_tracking(struct ocfs2_lock_res *res)
+{
+	spin_lock(&ocfs2_dlm_tracking_lock);
+	if (!list_empty(&res->l_debug_list))
+		list_del_init(&res->l_debug_list);
+	spin_unlock(&ocfs2_dlm_tracking_lock);
+}
+
+static void ocfs2_lock_res_init_common(ocfs2_super *osb,
+				       struct ocfs2_lock_res *res,
 				       enum ocfs2_lock_type type,
 				       u64 blkno,
 				       u32 generation,
@@ -236,6 +259,8 @@
 	res->l_unlock_action = OCFS2_UNLOCK_INVALID;
 
 	res->l_flags         = OCFS2_LOCK_INITIALIZED;
+
+	ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug);
 }
 
 void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res)
@@ -262,7 +287,8 @@
 	else
 		ops = &ocfs2_inode_data_lops;
 
-	ocfs2_lock_res_init_common(res, type, OCFS2_I(inode)->ip_blkno,
+	ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), res, type,
+				   OCFS2_I(inode)->ip_blkno,
 				   inode->i_generation, ops, inode);
 }
 
@@ -272,7 +298,7 @@
 	/* Superblock lockres doesn't come from a slab so we call init
 	 * once on it manually.  */
 	ocfs2_lock_res_init_once(res);
-	ocfs2_lock_res_init_common(res, OCFS2_LOCK_TYPE_SUPER,
+	ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_SUPER,
 				   OCFS2_SUPER_BLOCK_BLKNO, 0,
 				   &ocfs2_super_lops, osb);
 }
@@ -283,7 +309,7 @@
 	/* Rename lockres doesn't come from a slab so we call init
 	 * once on it manually.  */
 	ocfs2_lock_res_init_once(res);
-	ocfs2_lock_res_init_common(res, OCFS2_LOCK_TYPE_RENAME, 0, 0,
+	ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_RENAME, 0, 0,
 				   &ocfs2_rename_lops, osb);
 }
 
@@ -294,6 +320,8 @@
 	if (!(res->l_flags & OCFS2_LOCK_INITIALIZED))
 		return;
 
+	ocfs2_remove_lockres_tracking(res);
+
 	mlog_bug_on_msg(!list_empty(&res->l_blocked_list),
 			"Lockres %s is on the blocked list\n",
 			res->l_name);
@@ -1650,6 +1678,259 @@
 	ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE);
 }
 
+/* Reference counting of the dlm debug structure. We want this because
+ * open references on the debug inodes can live on after a mount, so
+ * we can't rely on the ocfs2_super to always exist. */
+static void ocfs2_dlm_debug_free(struct kref *kref)
+{
+	struct ocfs2_dlm_debug *dlm_debug;
+
+	dlm_debug = container_of(kref, struct ocfs2_dlm_debug, d_refcnt);
+
+	kfree(dlm_debug);
+}
+
+void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug)
+{
+	if (dlm_debug)
+		kref_put(&dlm_debug->d_refcnt, ocfs2_dlm_debug_free);
+}
+
+static void ocfs2_get_dlm_debug(struct ocfs2_dlm_debug *debug)
+{
+	kref_get(&debug->d_refcnt);
+}
+
+struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void)
+{
+	struct ocfs2_dlm_debug *dlm_debug;
+
+	dlm_debug = kmalloc(sizeof(struct ocfs2_dlm_debug), GFP_KERNEL);
+	if (!dlm_debug) {
+		mlog_errno(-ENOMEM);
+		goto out;
+	}
+
+	kref_init(&dlm_debug->d_refcnt, ocfs2_dlm_debug_free);
+	INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking);
+	dlm_debug->d_locking_state = NULL;
+out:
+	return dlm_debug;
+}
+
+/* Access to this is arbitrated for us via seq_file->sem. */
+struct ocfs2_dlm_seq_priv {
+	struct ocfs2_dlm_debug *p_dlm_debug;
+	struct ocfs2_lock_res p_iter_res;
+	struct ocfs2_lock_res p_tmp_res;
+};
+
+static struct ocfs2_lock_res *ocfs2_dlm_next_res(struct ocfs2_lock_res *start,
+						 struct ocfs2_dlm_seq_priv *priv)
+{
+	struct ocfs2_lock_res *iter, *ret = NULL;
+	struct ocfs2_dlm_debug *dlm_debug = priv->p_dlm_debug;
+
+	assert_spin_locked(&ocfs2_dlm_tracking_lock);
+
+	list_for_each_entry(iter, &start->l_debug_list, l_debug_list) {
+		/* discover the head of the list */
+		if (&iter->l_debug_list == &dlm_debug->d_lockres_tracking) {
+			mlog(0, "End of list found, %p\n", ret);
+			break;
+		}
+
+		/* We track our "dummy" iteration lockres' by a NULL
+		 * l_ops field. */
+		if (iter->l_ops != NULL) {
+			ret = iter;
+			break;
+		}
+	}
+
+	return ret;
+}
+
+static void *ocfs2_dlm_seq_start(struct seq_file *m, loff_t *pos)
+{
+	struct ocfs2_dlm_seq_priv *priv = m->private;
+	struct ocfs2_lock_res *iter;
+
+	spin_lock(&ocfs2_dlm_tracking_lock);
+	iter = ocfs2_dlm_next_res(&priv->p_iter_res, priv);
+	if (iter) {
+		/* Since lockres' have the lifetime of their container
+		 * (which can be inodes, ocfs2_supers, etc) we want to
+		 * copy this out to a temporary lockres while still
+		 * under the spinlock. Obviously after this we can't
+		 * trust any pointers on the copy returned, but that's
+		 * ok as the information we want isn't typically held
+		 * in them. */
+		priv->p_tmp_res = *iter;
+		iter = &priv->p_tmp_res;
+	}
+	spin_unlock(&ocfs2_dlm_tracking_lock);
+
+	return iter;
+}
+
+static void ocfs2_dlm_seq_stop(struct seq_file *m, void *v)
+{
+}
+
+static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
+{
+	struct ocfs2_dlm_seq_priv *priv = m->private;
+	struct ocfs2_lock_res *iter = v;
+	struct ocfs2_lock_res *dummy = &priv->p_iter_res;
+
+	spin_lock(&ocfs2_dlm_tracking_lock);
+	iter = ocfs2_dlm_next_res(iter, priv);
+	list_del_init(&dummy->l_debug_list);
+	if (iter) {
+		list_add(&dummy->l_debug_list, &iter->l_debug_list);
+		priv->p_tmp_res = *iter;
+		iter = &priv->p_tmp_res;
+	}
+	spin_unlock(&ocfs2_dlm_tracking_lock);
+
+	return iter;
+}
+
+/* So that debugfs.ocfs2 can determine which format is being used */
+#define OCFS2_DLM_DEBUG_STR_VERSION 1
+static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
+{
+	int i;
+	char *lvb;
+	struct ocfs2_lock_res *lockres = v;
+
+	if (!lockres)
+		return -EINVAL;
+
+	seq_printf(m, "0x%x\t"
+		   "%.*s\t"
+		   "%d\t"
+		   "0x%lx\t"
+		   "0x%x\t"
+		   "0x%x\t"
+		   "%u\t"
+		   "%u\t"
+		   "%d\t"
+		   "%d\t",
+		   OCFS2_DLM_DEBUG_STR_VERSION,
+		   OCFS2_LOCK_ID_MAX_LEN, lockres->l_name,
+		   lockres->l_level,
+		   lockres->l_flags,
+		   lockres->l_action,
+		   lockres->l_unlock_action,
+		   lockres->l_ro_holders,
+		   lockres->l_ex_holders,
+		   lockres->l_requested,
+		   lockres->l_blocking);
+
+	/* Dump the raw LVB */
+	lvb = lockres->l_lksb.lvb;
+	for(i = 0; i < DLM_LVB_LEN; i++)
+		seq_printf(m, "0x%x\t", lvb[i]);
+
+	/* End the line */
+	seq_printf(m, "\n");
+	return 0;
+}
+
+static struct seq_operations ocfs2_dlm_seq_ops = {
+	.start =	ocfs2_dlm_seq_start,
+	.stop =		ocfs2_dlm_seq_stop,
+	.next =		ocfs2_dlm_seq_next,
+	.show =		ocfs2_dlm_seq_show,
+};
+
+static int ocfs2_dlm_debug_release(struct inode *inode, struct file *file)
+{
+	struct seq_file *seq = (struct seq_file *) file->private_data;
+	struct ocfs2_dlm_seq_priv *priv = seq->private;
+	struct ocfs2_lock_res *res = &priv->p_iter_res;
+
+	ocfs2_remove_lockres_tracking(res);
+	ocfs2_put_dlm_debug(priv->p_dlm_debug);
+	return seq_release_private(inode, file);
+}
+
+static int ocfs2_dlm_debug_open(struct inode *inode, struct file *file)
+{
+	int ret;
+	struct ocfs2_dlm_seq_priv *priv;
+	struct seq_file *seq;
+	ocfs2_super *osb;
+
+	priv = kzalloc(sizeof(struct ocfs2_dlm_seq_priv), GFP_KERNEL);
+	if (!priv) {
+		ret = -ENOMEM;
+		mlog_errno(ret);
+		goto out;
+	}
+	osb = (ocfs2_super *) inode->u.generic_ip;
+	ocfs2_get_dlm_debug(osb->osb_dlm_debug);
+	priv->p_dlm_debug = osb->osb_dlm_debug;
+	INIT_LIST_HEAD(&priv->p_iter_res.l_debug_list);
+
+	ret = seq_open(file, &ocfs2_dlm_seq_ops);
+	if (ret) {
+		kfree(priv);
+		mlog_errno(ret);
+		goto out;
+	}
+
+	seq = (struct seq_file *) file->private_data;
+	seq->private = priv;
+
+	ocfs2_add_lockres_tracking(&priv->p_iter_res,
+				   priv->p_dlm_debug);
+
+out:
+	return ret;
+}
+
+static struct file_operations ocfs2_dlm_debug_fops = {
+	.open =		ocfs2_dlm_debug_open,
+	.release =	ocfs2_dlm_debug_release,
+	.read =		seq_read,
+	.llseek =	seq_lseek,
+};
+
+static int ocfs2_dlm_init_debug(ocfs2_super *osb)
+{
+	int ret = 0;
+	struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
+
+	dlm_debug->d_locking_state = debugfs_create_file("locking_state",
+							 S_IFREG|S_IRUSR,
+							 osb->osb_debug_root,
+							 osb,
+							 &ocfs2_dlm_debug_fops);
+	if (!dlm_debug->d_locking_state) {
+		ret = -EINVAL;
+		mlog(ML_ERROR,
+		     "Unable to create locking state debugfs file.\n");
+		goto out;
+	}
+
+	ocfs2_get_dlm_debug(dlm_debug);
+out:
+	return ret;
+}
+
+static void ocfs2_dlm_shutdown_debug(ocfs2_super *osb)
+{
+	struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
+
+	if (dlm_debug) {
+		debugfs_remove(dlm_debug->d_locking_state);
+		ocfs2_put_dlm_debug(dlm_debug);
+	}
+}
+
 int ocfs2_dlm_init(ocfs2_super *osb)
 {
 	int status;
@@ -1658,6 +1939,12 @@
 
 	mlog_entry_void();
 
+	status = ocfs2_dlm_init_debug(osb);
+	if (status < 0) {
+		mlog_errno(status);
+		goto bail;
+	}
+
 	/* launch vote thread */
 	osb->vote_task = kthread_run(ocfs2_vote_thread, osb, "ocfs2vote-%d",
 				     osb->osb_id);
@@ -1689,6 +1976,8 @@
 
 	status = 0;
 bail:
+	if (status < 0)
+		ocfs2_dlm_shutdown_debug(osb);
 
 	mlog_exit(status);
 	return status;
@@ -1713,6 +2002,8 @@
 	dlm_unregister_domain(osb->dlm);
 	osb->dlm = NULL;
 
+	ocfs2_dlm_shutdown_debug(osb);
+
 	mlog_exit_void();
 }
 

Modified: branches/ocfs2-1.0/fs/ocfs2/dlmglue.h
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/dlmglue.h	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/dlmglue.h	2005-11-18 21:52:17 UTC (rev 2705)
@@ -85,4 +85,7 @@
 void ocfs2_process_blocked_lock(ocfs2_super *osb,
 				struct ocfs2_lock_res *lockres);
 
+struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void);
+void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug);
+
 #endif	/* DLMGLUE_H */

Modified: branches/ocfs2-1.0/fs/ocfs2/extent_map.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/extent_map.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/extent_map.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -159,23 +159,29 @@
 
 			ret = -EBADR;
 			if ((rec->e_cpos + rec->e_clusters) >
-			    OCFS2_I(inode)->ip_clusters)
+			    OCFS2_I(inode)->ip_clusters) {
+				mlog_errno(ret);
 				goto out_free;
+			}
 
 			if ((rec->e_cpos + rec->e_clusters) <= cpos) {
 				ret = ocfs2_extent_map_insert(inode,
 							      rec,
 							      el->l_tree_depth);
-				if (ret && (ret != -EEXIST))
+				if (ret && (ret != -EEXIST)) {
+					mlog_errno(ret);
 					goto out_free;
+				}
 				continue;
 			}
 			if ((cpos + clusters) <= rec->e_cpos) {
 				ret = ocfs2_extent_map_insert(inode,
 							      rec,
 							      el->l_tree_depth);
-				if (ret && (ret != -EEXIST))
+				if (ret && (ret != -EEXIST)) {
+					mlog_errno(ret);
 					goto out_free;
+				}
 				continue;
 			}
 
@@ -189,8 +195,10 @@
 			ret = -ESRCH;
 			if ((rec->e_cpos > cpos) ||
 			    ((cpos + clusters) >
-			     (rec->e_cpos + rec->e_clusters)))
+			     (rec->e_cpos + rec->e_clusters))) {
+				mlog_errno(ret);
 				goto out_free;
+			}
 
 			/*
 			 * If we've already found a record, the el has
@@ -198,8 +206,10 @@
 			 * EEEK!
 			 */
 			ret = -EBADR;
-			if (blkno)
+			if (blkno) {
+				mlog_errno(ret);
 				goto out_free;
+			}
 
 			blkno = rec->e_blkno;
 		}
@@ -219,8 +229,10 @@
 		ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
 				       blkno, &eb_bh, OCFS2_BH_CACHED,
 				       inode);
-		if (ret)
+		if (ret) {
+			mlog_errno(ret);
 			goto out_free;
+		}
 		eb = (ocfs2_extent_block *)eb_bh->b_data;
 		OCFS2_BUG_ON_INVALID_EXTENT_BLOCK(eb);
 		el = &eb->h_list;
@@ -233,8 +245,10 @@
 		rec = &el->l_recs[i];
 		ret = ocfs2_extent_map_insert(inode, rec,
 					      el->l_tree_depth);
-		if (ret)
+		if (ret) {
+			mlog_errno(ret);
 			goto out_free;
+		}
 	}
 
 	ret = 0;
@@ -279,6 +293,7 @@
 		ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, &bh,
 				       OCFS2_BH_CACHED, inode);
 		if (ret) {
+			mlog_errno(ret);
 			if (bh)
 				brelse(bh);
 			return ret;
@@ -293,6 +308,7 @@
 				       OCFS2_I(inode)->ip_blkno, &bh,
 				       OCFS2_BH_CACHED, inode);
 		if (ret) {
+			mlog_errno(ret);
 			if (bh)
 				brelse(bh);
 			return ret;
@@ -304,12 +320,17 @@
 
 	ret = ocfs2_extent_map_find_leaf(inode, cpos, clusters, el);
 	brelse(bh);
-	if (ret)
+	if (ret) {
+		mlog_errno(ret);
 		return ret;
+	}
 
 	ent = ocfs2_extent_map_lookup(em, cpos, clusters, NULL, NULL);
-	if (!ent)
-		return -ESRCH;
+	if (!ent) {
+		ret = -ESRCH;
+		mlog_errno(ret);
+		return ret;
+	}
 
 	if (ent->e_tree_depth)
 		BUG();  /* FIXME: Make sure this isn't a corruption */
@@ -458,14 +479,20 @@
 	struct ocfs2_em_insert_context ctxt = {0, };
 
 	if ((rec->e_cpos + rec->e_clusters) >
-	    OCFS2_I(inode)->ip_map.em_clusters)
-		return -EBADR;
+	    OCFS2_I(inode)->ip_map.em_clusters) {
+		ret = -EBADR;
+		mlog_errno(ret);
+		return ret;
+	}
 
 	/* Zero e_clusters means a truncated tail record.  It better be EOF */
 	if (!rec->e_clusters) {
 		if ((rec->e_cpos + rec->e_clusters) !=
-		    OCFS2_I(inode)->ip_map.em_clusters)
-			return -EBADR;
+		    OCFS2_I(inode)->ip_map.em_clusters) {
+			ret = -EBADR;
+			mlog_errno(ret);
+			return ret;
+		}
 
 		/* Ignore the truncated tail */
 		return 0;
@@ -474,8 +501,10 @@
 	ret = -ENOMEM;
 	ctxt.new_ent = kmem_cache_alloc(ocfs2_em_ent_cachep,
 					GFP_KERNEL);
-	if (!ctxt.new_ent)
+	if (!ctxt.new_ent) {
+		mlog_errno(ret);
 		return ret;
+	}
 
 	ctxt.new_ent->e_rec = *rec;
 	ctxt.new_ent->e_tree_depth = tree_depth;
@@ -501,6 +530,9 @@
 						  tree_depth, &ctxt);
 	} while (ret == -EAGAIN);
 
+	if (ret < 0)
+		mlog_errno(ret);
+
 	if (ctxt.left_ent)
 		kmem_cache_free(ocfs2_em_ent_cachep, ctxt.left_ent);
 	if (ctxt.right_ent)
@@ -593,6 +625,8 @@
 
 	if (ret == -ENOENT)
 		ret = ocfs2_extent_map_insert(inode, rec, 0);
+	if (ret < 0)
+		mlog_errno(ret);
 
 	return ret;
 }
@@ -717,8 +751,11 @@
 	cpos = ocfs2_blocks_to_clusters(inode->i_sb, v_blkno);
 	clusters = ocfs2_blocks_to_clusters(inode->i_sb,
 					    (u64)count + bpc - 1);
-	if ((cpos + clusters) > OCFS2_I(inode)->ip_clusters)
-		return -EINVAL;
+	if ((cpos + clusters) > OCFS2_I(inode)->ip_clusters) {
+		ret = -EINVAL;
+		mlog_errno(ret);
+		return ret;
+	}
 
 	if ((cpos + clusters) > em->em_clusters) {
 		/*
@@ -731,8 +768,10 @@
 	}
 
 	ret = ocfs2_extent_map_lookup_read(inode, cpos, clusters, &ent);
-	if (ret)
+	if (ret) {
+		mlog_errno(ret);
 		return ret;
+	}
 
 	if (ent)
 	{
@@ -741,8 +780,11 @@
 		/* We should never find ourselves straddling an interval */
 		if ((rec->e_cpos > cpos) ||
 		    ((cpos + clusters) >
-		     (rec->e_cpos + rec->e_clusters)))
-			return -ESRCH;
+		     (rec->e_cpos + rec->e_clusters))) {
+			ret = -ESRCH;
+			mlog_errno(ret);
+			return ret;
+		}
 
 		boff = ocfs2_clusters_to_blocks(inode->i_sb,
 						cpos - rec->e_cpos);

Modified: branches/ocfs2-1.0/fs/ocfs2/ocfs2.h
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/ocfs2.h	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/ocfs2.h	2005-11-18 21:52:17 UTC (rev 2705)
@@ -32,6 +32,7 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <linux/workqueue.h>
+#include <linux/kref.h>
 
 #include "cluster/nodemanager.h"
 #include "cluster/heartbeat.h"
@@ -141,8 +142,16 @@
 	int                      l_blocking;
 
 	wait_queue_head_t        l_event;
+
+	struct list_head         l_debug_list;
 };
 
+struct ocfs2_dlm_debug {
+	struct kref d_refcnt;
+	struct dentry *d_locking_state;
+	struct list_head d_lockres_tracking;
+};
+
 enum ocfs2_vol_state
 {
 	VOLUME_INIT = 0,
@@ -248,7 +257,10 @@
 	struct ocfs2_lock_res osb_super_lockres;
 	struct ocfs2_lock_res osb_rename_lockres;
 	struct dlm_eviction_cb osb_eviction_cb;
+	struct ocfs2_dlm_debug *osb_dlm_debug;
 
+	struct dentry *osb_debug_root;
+
 	wait_queue_head_t recovery_event;
 
 	spinlock_t vote_task_lock;

Modified: branches/ocfs2-1.0/fs/ocfs2/super.c
===================================================================
--- branches/ocfs2-1.0/fs/ocfs2/super.c	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/fs/ocfs2/super.c	2005-11-18 21:52:17 UTC (rev 2705)
@@ -37,6 +37,7 @@
 #include <linux/socket.h>
 #include <linux/inet.h>
 #include <linux/parser.h>
+#include <linux/debugfs.h>
 
 #include <cluster/nodemanager.h>
 
@@ -84,6 +85,8 @@
  * workqueue and schedule on our own. */
 struct workqueue_struct *ocfs2_wq = NULL;
 
+static struct dentry *ocfs2_debugfs_root = NULL;
+
 MODULE_AUTHOR("Oracle");
 MODULE_LICENSE("GPL");
 
@@ -390,6 +393,14 @@
 	sb->s_flags |= MS_NOATIME;
 	sb->s_fs_info = NULL;
 
+	osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
+						 ocfs2_debugfs_root);
+	if (!osb->osb_debug_root) {
+		status = -EINVAL;
+		mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n");
+		goto read_super_error;
+	}
+
 	status = ocfs2_mount_volume(sb, mount_opt);
 	/* ocfs2_mount_volume may set osb even on error so we want to
 	 * pull it off for proper cleanup. */
@@ -563,6 +574,12 @@
 	osb_id = 0;
 	spin_unlock(&ocfs2_globals_lock);
 
+	ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
+	if (!ocfs2_debugfs_root) {
+		status = -EFAULT;
+		mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
+	}
+
 	/* Initialize the proc interface */
 	ocfs2_proc_init();
 
@@ -595,6 +612,8 @@
 	/* Deinit the proc interface */
 	ocfs2_proc_deinit();
 
+	debugfs_remove(ocfs2_debugfs_root);
+
 	unregister_filesystem(&ocfs2_fs_type);
 
 	exit_ocfs2_extent_maps();
@@ -1064,6 +1083,8 @@
 
 	ocfs2_clear_hb_callbacks(osb);
 
+	debugfs_remove(osb->osb_debug_root);
+
 	if (!mnt_err)
 		ocfs2_stop_heartbeat(osb);
 
@@ -1282,6 +1303,13 @@
 	mlog(0, "root_blkno=%"MLFu64", system_dir_blkno=%"MLFu64"\n",
 	     osb->root_blkno, osb->system_dir_blkno);
 
+	osb->osb_dlm_debug = ocfs2_new_dlm_debug();
+	if (!osb->osb_dlm_debug) {
+		status = -ENOMEM;
+		mlog_errno(status);
+		goto bail;
+	}
+
 	atomic_set(&osb->vol_state, VOLUME_INIT);
 
 	/* load root, system_dir, and all global system inodes */
@@ -1503,6 +1531,7 @@
 	if (osb->local_alloc_copy)
 		kfree(osb->local_alloc_copy);
 	kfree(osb->uuid_str);
+	ocfs2_put_dlm_debug(osb->osb_dlm_debug);
 	memset(osb, 0, sizeof(ocfs2_super));
 
 	mlog_exit_void();

Added: branches/ocfs2-1.0/kapi-compat/include/kzalloc.h
===================================================================
--- branches/ocfs2-1.0/kapi-compat/include/kzalloc.h	2005-11-18 21:48:30 UTC (rev 2704)
+++ branches/ocfs2-1.0/kapi-compat/include/kzalloc.h	2005-11-18 21:52:17 UTC (rev 2705)
@@ -0,0 +1,6 @@
+#ifndef KAPI_KZALLOC_H
+#define KAPI_KZALLOC_H
+
+#define kzalloc(_size, _gfp_flags)	kcalloc(1, _size, _gfp_flags)
+
+#endif /* KAPI_KZALLOC_H */



More information about the Ocfs2-commits mailing list