diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2010-10-07 18:26:08 -0400 |
---|---|---|
committer | Sunil Mushran <sunil.mushran@oracle.com> | 2010-10-07 18:26:08 -0400 |
commit | 54b5187b5a1ad6573ade8b18e065dda92501fc52 (patch) | |
tree | 7e092a6b57f9066b615942d100dff6fc92106e68 /fs/ocfs2 | |
parent | cb655d0f3d57c23db51b981648e452988c0223f9 (diff) |
ocfs2/cluster: Add heartbeat mode configfs parameter
Add heartbeat mode parameter to the configfs tree. This will be used
to set/show the heartbeat mode. The user is free to toggle the mode
between local and global as long as there is no active heartbeat region.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 41d5f1f92d56..4d36459a8343 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -77,7 +77,19 @@ static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type); | |||
77 | 77 | ||
78 | #define O2HB_DEFAULT_BLOCK_BITS 9 | 78 | #define O2HB_DEFAULT_BLOCK_BITS 9 |
79 | 79 | ||
80 | enum o2hb_heartbeat_modes { | ||
81 | O2HB_HEARTBEAT_LOCAL = 0, | ||
82 | O2HB_HEARTBEAT_GLOBAL, | ||
83 | O2HB_HEARTBEAT_NUM_MODES, | ||
84 | }; | ||
85 | |||
86 | char *o2hb_heartbeat_mode_desc[O2HB_HEARTBEAT_NUM_MODES] = { | ||
87 | "local", /* O2HB_HEARTBEAT_LOCAL */ | ||
88 | "global", /* O2HB_HEARTBEAT_GLOBAL */ | ||
89 | }; | ||
90 | |||
80 | unsigned int o2hb_dead_threshold = O2HB_DEFAULT_DEAD_THRESHOLD; | 91 | unsigned int o2hb_dead_threshold = O2HB_DEFAULT_DEAD_THRESHOLD; |
92 | unsigned int o2hb_heartbeat_mode = O2HB_HEARTBEAT_LOCAL; | ||
81 | 93 | ||
82 | /* Only sets a new threshold if there are no active regions. | 94 | /* Only sets a new threshold if there are no active regions. |
83 | * | 95 | * |
@@ -94,6 +106,22 @@ static void o2hb_dead_threshold_set(unsigned int threshold) | |||
94 | } | 106 | } |
95 | } | 107 | } |
96 | 108 | ||
109 | static int o2hb_global_hearbeat_mode_set(unsigned int hb_mode) | ||
110 | { | ||
111 | int ret = -1; | ||
112 | |||
113 | if (hb_mode < O2HB_HEARTBEAT_NUM_MODES) { | ||
114 | spin_lock(&o2hb_live_lock); | ||
115 | if (list_empty(&o2hb_all_regions)) { | ||
116 | o2hb_heartbeat_mode = hb_mode; | ||
117 | ret = 0; | ||
118 | } | ||
119 | spin_unlock(&o2hb_live_lock); | ||
120 | } | ||
121 | |||
122 | return ret; | ||
123 | } | ||
124 | |||
97 | struct o2hb_node_event { | 125 | struct o2hb_node_event { |
98 | struct list_head hn_item; | 126 | struct list_head hn_item; |
99 | enum o2hb_callback_type hn_event_type; | 127 | enum o2hb_callback_type hn_event_type; |
@@ -1688,6 +1716,41 @@ static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group | |||
1688 | return count; | 1716 | return count; |
1689 | } | 1717 | } |
1690 | 1718 | ||
1719 | static | ||
1720 | ssize_t o2hb_heartbeat_group_mode_show(struct o2hb_heartbeat_group *group, | ||
1721 | char *page) | ||
1722 | { | ||
1723 | return sprintf(page, "%s\n", | ||
1724 | o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]); | ||
1725 | } | ||
1726 | |||
1727 | static | ||
1728 | ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group, | ||
1729 | const char *page, size_t count) | ||
1730 | { | ||
1731 | unsigned int i; | ||
1732 | int ret; | ||
1733 | size_t len; | ||
1734 | |||
1735 | len = (page[count - 1] == '\n') ? count - 1 : count; | ||
1736 | if (!len) | ||
1737 | return -EINVAL; | ||
1738 | |||
1739 | for (i = 0; i < O2HB_HEARTBEAT_NUM_MODES; ++i) { | ||
1740 | if (strnicmp(page, o2hb_heartbeat_mode_desc[i], len)) | ||
1741 | continue; | ||
1742 | |||
1743 | ret = o2hb_global_hearbeat_mode_set(i); | ||
1744 | if (!ret) | ||
1745 | printk(KERN_NOTICE "ocfs2: Heartbeat mode set to %s\n", | ||
1746 | o2hb_heartbeat_mode_desc[i]); | ||
1747 | return count; | ||
1748 | } | ||
1749 | |||
1750 | return -EINVAL; | ||
1751 | |||
1752 | } | ||
1753 | |||
1691 | static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = { | 1754 | static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = { |
1692 | .attr = { .ca_owner = THIS_MODULE, | 1755 | .attr = { .ca_owner = THIS_MODULE, |
1693 | .ca_name = "dead_threshold", | 1756 | .ca_name = "dead_threshold", |
@@ -1696,8 +1759,17 @@ static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold | |||
1696 | .store = o2hb_heartbeat_group_threshold_store, | 1759 | .store = o2hb_heartbeat_group_threshold_store, |
1697 | }; | 1760 | }; |
1698 | 1761 | ||
1762 | static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_mode = { | ||
1763 | .attr = { .ca_owner = THIS_MODULE, | ||
1764 | .ca_name = "mode", | ||
1765 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1766 | .show = o2hb_heartbeat_group_mode_show, | ||
1767 | .store = o2hb_heartbeat_group_mode_store, | ||
1768 | }; | ||
1769 | |||
1699 | static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { | 1770 | static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { |
1700 | &o2hb_heartbeat_group_attr_threshold.attr, | 1771 | &o2hb_heartbeat_group_attr_threshold.attr, |
1772 | &o2hb_heartbeat_group_attr_mode.attr, | ||
1701 | NULL, | 1773 | NULL, |
1702 | }; | 1774 | }; |
1703 | 1775 | ||