Skip to contentSkip to conversation

backports to 1.4 from mainline

Ocfs2-devel New Srinivas Eeda 2 participants 4 messages Nov 2, 2010 OCFS2

lore
Share & tools
lore
#0 lore raw

The following two patches are backports from mainline to 1.4. These patches create debugfs entry for heartbeat regions and to show elapsed time.

#1 lore raw

PATCH 1/2 ocfs2/cluster: Create debugfs dir for heartbeat regions

From: Sunil Mushran <[email protected]>

Mainline 0841ed580fe8a3e51ba9dbb133dafc787cce428f

---
 fs/ocfs2/cluster/heartbeat.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
fs/ocfs2/cluster/heartbeat.c +19 -8
index 55e8718..8580e66 100644
@@ -134,6 +134,8 @@ struct o2hb_region {
 	struct block_device	*hr_bdev;
 	struct o2hb_disk_slot	*hr_slots;
 
+	struct dentry		*hr_debug_dir;
+
 	/* let the person setting up hb wait for it to return until it
 	 * has reached a 'steady' state.  This will be fixed when we have
 	 * a more complete api that doesn't lead to this sort of fragility. */
@@ -1085,6 +1087,8 @@ static void o2hb_region_release(struct config_item *item)
 	if (reg->hr_slots)
 		kfree(reg->hr_slots);
 
+	debugfs_remove(reg->hr_debug_dir);
+
 	spin_lock(&o2hb_live_lock);
 	list_del(&reg->hr_all_item);
 	spin_unlock(&o2hb_live_lock);
@@ -1597,24 +1601,31 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
 							  const char *name)
 {
 	struct o2hb_region *reg = NULL;
-	struct config_item *ret = NULL;
 
 	reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
-	if (reg == NULL)
-		goto out; /* ENOMEM */
+	if (reg == NULL) {
+		mlog_errno(-ENOMEM);
+		goto out;
+	}
 
 	config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type);
 
-	ret = &reg->hr_item;
+	reg->hr_debug_dir =
+		debugfs_create_dir(config_item_name(&reg->hr_item), o2hb_debug_dir);
+	if (!reg->hr_debug_dir) {
+		mlog_errno(-ENOMEM);
+		goto out;
+	}
 
 	spin_lock(&o2hb_live_lock);
 	list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
 	spin_unlock(&o2hb_live_lock);
-out:
-	if (ret == NULL)
-		kfree(reg);
 
-	return ret;
+	return &reg->hr_item;
+
+out:
+	kfree(reg);
+	return NULL;
 }
 
 static void o2hb_heartbeat_group_drop_item(struct config_group *group,
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/2 ocfs2/cluster: Add per-region debugfs file to show the elapsed time

In reply to Srinivas Eeda

From: Sunil Mushran <[email protected]>

Mainline fa16655a622e7c0fda76ca5155db6efc86968c65
A per-region debugfs file, elapsed_time_in_ms, shows the time since the heartbeat timer was last armed.

---
 fs/ocfs2/cluster/heartbeat.c |   46 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
fs/ocfs2/cluster/heartbeat.c +46 -0
index 8580e66..0ae0dea 100644
@@ -63,6 +63,7 @@ static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue);
 
 #define O2HB_DEBUG_DIR			"o2hb"
 #define O2HB_DEBUG_LIVENODES		"livenodes"
+#define O2HB_DEBUG_REGION_ELAPSED_TIME	"elapsed_time_in_ms"
 static struct dentry *o2hb_debug_dir;
 static struct dentry *o2hb_debug_livenodes;
 
@@ -135,6 +136,7 @@ struct o2hb_region {
 	struct o2hb_disk_slot	*hr_slots;
 
 	struct dentry		*hr_debug_dir;
+	struct dentry		*hr_debug_elapsed_time;
 
 	/* let the person setting up hb wait for it to return until it
 	 * has reached a 'steady' state.  This will be fixed when we have
@@ -950,6 +952,29 @@ bail:
 	return -ENOMEM;
 }
 
+static int o2hb_region_debug_open(struct inode *inode, struct file *file)
+{
+	struct o2hb_region *reg = inode->i_private;
+	char *buf = NULL;
+	int out = 0;
+
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!buf)
+		goto bail;
+
+	out += snprintf(buf + out, PAGE_SIZE - out, "%u\n",
+			jiffies_to_msecs(jiffies -
+					 reg->hr_last_timeout_start));
+
+	i_size_write(inode, out);
+
+	file->private_data = buf;
+
+	return 0;
+bail:
+	return -ENOMEM;
+}
+
 static int o2hb_debug_release(struct inode *inode, struct file *file)
 {
 	kfree(file->private_data);
@@ -985,6 +1010,13 @@ static struct file_operations o2hb_debug_fops = {
 	.llseek =	generic_file_llseek,
 };
 
+static struct file_operations o2hb_region_debug_fops = {
+	.open =		o2hb_region_debug_open,
+	.release =	o2hb_debug_release,
+	.read =		o2hb_debug_read,
+	.llseek =	generic_file_llseek,
+};
+
 void o2hb_exit(void)
 {
 	if (o2hb_debug_livenodes)
@@ -1087,6 +1119,7 @@ static void o2hb_region_release(struct config_item *item)
 	if (reg->hr_slots)
 		kfree(reg->hr_slots);
 
+	debugfs_remove(reg->hr_debug_elapsed_time);
 	debugfs_remove(reg->hr_debug_dir);
 
 	spin_lock(&o2hb_live_lock);
@@ -1617,6 +1650,17 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
 		goto out;
 	}
 
+	reg->hr_debug_elapsed_time =
+		debugfs_create_file(O2HB_DEBUG_REGION_ELAPSED_TIME,
+				    S_IFREG|S_IRUSR,
+				    reg->hr_debug_dir,
+				    reg,
+				    &o2hb_region_debug_fops);
+	if (!reg->hr_debug_elapsed_time) {
+		mlog_errno(-ENOMEM);
+		goto out;
+	}
+
 	spin_lock(&o2hb_live_lock);
 	list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
 	spin_unlock(&o2hb_live_lock);
@@ -1624,6 +1668,8 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
 	return &reg->hr_item;
 
 out:
+	if (reg && reg->hr_debug_dir)
+		debugfs_remove(reg->hr_debug_dir);
 	kfree(reg);
 	return NULL;
 }
Signature · 1 line
1.5.6.5
#3 lore raw
In reply to Srinivas Eeda
Quoted 2 lines · Srinivas Eeda

The following two patches are backports from mainline to 1.4. These patches create debugfs entry for heartbeat regions and to show elapsed time.

Works for me.

Joel

Signature · 7 lines
"Drake!  We're LEAVING!"

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127