[Ocfs2-commits] mfasheh commits r2612 - trunk/fs/ocfs2/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Sep 22 18:00:18 CDT 2005


Author: mfasheh
Signed-off-by: jlbec
Signed-off-by: zab
Date: 2005-09-22 18:00:17 -0500 (Thu, 22 Sep 2005)
New Revision: 2612

Modified:
   trunk/fs/ocfs2/cluster/heartbeat.c
   trunk/fs/ocfs2/cluster/heartbeat.h
   trunk/fs/ocfs2/cluster/nodemanager.c
Log:
* make the hb_dead_threshold a heartbeat configfs attribute       

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



Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-09-22 22:01:28 UTC (rev 2611)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-09-22 23:00:17 UTC (rev 2612)
@@ -77,7 +77,7 @@
  * No locking or otherwise interesting code is required for reading
  * o2hb_dead_threshold as it can't change once regions are active and
  * it's not interesting to anyone until then anyway. */
-void o2hb_dead_threshold_set(unsigned int threshold)
+static void o2hb_dead_threshold_set(unsigned int threshold)
 {
 	if (threshold > O2HB_MIN_DEAD_THRESHOLD) {
 		spin_lock(&o2hb_live_lock);
@@ -1533,6 +1533,81 @@
 	config_item_put(item);
 }
 
+struct o2hb_heartbeat_group_attribute {
+	struct configfs_attribute attr;
+	ssize_t (*show)(struct o2hb_heartbeat_group *, char *);
+	ssize_t (*store)(struct o2hb_heartbeat_group *, const char *, size_t);
+};
+
+static ssize_t o2hb_heartbeat_group_show(struct config_item *item,
+					 struct configfs_attribute *attr,
+					 char *page)
+{
+	struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item));
+	struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr =
+		container_of(attr, struct o2hb_heartbeat_group_attribute, attr);
+	ssize_t ret = 0;
+
+	if (o2hb_heartbeat_group_attr->show)
+		ret = o2hb_heartbeat_group_attr->show(reg, page);
+	return ret;
+}
+
+static ssize_t o2hb_heartbeat_group_store(struct config_item *item,
+					  struct configfs_attribute *attr,
+					  const char *page, size_t count)
+{
+	struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item));
+	struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr =
+		container_of(attr, struct o2hb_heartbeat_group_attribute, attr);
+	ssize_t ret = -EINVAL;
+
+	if (o2hb_heartbeat_group_attr->store)
+		ret = o2hb_heartbeat_group_attr->store(reg, page, count);
+	return ret;
+}
+
+static ssize_t o2hb_heartbeat_group_threshold_show(struct o2hb_heartbeat_group *group,
+						     char *page)
+{
+	return sprintf(page, "%u\n", o2hb_dead_threshold);
+}
+
+static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group *group,
+						    const char *page,
+						    size_t count)
+{
+	unsigned long tmp;
+	char *p = (char *)page;
+
+	tmp = simple_strtoul(p, &p, 10);
+	if (!p || (*p && (*p != '\n')))
+                return -EINVAL;
+
+	/* this will validate ranges for us. */
+	o2hb_dead_threshold_set((unsigned int) tmp);
+
+	return count;
+}
+
+static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = {
+	.attr	= { .ca_owner = THIS_MODULE,
+		    .ca_name = "dead_threshold",
+		    .ca_mode = S_IRUGO | S_IWUSR },
+	.show	= o2hb_heartbeat_group_threshold_show,
+	.store	= o2hb_heartbeat_group_threshold_store,
+};
+
+static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = {
+	&o2hb_heartbeat_group_attr_threshold.attr,
+	NULL,
+};
+
+static struct configfs_item_operations o2hb_hearbeat_group_item_ops = {
+	.show_attribute		= o2hb_heartbeat_group_show,
+	.store_attribute	= o2hb_heartbeat_group_store,
+};
+
 static struct configfs_group_operations o2hb_heartbeat_group_group_ops = {
 	.make_item	= o2hb_heartbeat_group_make_item,
 	.drop_item	= o2hb_heartbeat_group_drop_item,
@@ -1540,6 +1615,8 @@
 
 static struct config_item_type o2hb_heartbeat_group_type = {
 	.ct_group_ops	= &o2hb_heartbeat_group_group_ops,
+	.ct_item_ops	= &o2hb_hearbeat_group_item_ops,
+	.ct_attrs	= o2hb_heartbeat_group_attrs,
 	.ct_owner	= THIS_MODULE,
 };
 

Modified: trunk/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.h	2005-09-22 22:01:28 UTC (rev 2611)
+++ trunk/fs/ocfs2/cluster/heartbeat.h	2005-09-22 23:00:17 UTC (rev 2612)
@@ -40,9 +40,6 @@
 #define O2HB_MIN_DEAD_THRESHOLD	  2
 #define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1))
 
-/* Always use this to set o2hb_dead_threshold */
-void o2hb_dead_threshold_set(unsigned int threshold);
-
 #define O2HB_CB_MAGIC		0x51d1e4ec
 
 /* callback stuff */

Modified: trunk/fs/ocfs2/cluster/nodemanager.c
===================================================================
--- trunk/fs/ocfs2/cluster/nodemanager.c	2005-09-22 22:01:28 UTC (rev 2611)
+++ trunk/fs/ocfs2/cluster/nodemanager.c	2005-09-22 23:00:17 UTC (rev 2612)
@@ -734,12 +734,10 @@
 static struct proc_dir_entry *o2nm_proc;
 
 #define O2NM_VERSION_PROC_NAME "interface_revision"
-#define O2NM_HB_DEAD_THRESHOLD_NAME "hb_dead_threshold"
 
 static void o2nm_remove_proc(struct proc_dir_entry *parent)
 {
 	remove_proc_entry(O2NM_VERSION_PROC_NAME, parent);
-	remove_proc_entry(O2NM_HB_DEAD_THRESHOLD_NAME, parent);
 }
 
 static void __exit exit_o2nm(void)
@@ -789,39 +787,6 @@
 				   O2NM_API_VERSION);
 }
 
