aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/config.c
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2011-06-30 08:37:10 -0400
committerDavid Teigland <teigland@redhat.com>2011-06-30 15:45:28 -0400
commit55b3286d3dfd74a1daa5c902cb76575ba0187388 (patch)
treeb2f473f81c270b0a871d978d6c575f39d0702c23 /fs/dlm/config.c
parent0e90ed0e8b9b1c25040442f1d20c799751b1e727 (diff)
dlm: show addresses in configfs
Display all addresses the dlm is using for the local node from the configfs file config/dlm/<cluster>/comms/<comm>/addr_list Also make the addr file write only. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/config.c')
-rw-r--r--fs/dlm/config.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 9b026ea8baa9..ad3b5a8535d0 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -28,7 +28,8 @@
28 * /config/dlm/<cluster>/spaces/<space>/nodes/<node>/weight 28 * /config/dlm/<cluster>/spaces/<space>/nodes/<node>/weight
29 * /config/dlm/<cluster>/comms/<comm>/nodeid 29 * /config/dlm/<cluster>/comms/<comm>/nodeid
30 * /config/dlm/<cluster>/comms/<comm>/local 30 * /config/dlm/<cluster>/comms/<comm>/local
31 * /config/dlm/<cluster>/comms/<comm>/addr 31 * /config/dlm/<cluster>/comms/<comm>/addr (write only)
32 * /config/dlm/<cluster>/comms/<comm>/addr_list (read only)
32 * The <cluster> level is useless, but I haven't figured out how to avoid it. 33 * The <cluster> level is useless, but I haven't figured out how to avoid it.
33 */ 34 */
34 35
@@ -80,6 +81,7 @@ static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
80 size_t len); 81 size_t len);
81static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, 82static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf,
82 size_t len); 83 size_t len);
84static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf);
83static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf); 85static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf);
84static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, 86static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
85 size_t len); 87 size_t len);
@@ -190,6 +192,7 @@ enum {
190 COMM_ATTR_NODEID = 0, 192 COMM_ATTR_NODEID = 0,
191 COMM_ATTR_LOCAL, 193 COMM_ATTR_LOCAL,
192 COMM_ATTR_ADDR, 194 COMM_ATTR_ADDR,
195 COMM_ATTR_ADDR_LIST,
193}; 196};
194 197
195struct comm_attribute { 198struct comm_attribute {
@@ -217,14 +220,22 @@ static struct comm_attribute comm_attr_local = {
217static struct comm_attribute comm_attr_addr = { 220static struct comm_attribute comm_attr_addr = {
218 .attr = { .ca_owner = THIS_MODULE, 221 .attr = { .ca_owner = THIS_MODULE,
219 .ca_name = "addr", 222 .ca_name = "addr",
220 .ca_mode = S_IRUGO | S_IWUSR }, 223 .ca_mode = S_IWUSR },
221 .store = comm_addr_write, 224 .store = comm_addr_write,
222}; 225};
223 226
227static struct comm_attribute comm_attr_addr_list = {
228 .attr = { .ca_owner = THIS_MODULE,
229 .ca_name = "addr_list",
230 .ca_mode = S_IRUGO },
231 .show = comm_addr_list_read,
232};
233
224static struct configfs_attribute *comm_attrs[] = { 234static struct configfs_attribute *comm_attrs[] = {
225 [COMM_ATTR_NODEID] = &comm_attr_nodeid.attr, 235 [COMM_ATTR_NODEID] = &comm_attr_nodeid.attr,
226 [COMM_ATTR_LOCAL] = &comm_attr_local.attr, 236 [COMM_ATTR_LOCAL] = &comm_attr_local.attr,
227 [COMM_ATTR_ADDR] = &comm_attr_addr.attr, 237 [COMM_ATTR_ADDR] = &comm_attr_addr.attr,
238 [COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list.attr,
228 NULL, 239 NULL,
229}; 240};
230 241
@@ -720,6 +731,50 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
720 return len; 731 return len;
721} 732}
722 733
734static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf)
735{
736 ssize_t s;
737 ssize_t allowance;
738 int i;
739 struct sockaddr_storage *addr;
740 struct sockaddr_in *addr_in;
741 struct sockaddr_in6 *addr_in6;
742
743 /* Taken from ip6_addr_string() defined in lib/vsprintf.c */
744 char buf0[sizeof("AF_INET6 xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255\n")];
745
746
747 /* Derived from SIMPLE_ATTR_SIZE of fs/configfs/file.c */
748 allowance = 4096;
749 buf[0] = '\0';
750
751 for (i = 0; i < cm->addr_count; i++) {
752 addr = cm->addr[i];
753
754 switch(addr->ss_family) {
755 case AF_INET:
756 addr_in = (struct sockaddr_in *)addr;
757 s = sprintf(buf0, "AF_INET %pI4\n", &addr_in->sin_addr.s_addr);
758 break;
759 case AF_INET6:
760 addr_in6 = (struct sockaddr_in6 *)addr;
761 s = sprintf(buf0, "AF_INET6 %pI6\n", &addr_in6->sin6_addr);
762 break;
763 default:
764 s = sprintf(buf0, "%s\n", "<UNKNOWN>");
765 break;
766 }
767 allowance -= s;
768 if (allowance >= 0)
769 strcat(buf, buf0);
770 else {
771 allowance += s;
772 break;
773 }
774 }
775 return 4096 - allowance;
776}
777
723static ssize_t show_node(struct config_item *i, struct configfs_attribute *a, 778static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
724 char *buf) 779 char *buf)
725{ 780{