-static int o2nm_proc_threshold(char *page, char **start, off_t off,
-			       int count, int *eof, void *data)
-{
-	return o2nm_proc_read_uint(page, start, off, count, eof,
-				   o2hb_dead_threshold);
-}
-
-static int o2nm_proc_write_threshold(struct file *file,
-				     const char __user *buffer,
-				     unsigned long count, void *data)
-{
-	char buf[32];
-	char *p = buf;
-	unsigned long tmp;
-
-	if (count > ARRAY_SIZE(buf) - 1)
-		count = ARRAY_SIZE(buf) - 1;
-
-	if (copy_from_user(buf, buffer, count))
-		return -EFAULT;
-
-	buf[ARRAY_SIZE(buf) - 1] = '\0';
-
-	tmp = simple_strtoul(p, &p, 10);
-	if (!p || (*p && (*p != '\n')))
-                return -EINVAL;
-
-	/* this will validate ranges for us. */
-	o2hb_dead_threshold_set((unsigned int) tmp);
-
-	return count;
-}
-
 static int o2nm_init_proc(struct proc_dir_entry *parent)
 {
 	struct proc_dir_entry *p;
@@ -834,16 +799,6 @@
 	if (!p)
 		return -ENOMEM;
 
-	p = create_proc_read_entry(O2NM_HB_DEAD_THRESHOLD_NAME,
-				   S_IFREG | S_IRUGO | S_IWUSR, parent,
-				   o2nm_proc_threshold,
-				   NULL);
-	if (!p) {
-		remove_proc_entry(O2NM_VERSION_PROC_NAME, parent);
-		return -ENOMEM;
-	}
-	p->write_proc = o2nm_proc_write_threshold;
-
 	return 0;
 }
 



More information about the Ocfs2-commits mailing list