diff options
-rw-r--r-- | fs/dlm/config.c | 130 | ||||
-rw-r--r-- | fs/dlm/config.h | 17 | ||||
-rw-r--r-- | fs/dlm/dlm_internal.h | 21 | ||||
-rw-r--r-- | fs/dlm/lockspace.c | 43 | ||||
-rw-r--r-- | fs/dlm/member.c | 197 | ||||
-rw-r--r-- | fs/dlm/member.h | 3 | ||||
-rw-r--r-- | fs/dlm/recoverd.c | 10 | ||||
-rw-r--r-- | fs/dlm/user.c | 5 | ||||
-rw-r--r-- | fs/gfs2/lock_dlm.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/stack_user.c | 4 | ||||
-rw-r--r-- | include/linux/dlm.h | 71 |
11 files changed, 333 insertions, 172 deletions
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 6cf72fcc0d0c..e7e327d43fa5 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/in.h> | 18 | #include <linux/in.h> |
19 | #include <linux/in6.h> | 19 | #include <linux/in6.h> |
20 | #include <linux/dlmconstants.h> | ||
20 | #include <net/ipv6.h> | 21 | #include <net/ipv6.h> |
21 | #include <net/sock.h> | 22 | #include <net/sock.h> |
22 | 23 | ||
@@ -36,6 +37,7 @@ | |||
36 | static struct config_group *space_list; | 37 | static struct config_group *space_list; |
37 | static struct config_group *comm_list; | 38 | static struct config_group *comm_list; |
38 | static struct dlm_comm *local_comm; | 39 | static struct dlm_comm *local_comm; |
40 | static uint32_t dlm_comm_count; | ||
39 | 41 | ||
40 | struct dlm_clusters; | 42 | struct dlm_clusters; |
41 | struct dlm_cluster; | 43 | struct dlm_cluster; |
@@ -103,6 +105,8 @@ struct dlm_cluster { | |||
103 | unsigned int cl_timewarn_cs; | 105 | unsigned int cl_timewarn_cs; |
104 | unsigned int cl_waitwarn_us; | 106 | unsigned int cl_waitwarn_us; |
105 | unsigned int cl_new_rsb_count; | 107 | unsigned int cl_new_rsb_count; |
108 | unsigned int cl_recover_callbacks; | ||
109 | char cl_cluster_name[DLM_LOCKSPACE_LEN]; | ||
106 | }; | 110 | }; |
107 | 111 | ||
108 | enum { | 112 | enum { |
@@ -118,6 +122,8 @@ enum { | |||
118 | CLUSTER_ATTR_TIMEWARN_CS, | 122 | CLUSTER_ATTR_TIMEWARN_CS, |
119 | CLUSTER_ATTR_WAITWARN_US, | 123 | CLUSTER_ATTR_WAITWARN_US, |
120 | CLUSTER_ATTR_NEW_RSB_COUNT, | 124 | CLUSTER_ATTR_NEW_RSB_COUNT, |
125 | CLUSTER_ATTR_RECOVER_CALLBACKS, | ||
126 | CLUSTER_ATTR_CLUSTER_NAME, | ||
121 | }; | 127 | }; |
122 | 128 | ||
123 | struct cluster_attribute { | 129 | struct cluster_attribute { |
@@ -126,6 +132,27 @@ struct cluster_attribute { | |||
126 | ssize_t (*store)(struct dlm_cluster *, const char *, size_t); | 132 | ssize_t (*store)(struct dlm_cluster *, const char *, size_t); |
127 | }; | 133 | }; |
128 | 134 | ||
135 | static ssize_t cluster_cluster_name_read(struct dlm_cluster *cl, char *buf) | ||
136 | { | ||
137 | return sprintf(buf, "%s\n", cl->cl_cluster_name); | ||
138 | } | ||
139 | |||
140 | static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl, | ||
141 | const char *buf, size_t len) | ||
142 | { | ||
143 | strncpy(dlm_config.ci_cluster_name, buf, DLM_LOCKSPACE_LEN); | ||
144 | strncpy(cl->cl_cluster_name, buf, DLM_LOCKSPACE_LEN); | ||
145 | return len; | ||
146 | } | ||
147 | |||
148 | static struct cluster_attribute cluster_attr_cluster_name = { | ||
149 | .attr = { .ca_owner = THIS_MODULE, | ||
150 | .ca_name = "cluster_name", | ||
151 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
152 | .show = cluster_cluster_name_read, | ||
153 | .store = cluster_cluster_name_write, | ||
154 | }; | ||
155 | |||
129 | static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, | 156 | static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, |
130 | int *info_field, int check_zero, | 157 | int *info_field, int check_zero, |
131 | const char *buf, size_t len) | 158 | const char *buf, size_t len) |
@@ -171,6 +198,7 @@ CLUSTER_ATTR(protocol, 0); | |||
171 | CLUSTER_ATTR(timewarn_cs, 1); | 198 | CLUSTER_ATTR(timewarn_cs, 1); |
172 | CLUSTER_ATTR(waitwarn_us, 0); | 199 | CLUSTER_ATTR(waitwarn_us, 0); |
173 | CLUSTER_ATTR(new_rsb_count, 0); | 200 | CLUSTER_ATTR(new_rsb_count, 0); |
201 | CLUSTER_ATTR(recover_callbacks, 0); | ||
174 | 202 | ||
175 | static struct configfs_attribute *cluster_attrs[] = { | 203 | static struct configfs_attribute *cluster_attrs[] = { |
176 | [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr, | 204 | [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr, |
@@ -185,6 +213,8 @@ static struct configfs_attribute *cluster_attrs[] = { | |||
185 | [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr, | 213 | [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr, |
186 | [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us.attr, | 214 | [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us.attr, |
187 | [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count.attr, | 215 | [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count.attr, |
216 | [CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks.attr, | ||
217 | [CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name.attr, | ||
188 | NULL, | 218 | NULL, |
189 | }; | 219 | }; |
190 | 220 | ||
@@ -293,6 +323,7 @@ struct dlm_comms { | |||
293 | 323 | ||
294 | struct dlm_comm { | 324 | struct dlm_comm { |
295 | struct config_item item; | 325 | struct config_item item; |
326 | int seq; | ||
296 | int nodeid; | 327 | int nodeid; |
297 | int local; | 328 | int local; |
298 | int addr_count; | 329 | int addr_count; |
@@ -309,6 +340,7 @@ struct dlm_node { | |||
309 | int nodeid; | 340 | int nodeid; |
310 | int weight; | 341 | int weight; |
311 | int new; | 342 | int new; |
343 | int comm_seq; /* copy of cm->seq when nd->nodeid is set */ | ||
312 | }; | 344 | }; |
313 | 345 | ||
314 | static struct configfs_group_operations clusters_ops = { | 346 | static struct configfs_group_operations clusters_ops = { |
@@ -455,6 +487,9 @@ static struct config_group *make_cluster(struct config_group *g, | |||
455 | cl->cl_timewarn_cs = dlm_config.ci_timewarn_cs; | 487 | cl->cl_timewarn_cs = dlm_config.ci_timewarn_cs; |
456 | cl->cl_waitwarn_us = dlm_config.ci_waitwarn_us; | 488 | cl->cl_waitwarn_us = dlm_config.ci_waitwarn_us; |
457 | cl->cl_new_rsb_count = dlm_config.ci_new_rsb_count; | 489 | cl->cl_new_rsb_count = dlm_config.ci_new_rsb_count; |
490 | cl->cl_recover_callbacks = dlm_config.ci_recover_callbacks; | ||
491 | memcpy(cl->cl_cluster_name, dlm_config.ci_cluster_name, | ||
492 | DLM_LOCKSPACE_LEN); | ||
458 | 493 | ||
459 | space_list = &sps->ss_group; | 494 | space_list = &sps->ss_group; |
460 | comm_list = &cms->cs_group; | 495 | comm_list = &cms->cs_group; |
@@ -558,6 +593,11 @@ static struct config_item *make_comm(struct config_group *g, const char *name) | |||
558 | return ERR_PTR(-ENOMEM); | 593 | return ERR_PTR(-ENOMEM); |
559 | 594 | ||
560 | config_item_init_type_name(&cm->item, name, &comm_type); | 595 | config_item_init_type_name(&cm->item, name, &comm_type); |
596 | |||
597 | cm->seq = dlm_comm_count++; | ||
598 | if (!cm->seq) | ||
599 | cm->seq = dlm_comm_count++; | ||
600 | |||
561 | cm->nodeid = -1; | 601 | cm->nodeid = -1; |
562 | cm->local = 0; | 602 | cm->local = 0; |
563 | cm->addr_count = 0; | 603 | cm->addr_count = 0; |
@@ -801,7 +841,10 @@ static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf) | |||
801 | static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, | 841 | static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, |
802 | size_t len) | 842 | size_t len) |
803 | { | 843 | { |
844 | uint32_t seq = 0; | ||
804 | nd->nodeid = simple_strtol(buf, NULL, 0); | 845 | nd->nodeid = simple_strtol(buf, NULL, 0); |
846 | dlm_comm_seq(nd->nodeid, &seq); | ||
847 | nd->comm_seq = seq; | ||
805 | return len; | 848 | return len; |
806 | } | 849 | } |
807 | 850 | ||
@@ -908,13 +951,13 @@ static void put_comm(struct dlm_comm *cm) | |||
908 | } | 951 | } |
909 | 952 | ||
910 | /* caller must free mem */ | 953 | /* caller must free mem */ |
911 | int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out, | 954 | int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out, |
912 | int **new_out, int *new_count_out) | 955 | int *count_out) |
913 | { | 956 | { |
914 | struct dlm_space *sp; | 957 | struct dlm_space *sp; |
915 | struct dlm_node *nd; | 958 | struct dlm_node *nd; |
916 | int i = 0, rv = 0, ids_count = 0, new_count = 0; | 959 | struct dlm_config_node *nodes, *node; |
917 | int *ids, *new; | 960 | int rv, count; |
918 | 961 | ||
919 | sp = get_space(lsname); | 962 | sp = get_space(lsname); |
920 | if (!sp) | 963 | if (!sp) |
@@ -927,73 +970,42 @@ int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out, | |||
927 | goto out; | 970 | goto out; |
928 | } | 971 | } |
929 | 972 | ||
930 | ids_count = sp->members_count; | 973 | count = sp->members_count; |
931 | 974 | ||
932 | ids = kcalloc(ids_count, sizeof(int), GFP_NOFS); | 975 | nodes = kcalloc(count, sizeof(struct dlm_config_node), GFP_NOFS); |
933 | if (!ids) { | 976 | if (!nodes) { |
934 | rv = -ENOMEM; | 977 | rv = -ENOMEM; |
935 | goto out; | 978 | goto out; |
936 | } | 979 | } |
937 | 980 | ||
981 | node = nodes; | ||
938 | list_for_each_entry(nd, &sp->members, list) { | 982 | list_for_each_entry(nd, &sp->members, list) { |
939 | ids[i++] = nd->nodeid; | 983 | node->nodeid = nd->nodeid; |
940 | if (nd->new) | 984 | node->weight = nd->weight; |
941 | new_count++; | 985 | node->new = nd->new; |
942 | } | 986 | node->comm_seq = nd->comm_seq; |
943 | 987 | node++; | |
944 | if (ids_count != i) | ||
945 | printk(KERN_ERR "dlm: bad nodeid count %d %d\n", ids_count, i); | ||
946 | |||
947 | if (!new_count) | ||
948 | goto out_ids; | ||
949 | 988 | ||
950 | new = kcalloc(new_count, sizeof(int), GFP_NOFS); | 989 | nd->new = 0; |
951 | if (!new) { | ||
952 | kfree(ids); | ||
953 | rv = -ENOMEM; | ||
954 | goto out; | ||
955 | } | 990 | } |
956 | 991 | ||
957 | i = 0; | 992 | *count_out = count; |
958 | list_for_each_entry(nd, &sp->members, list) { | 993 | *nodes_out = nodes; |
959 | if (nd->new) { | 994 | rv = 0; |
960 | new[i++] = nd->nodeid; | ||
961 | nd->new = 0; | ||
962 | } | ||
963 | } | ||
964 | *new_count_out = new_count; | ||
965 | *new_out = new; | ||
966 | |||
967 | out_ids: | ||
968 | *ids_count_out = ids_count; | ||
969 | *ids_out = ids; | ||
970 | out: | 995 | out: |
971 | mutex_unlock(&sp->members_lock); | 996 | mutex_unlock(&sp->members_lock); |
972 | put_space(sp); | 997 | put_space(sp); |
973 | return rv; | 998 | return rv; |
974 | } | 999 | } |
975 | 1000 | ||
976 | int dlm_node_weight(char *lsname, int nodeid) | 1001 | int dlm_comm_seq(int nodeid, uint32_t *seq) |
977 | { | 1002 | { |
978 | struct dlm_space *sp; | 1003 | struct dlm_comm *cm = get_comm(nodeid, NULL); |
979 | struct dlm_node *nd; | 1004 | if (!cm) |
980 | int w = -EEXIST; | 1005 | return -EEXIST; |
981 | 1006 | *seq = cm->seq; | |
982 | sp = get_space(lsname); | 1007 | put_comm(cm); |
983 | if (!sp) | 1008 | return 0; |
984 | goto out; | ||
985 | |||
986 | mutex_lock(&sp->members_lock); | ||
987 | list_for_each_entry(nd, &sp->members, list) { | ||
988 | if (nd->nodeid != nodeid) | ||
989 | continue; | ||
990 | w = nd->weight; | ||
991 | break; | ||
992 | } | ||
993 | mutex_unlock(&sp->members_lock); | ||
994 | put_space(sp); | ||
995 | out: | ||
996 | return w; | ||
997 | } | 1009 | } |
998 | 1010 | ||
999 | int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr) | 1011 | int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr) |
@@ -1047,6 +1059,8 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num) | |||
1047 | #define DEFAULT_TIMEWARN_CS 500 /* 5 sec = 500 centiseconds */ | 1059 | #define DEFAULT_TIMEWARN_CS 500 /* 5 sec = 500 centiseconds */ |
1048 | #define DEFAULT_WAITWARN_US 0 | 1060 | #define DEFAULT_WAITWARN_US 0 |
1049 | #define DEFAULT_NEW_RSB_COUNT 128 | 1061 | #define DEFAULT_NEW_RSB_COUNT 128 |
1062 | #define DEFAULT_RECOVER_CALLBACKS 0 | ||
1063 | #define DEFAULT_CLUSTER_NAME "" | ||
1050 | 1064 | ||
1051 | struct dlm_config_info dlm_config = { | 1065 | struct dlm_config_info dlm_config = { |
1052 | .ci_tcp_port = DEFAULT_TCP_PORT, | 1066 | .ci_tcp_port = DEFAULT_TCP_PORT, |
@@ -1060,6 +1074,8 @@ struct dlm_config_info dlm_config = { | |||
1060 | .ci_protocol = DEFAULT_PROTOCOL, | 1074 | .ci_protocol = DEFAULT_PROTOCOL, |
1061 | .ci_timewarn_cs = DEFAULT_TIMEWARN_CS, | 1075 | .ci_timewarn_cs = DEFAULT_TIMEWARN_CS, |
1062 | .ci_waitwarn_us = DEFAULT_WAITWARN_US, | 1076 | .ci_waitwarn_us = DEFAULT_WAITWARN_US, |
1063 | .ci_new_rsb_count = DEFAULT_NEW_RSB_COUNT | 1077 | .ci_new_rsb_count = DEFAULT_NEW_RSB_COUNT, |
1078 | .ci_recover_callbacks = DEFAULT_RECOVER_CALLBACKS, | ||
1079 | .ci_cluster_name = DEFAULT_CLUSTER_NAME | ||
1064 | }; | 1080 | }; |
1065 | 1081 | ||
diff --git a/fs/dlm/config.h b/fs/dlm/config.h index 3099d0dd26c0..9f5e3663bb0c 100644 --- a/fs/dlm/config.h +++ b/fs/dlm/config.h | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -14,6 +14,13 @@ | |||
14 | #ifndef __CONFIG_DOT_H__ | 14 | #ifndef __CONFIG_DOT_H__ |
15 | #define __CONFIG_DOT_H__ | 15 | #define __CONFIG_DOT_H__ |
16 | 16 | ||
17 | struct dlm_config_node { | ||
18 | int nodeid; | ||
19 | int weight; | ||
20 | int new; | ||
21 | uint32_t comm_seq; | ||
22 | }; | ||
23 | |||
17 | #define DLM_MAX_ADDR_COUNT 3 | 24 | #define DLM_MAX_ADDR_COUNT 3 |
18 | 25 | ||
19 | struct dlm_config_info { | 26 | struct dlm_config_info { |
@@ -29,15 +36,17 @@ struct dlm_config_info { | |||
29 | int ci_timewarn_cs; | 36 | int ci_timewarn_cs; |
30 | int ci_waitwarn_us; | 37 | int ci_waitwarn_us; |
31 | int ci_new_rsb_count; | 38 | int ci_new_rsb_count; |
39 | int ci_recover_callbacks; | ||
40 | char ci_cluster_name[DLM_LOCKSPACE_LEN]; | ||
32 | }; | 41 | }; |
33 | 42 | ||
34 | extern struct dlm_config_info dlm_config; | 43 | extern struct dlm_config_info dlm_config; |
35 | 44 | ||
36 | int dlm_config_init(void); | 45 | int dlm_config_init(void); |
37 | void dlm_config_exit(void); | 46 | void dlm_config_exit(void); |
38 | int dlm_node_weight(char *lsname, int nodeid); | 47 | int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out, |
39 | int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out, | 48 | int *count_out); |
40 | int **new_out, int *new_count_out); | 49 | int dlm_comm_seq(int nodeid, uint32_t *seq); |
41 | int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr); | 50 | int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr); |
42 | int dlm_addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid); | 51 | int dlm_addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid); |
43 | int dlm_our_nodeid(void); | 52 | int dlm_our_nodeid(void); |
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index f4d132c76908..3a564d197e99 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -119,28 +119,18 @@ struct dlm_member { | |||
119 | int weight; | 119 | int weight; |
120 | int slot; | 120 | int slot; |
121 | int slot_prev; | 121 | int slot_prev; |
122 | int comm_seq; | ||
122 | uint32_t generation; | 123 | uint32_t generation; |
123 | }; | 124 | }; |
124 | 125 | ||
125 | /* | 126 | /* |
126 | * low nodeid saves array of these in ls_slots | ||
127 | */ | ||
128 | |||
129 | struct dlm_slot { | ||
130 | int nodeid; | ||
131 | int slot; | ||
132 | }; | ||
133 | |||
134 | /* | ||
135 | * Save and manage recovery state for a lockspace. | 127 | * Save and manage recovery state for a lockspace. |
136 | */ | 128 | */ |
137 | 129 | ||
138 | struct dlm_recover { | 130 | struct dlm_recover { |
139 | struct list_head list; | 131 | struct list_head list; |
140 | int *nodeids; /* nodeids of all members */ | 132 | struct dlm_config_node *nodes; |
141 | int node_count; | 133 | int nodes_count; |
142 | int *new; /* nodeids of new members */ | ||
143 | int new_count; | ||
144 | uint64_t seq; | 134 | uint64_t seq; |
145 | }; | 135 | }; |
146 | 136 | ||
@@ -584,6 +574,9 @@ struct dlm_ls { | |||
584 | struct list_head ls_root_list; /* root resources */ | 574 | struct list_head ls_root_list; /* root resources */ |
585 | struct rw_semaphore ls_root_sem; /* protect root_list */ | 575 | struct rw_semaphore ls_root_sem; /* protect root_list */ |
586 | 576 | ||
577 | const struct dlm_lockspace_ops *ls_ops; | ||
578 | void *ls_ops_arg; | ||
579 | |||
587 | int ls_namelen; | 580 | int ls_namelen; |
588 | char ls_name[1]; | 581 | char ls_name[1]; |
589 | }; | 582 | }; |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 1441f04bfabe..a1ea25face82 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -386,12 +386,15 @@ static void threads_stop(void) | |||
386 | dlm_lowcomms_stop(); | 386 | dlm_lowcomms_stop(); |
387 | } | 387 | } |
388 | 388 | ||
389 | static int new_lockspace(const char *name, int namelen, void **lockspace, | 389 | static int new_lockspace(const char *name, const char *cluster, |
390 | uint32_t flags, int lvblen) | 390 | uint32_t flags, int lvblen, |
391 | const struct dlm_lockspace_ops *ops, void *ops_arg, | ||
392 | int *ops_result, dlm_lockspace_t **lockspace) | ||
391 | { | 393 | { |
392 | struct dlm_ls *ls; | 394 | struct dlm_ls *ls; |
393 | int i, size, error; | 395 | int i, size, error; |
394 | int do_unreg = 0; | 396 | int do_unreg = 0; |
397 | int namelen = strlen(name); | ||
395 | 398 | ||
396 | if (namelen > DLM_LOCKSPACE_LEN) | 399 | if (namelen > DLM_LOCKSPACE_LEN) |
397 | return -EINVAL; | 400 | return -EINVAL; |
@@ -403,8 +406,24 @@ static int new_lockspace(const char *name, int namelen, void **lockspace, | |||
403 | return -EINVAL; | 406 | return -EINVAL; |
404 | 407 | ||
405 | if (!dlm_user_daemon_available()) { | 408 | if (!dlm_user_daemon_available()) { |
406 | module_put(THIS_MODULE); | 409 | log_print("dlm user daemon not available"); |
407 | return -EUNATCH; | 410 | error = -EUNATCH; |
411 | goto out; | ||
412 | } | ||
413 | |||
414 | if (ops && ops_result) { | ||
415 | if (!dlm_config.ci_recover_callbacks) | ||
416 | *ops_result = -EOPNOTSUPP; | ||
417 | else | ||
418 | *ops_result = 0; | ||
419 | } | ||
420 | |||
421 | if (dlm_config.ci_recover_callbacks && cluster && | ||
422 | strncmp(cluster, dlm_config.ci_cluster_name, DLM_LOCKSPACE_LEN)) { | ||
423 | log_print("dlm cluster name %s mismatch %s", | ||
424 | dlm_config.ci_cluster_name, cluster); | ||
425 | error = -EBADR; | ||
426 | goto out; | ||
408 | } | 427 | } |
409 | 428 | ||
410 | error = 0; | 429 | error = 0; |
@@ -442,6 +461,11 @@ static int new_lockspace(const char *name, int namelen, void **lockspace, | |||
442 | ls->ls_flags = 0; | 461 | ls->ls_flags = 0; |
443 | ls->ls_scan_time = jiffies; | 462 | ls->ls_scan_time = jiffies; |
444 | 463 | ||
464 | if (ops && dlm_config.ci_recover_callbacks) { | ||
465 | ls->ls_ops = ops; | ||
466 | ls->ls_ops_arg = ops_arg; | ||
467 | } | ||
468 | |||
445 | if (flags & DLM_LSFL_TIMEWARN) | 469 | if (flags & DLM_LSFL_TIMEWARN) |
446 | set_bit(LSFL_TIMEWARN, &ls->ls_flags); | 470 | set_bit(LSFL_TIMEWARN, &ls->ls_flags); |
447 | 471 | ||
@@ -619,8 +643,10 @@ static int new_lockspace(const char *name, int namelen, void **lockspace, | |||
619 | return error; | 643 | return error; |
620 | } | 644 | } |
621 | 645 | ||
622 | int dlm_new_lockspace(const char *name, int namelen, void **lockspace, | 646 | int dlm_new_lockspace(const char *name, const char *cluster, |
623 | uint32_t flags, int lvblen) | 647 | uint32_t flags, int lvblen, |
648 | const struct dlm_lockspace_ops *ops, void *ops_arg, | ||
649 | int *ops_result, dlm_lockspace_t **lockspace) | ||
624 | { | 650 | { |
625 | int error = 0; | 651 | int error = 0; |
626 | 652 | ||
@@ -630,7 +656,8 @@ int dlm_new_lockspace(const char *name, int namelen, void **lockspace, | |||
630 | if (error) | 656 | if (error) |
631 | goto out; | 657 | goto out; |
632 | 658 | ||
633 | error = new_lockspace(name, namelen, lockspace, flags, lvblen); | 659 | error = new_lockspace(name, cluster, flags, lvblen, ops, ops_arg, |
660 | ops_result, lockspace); | ||
634 | if (!error) | 661 | if (!error) |
635 | ls_count++; | 662 | ls_count++; |
636 | if (error > 0) | 663 | if (error > 0) |
diff --git a/fs/dlm/member.c b/fs/dlm/member.c index eebc52aae82e..862640a36d5c 100644 --- a/fs/dlm/member.c +++ b/fs/dlm/member.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) 2005-2009 Red Hat, Inc. All rights reserved. | 4 | ** Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This copyrighted material is made available to anyone wishing to use, | 6 | ** This copyrighted material is made available to anyone wishing to use, |
7 | ** modify, copy, or redistribute it subject to the terms and conditions | 7 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -27,7 +27,7 @@ int dlm_slots_version(struct dlm_header *h) | |||
27 | } | 27 | } |
28 | 28 | ||
29 | void dlm_slot_save(struct dlm_ls *ls, struct dlm_rcom *rc, | 29 | void dlm_slot_save(struct dlm_ls *ls, struct dlm_rcom *rc, |
30 | struct dlm_member *memb) | 30 | struct dlm_member *memb) |
31 | { | 31 | { |
32 | struct rcom_config *rf = (struct rcom_config *)rc->rc_buf; | 32 | struct rcom_config *rf = (struct rcom_config *)rc->rc_buf; |
33 | 33 | ||
@@ -317,59 +317,51 @@ static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new) | |||
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | static int dlm_add_member(struct dlm_ls *ls, int nodeid) | 320 | static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node) |
321 | { | 321 | { |
322 | struct dlm_member *memb; | 322 | struct dlm_member *memb; |
323 | int w, error; | 323 | int error; |
324 | 324 | ||
325 | memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS); | 325 | memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS); |
326 | if (!memb) | 326 | if (!memb) |
327 | return -ENOMEM; | 327 | return -ENOMEM; |
328 | 328 | ||
329 | w = dlm_node_weight(ls->ls_name, nodeid); | 329 | error = dlm_lowcomms_connect_node(node->nodeid); |
330 | if (w < 0) { | ||
331 | kfree(memb); | ||
332 | return w; | ||
333 | } | ||
334 | |||
335 | error = dlm_lowcomms_connect_node(nodeid); | ||
336 | if (error < 0) { | 330 | if (error < 0) { |
337 | kfree(memb); | 331 | kfree(memb); |
338 | return error; | 332 | return error; |
339 | } | 333 | } |
340 | 334 | ||
341 | memb->nodeid = nodeid; | 335 | memb->nodeid = node->nodeid; |
342 | memb->weight = w; | 336 | memb->weight = node->weight; |
337 | memb->comm_seq = node->comm_seq; | ||
343 | add_ordered_member(ls, memb); | 338 | add_ordered_member(ls, memb); |
344 | ls->ls_num_nodes++; | 339 | ls->ls_num_nodes++; |
345 | return 0; | 340 | return 0; |
346 | } | 341 | } |
347 | 342 | ||
348 | static void dlm_remove_member(struct dlm_ls *ls, struct dlm_member *memb) | 343 | static struct dlm_member *find_memb(struct list_head *head, int nodeid) |
349 | { | ||
350 | list_move(&memb->list, &ls->ls_nodes_gone); | ||
351 | ls->ls_num_nodes--; | ||
352 | } | ||
353 | |||
354 | int dlm_is_member(struct dlm_ls *ls, int nodeid) | ||
355 | { | 344 | { |
356 | struct dlm_member *memb; | 345 | struct dlm_member *memb; |
357 | 346 | ||
358 | list_for_each_entry(memb, &ls->ls_nodes, list) { | 347 | list_for_each_entry(memb, head, list) { |
359 | if (memb->nodeid == nodeid) | 348 | if (memb->nodeid == nodeid) |
360 | return 1; | 349 | return memb; |
361 | } | 350 | } |
351 | return NULL; | ||
352 | } | ||
353 | |||
354 | int dlm_is_member(struct dlm_ls *ls, int nodeid) | ||
355 | { | ||
356 | if (find_memb(&ls->ls_nodes, nodeid)) | ||
357 | return 1; | ||
362 | return 0; | 358 | return 0; |
363 | } | 359 | } |
364 | 360 | ||
365 | int dlm_is_removed(struct dlm_ls *ls, int nodeid) | 361 | int dlm_is_removed(struct dlm_ls *ls, int nodeid) |
366 | { | 362 | { |
367 | struct dlm_member *memb; | 363 | if (find_memb(&ls->ls_nodes_gone, nodeid)) |
368 | 364 | return 1; | |
369 | list_for_each_entry(memb, &ls->ls_nodes_gone, list) { | ||
370 | if (memb->nodeid == nodeid) | ||
371 | return 1; | ||
372 | } | ||
373 | return 0; | 365 | return 0; |
374 | } | 366 | } |
375 | 367 | ||
@@ -460,10 +452,88 @@ static int ping_members(struct dlm_ls *ls) | |||
460 | return error; | 452 | return error; |
461 | } | 453 | } |
462 | 454 | ||
455 | static void dlm_lsop_recover_prep(struct dlm_ls *ls) | ||
456 | { | ||
457 | if (!ls->ls_ops || !ls->ls_ops->recover_prep) | ||
458 | return; | ||
459 | ls->ls_ops->recover_prep(ls->ls_ops_arg); | ||
460 | } | ||
461 | |||
462 | static void dlm_lsop_recover_slot(struct dlm_ls *ls, struct dlm_member *memb) | ||
463 | { | ||
464 | struct dlm_slot slot; | ||
465 | uint32_t seq; | ||
466 | int error; | ||
467 | |||
468 | if (!ls->ls_ops || !ls->ls_ops->recover_slot) | ||
469 | return; | ||
470 | |||
471 | /* if there is no comms connection with this node | ||
472 | or the present comms connection is newer | ||
473 | than the one when this member was added, then | ||
474 | we consider the node to have failed (versus | ||
475 | being removed due to dlm_release_lockspace) */ | ||
476 | |||
477 | error = dlm_comm_seq(memb->nodeid, &seq); | ||
478 | |||
479 | if (!error && seq == memb->comm_seq) | ||
480 | return; | ||
481 | |||
482 | slot.nodeid = memb->nodeid; | ||
483 | slot.slot = memb->slot; | ||
484 | |||
485 | ls->ls_ops->recover_slot(ls->ls_ops_arg, &slot); | ||
486 | } | ||
487 | |||
488 | void dlm_lsop_recover_done(struct dlm_ls *ls) | ||
489 | { | ||
490 | struct dlm_member *memb; | ||
491 | struct dlm_slot *slots; | ||
492 | int i, num; | ||
493 | |||
494 | if (!ls->ls_ops || !ls->ls_ops->recover_done) | ||
495 | return; | ||
496 | |||
497 | num = ls->ls_num_nodes; | ||
498 | |||
499 | slots = kzalloc(num * sizeof(struct dlm_slot), GFP_KERNEL); | ||
500 | if (!slots) | ||
501 | return; | ||
502 | |||
503 | i = 0; | ||
504 | list_for_each_entry(memb, &ls->ls_nodes, list) { | ||
505 | if (i == num) { | ||
506 | log_error(ls, "dlm_lsop_recover_done bad num %d", num); | ||
507 | goto out; | ||
508 | } | ||
509 | slots[i].nodeid = memb->nodeid; | ||
510 | slots[i].slot = memb->slot; | ||
511 | i++; | ||
512 | } | ||
513 | |||
514 | ls->ls_ops->recover_done(ls->ls_ops_arg, slots, num, | ||
515 | ls->ls_slot, ls->ls_generation); | ||
516 | out: | ||
517 | kfree(slots); | ||
518 | } | ||
519 | |||
520 | static struct dlm_config_node *find_config_node(struct dlm_recover *rv, | ||
521 | int nodeid) | ||
522 | { | ||
523 | int i; | ||
524 | |||
525 | for (i = 0; i < rv->nodes_count; i++) { | ||
526 | if (rv->nodes[i].nodeid == nodeid) | ||
527 | return &rv->nodes[i]; | ||
528 | } | ||
529 | return NULL; | ||
530 | } | ||
531 | |||
463 | int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) | 532 | int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) |
464 | { | 533 | { |
465 | struct dlm_member *memb, *safe; | 534 | struct dlm_member *memb, *safe; |
466 | int i, error, found, pos = 0, neg = 0, low = -1; | 535 | struct dlm_config_node *node; |
536 | int i, error, neg = 0, low = -1; | ||
467 | 537 | ||
468 | /* previously removed members that we've not finished removing need to | 538 | /* previously removed members that we've not finished removing need to |
469 | count as a negative change so the "neg" recovery steps will happen */ | 539 | count as a negative change so the "neg" recovery steps will happen */ |
@@ -476,46 +546,32 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) | |||
476 | /* move departed members from ls_nodes to ls_nodes_gone */ | 546 | /* move departed members from ls_nodes to ls_nodes_gone */ |
477 | 547 | ||
478 | list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) { | 548 | list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) { |
479 | found = 0; | 549 | node = find_config_node(rv, memb->nodeid); |
480 | for (i = 0; i < rv->node_count; i++) { | 550 | if (node && !node->new) |
481 | if (memb->nodeid == rv->nodeids[i]) { | 551 | continue; |
482 | found = 1; | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | 552 | ||
487 | if (!found) { | 553 | if (!node) { |
488 | neg++; | ||
489 | dlm_remove_member(ls, memb); | ||
490 | log_debug(ls, "remove member %d", memb->nodeid); | 554 | log_debug(ls, "remove member %d", memb->nodeid); |
555 | } else { | ||
556 | /* removed and re-added */ | ||
557 | log_debug(ls, "remove member %d comm_seq %u %u", | ||
558 | memb->nodeid, memb->comm_seq, node->comm_seq); | ||
491 | } | 559 | } |
492 | } | ||
493 | |||
494 | /* Add an entry to ls_nodes_gone for members that were removed and | ||
495 | then added again, so that previous state for these nodes will be | ||
496 | cleared during recovery. */ | ||
497 | 560 | ||
498 | for (i = 0; i < rv->new_count; i++) { | ||
499 | if (!dlm_is_member(ls, rv->new[i])) | ||
500 | continue; | ||
501 | log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]); | ||
502 | |||
503 | memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS); | ||
504 | if (!memb) | ||
505 | return -ENOMEM; | ||
506 | memb->nodeid = rv->new[i]; | ||
507 | list_add_tail(&memb->list, &ls->ls_nodes_gone); | ||
508 | neg++; | 561 | neg++; |
562 | list_move(&memb->list, &ls->ls_nodes_gone); | ||
563 | ls->ls_num_nodes--; | ||
564 | dlm_lsop_recover_slot(ls, memb); | ||
509 | } | 565 | } |
510 | 566 | ||
511 | /* add new members to ls_nodes */ | 567 | /* add new members to ls_nodes */ |
512 | 568 | ||
513 | for (i = 0; i < rv->node_count; i++) { | 569 | for (i = 0; i < rv->nodes_count; i++) { |
514 | if (dlm_is_member(ls, rv->nodeids[i])) | 570 | node = &rv->nodes[i]; |
571 | if (dlm_is_member(ls, node->nodeid)) | ||
515 | continue; | 572 | continue; |
516 | dlm_add_member(ls, rv->nodeids[i]); | 573 | dlm_add_member(ls, node); |
517 | pos++; | 574 | log_debug(ls, "add member %d", node->nodeid); |
518 | log_debug(ls, "add member %d", rv->nodeids[i]); | ||
519 | } | 575 | } |
520 | 576 | ||
521 | list_for_each_entry(memb, &ls->ls_nodes, list) { | 577 | list_for_each_entry(memb, &ls->ls_nodes, list) { |
@@ -609,21 +665,22 @@ int dlm_ls_stop(struct dlm_ls *ls) | |||
609 | 665 | ||
610 | if (!ls->ls_recover_begin) | 666 | if (!ls->ls_recover_begin) |
611 | ls->ls_recover_begin = jiffies; | 667 | ls->ls_recover_begin = jiffies; |
668 | |||
669 | dlm_lsop_recover_prep(ls); | ||
612 | return 0; | 670 | return 0; |
613 | } | 671 | } |
614 | 672 | ||
615 | int dlm_ls_start(struct dlm_ls *ls) | 673 | int dlm_ls_start(struct dlm_ls *ls) |
616 | { | 674 | { |
617 | struct dlm_recover *rv = NULL, *rv_old; | 675 | struct dlm_recover *rv = NULL, *rv_old; |
618 | int *ids = NULL, *new = NULL; | 676 | struct dlm_config_node *nodes; |
619 | int error, ids_count = 0, new_count = 0; | 677 | int error, count; |
620 | 678 | ||
621 | rv = kzalloc(sizeof(struct dlm_recover), GFP_NOFS); | 679 | rv = kzalloc(sizeof(struct dlm_recover), GFP_NOFS); |
622 | if (!rv) | 680 | if (!rv) |
623 | return -ENOMEM; | 681 | return -ENOMEM; |
624 | 682 | ||
625 | error = dlm_nodeid_list(ls->ls_name, &ids, &ids_count, | 683 | error = dlm_config_nodes(ls->ls_name, &nodes, &count); |
626 | &new, &new_count); | ||
627 | if (error < 0) | 684 | if (error < 0) |
628 | goto fail; | 685 | goto fail; |
629 | 686 | ||
@@ -638,10 +695,8 @@ int dlm_ls_start(struct dlm_ls *ls) | |||
638 | goto fail; | 695 | goto fail; |
639 | } | 696 | } |
640 | 697 | ||
641 | rv->nodeids = ids; | 698 | rv->nodes = nodes; |
642 | rv->node_count = ids_count; | 699 | rv->nodes_count = count; |
643 | rv->new = new; | ||
644 | rv->new_count = new_count; | ||
645 | rv->seq = ++ls->ls_recover_seq; | 700 | rv->seq = ++ls->ls_recover_seq; |
646 | rv_old = ls->ls_recover_args; | 701 | rv_old = ls->ls_recover_args; |
647 | ls->ls_recover_args = rv; | 702 | ls->ls_recover_args = rv; |
@@ -649,9 +704,8 @@ int dlm_ls_start(struct dlm_ls *ls) | |||
649 | 704 | ||
650 | if (rv_old) { | 705 | if (rv_old) { |
651 | log_error(ls, "unused recovery %llx %d", | 706 | log_error(ls, "unused recovery %llx %d", |
652 | (unsigned long long)rv_old->seq, rv_old->node_count); | 707 | (unsigned long long)rv_old->seq, rv_old->nodes_count); |
653 | kfree(rv_old->nodeids); | 708 | kfree(rv_old->nodes); |
654 | kfree(rv_old->new); | ||
655 | kfree(rv_old); | 709 | kfree(rv_old); |
656 | } | 710 | } |
657 | 711 | ||
@@ -660,8 +714,7 @@ int dlm_ls_start(struct dlm_ls *ls) | |||
660 | 714 | ||
661 | fail: | 715 | fail: |
662 | kfree(rv); | 716 | kfree(rv); |
663 | kfree(ids); | 717 | kfree(nodes); |
664 | kfree(new); | ||
665 | return error; | 718 | return error; |
666 | } | 719 | } |
667 | 720 | ||
diff --git a/fs/dlm/member.h b/fs/dlm/member.h index 7e87e8a79dfd..3deb70661c69 100644 --- a/fs/dlm/member.h +++ b/fs/dlm/member.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. | 4 | ** Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This copyrighted material is made available to anyone wishing to use, | 6 | ** This copyrighted material is made available to anyone wishing to use, |
7 | ** modify, copy, or redistribute it subject to the terms and conditions | 7 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -27,6 +27,7 @@ void dlm_slots_copy_out(struct dlm_ls *ls, struct dlm_rcom *rc); | |||
27 | int dlm_slots_copy_in(struct dlm_ls *ls); | 27 | int dlm_slots_copy_in(struct dlm_ls *ls); |
28 | int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size, | 28 | int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size, |
29 | struct dlm_slot **slots_out, uint32_t *gen_out); | 29 | struct dlm_slot **slots_out, uint32_t *gen_out); |
30 | void dlm_lsop_recover_done(struct dlm_ls *ls); | ||
30 | 31 | ||
31 | #endif /* __MEMBER_DOT_H__ */ | 32 | #endif /* __MEMBER_DOT_H__ */ |
32 | 33 | ||
diff --git a/fs/dlm/recoverd.c b/fs/dlm/recoverd.c index 5a9e1a49a860..3780caf7ae0c 100644 --- a/fs/dlm/recoverd.c +++ b/fs/dlm/recoverd.c | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -227,11 +227,12 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv) | |||
227 | 227 | ||
228 | dlm_grant_after_purge(ls); | 228 | dlm_grant_after_purge(ls); |
229 | 229 | ||
230 | log_debug(ls, "dlm_recover %llx done: %u ms", | 230 | log_debug(ls, "dlm_recover %llx generation %u done: %u ms", |
231 | (unsigned long long)rv->seq, | 231 | (unsigned long long)rv->seq, ls->ls_generation, |
232 | jiffies_to_msecs(jiffies - start)); | 232 | jiffies_to_msecs(jiffies - start)); |
233 | mutex_unlock(&ls->ls_recoverd_active); | 233 | mutex_unlock(&ls->ls_recoverd_active); |
234 | 234 | ||
235 | dlm_lsop_recover_done(ls); | ||
235 | return 0; | 236 | return 0; |
236 | 237 | ||
237 | fail: | 238 | fail: |
@@ -259,8 +260,7 @@ static void do_ls_recovery(struct dlm_ls *ls) | |||
259 | 260 | ||
260 | if (rv) { | 261 | if (rv) { |
261 | ls_recover(ls, rv); | 262 | ls_recover(ls, rv); |
262 | kfree(rv->nodeids); | 263 | kfree(rv->nodes); |
263 | kfree(rv->new); | ||
264 | kfree(rv); | 264 | kfree(rv); |
265 | } | 265 | } |
266 | } | 266 | } |
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index d8ea60756403..eb4ed9ba3098 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -392,8 +392,9 @@ static int device_create_lockspace(struct dlm_lspace_params *params) | |||
392 | if (!capable(CAP_SYS_ADMIN)) | 392 | if (!capable(CAP_SYS_ADMIN)) |
393 | return -EPERM; | 393 | return -EPERM; |
394 | 394 | ||
395 | error = dlm_new_lockspace(params->name, strlen(params->name), | 395 | error = dlm_new_lockspace(params->name, NULL, params->flags, |
396 | &lockspace, params->flags, DLM_USER_LVB_LEN); | 396 | DLM_USER_LVB_LEN, NULL, NULL, NULL, |
397 | &lockspace); | ||
397 | if (error) | 398 | if (error) |
398 | return error; | 399 | return error; |
399 | 400 | ||
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index 98c80d8c2a62..ce85b62bc0a2 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c | |||
@@ -195,10 +195,10 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *fsname) | |||
195 | return -EINVAL; | 195 | return -EINVAL; |
196 | } | 196 | } |
197 | 197 | ||
198 | error = dlm_new_lockspace(fsname, strlen(fsname), &ls->ls_dlm, | 198 | error = dlm_new_lockspace(fsname, NULL, |
199 | DLM_LSFL_FS | DLM_LSFL_NEWEXCL | | 199 | DLM_LSFL_FS | DLM_LSFL_NEWEXCL | |
200 | (ls->ls_nodir ? DLM_LSFL_NODIR : 0), | 200 | (ls->ls_nodir ? DLM_LSFL_NODIR : 0), |
201 | GDLM_LVB_SIZE); | 201 | GDLM_LVB_SIZE, NULL, NULL, NULL, &ls->ls_dlm); |
202 | if (error) | 202 | if (error) |
203 | printk(KERN_ERR "dlm_new_lockspace error %d", error); | 203 | printk(KERN_ERR "dlm_new_lockspace error %d", error); |
204 | 204 | ||
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index a5ebe421195f..286edf1e231f 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -827,8 +827,8 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) | |||
827 | goto out; | 827 | goto out; |
828 | } | 828 | } |
829 | 829 | ||
830 | rc = dlm_new_lockspace(conn->cc_name, strlen(conn->cc_name), | 830 | rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN, |
831 | &fsdlm, DLM_LSFL_FS, DLM_LVB_LEN); | 831 | NULL, NULL, NULL, &fsdlm); |
832 | if (rc) { | 832 | if (rc) { |
833 | ocfs2_live_connection_drop(control); | 833 | ocfs2_live_connection_drop(control); |
834 | goto out; | 834 | goto out; |
diff --git a/include/linux/dlm.h b/include/linux/dlm.h index d4e02f5353a0..6c7f6e9546c7 100644 --- a/include/linux/dlm.h +++ b/include/linux/dlm.h | |||
@@ -2,7 +2,7 @@ | |||
2 | ******************************************************************************* | 2 | ******************************************************************************* |
3 | ** | 3 | ** |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
5 | ** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. | 5 | ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. |
6 | ** | 6 | ** |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
@@ -74,15 +74,76 @@ struct dlm_lksb { | |||
74 | 74 | ||
75 | #ifdef __KERNEL__ | 75 | #ifdef __KERNEL__ |
76 | 76 | ||
77 | struct dlm_slot { | ||
78 | int nodeid; /* 1 to MAX_INT */ | ||
79 | int slot; /* 1 to MAX_INT */ | ||
80 | }; | ||
81 | |||
82 | /* | ||
83 | * recover_prep: called before the dlm begins lock recovery. | ||
84 | * Notfies lockspace user that locks from failed members will be granted. | ||
85 | * recover_slot: called after recover_prep and before recover_done. | ||
86 | * Identifies a failed lockspace member. | ||
87 | * recover_done: called after the dlm completes lock recovery. | ||
88 | * Identifies lockspace members and lockspace generation number. | ||
89 | */ | ||
90 | |||
91 | struct dlm_lockspace_ops { | ||
92 | void (*recover_prep) (void *ops_arg); | ||
93 | void (*recover_slot) (void *ops_arg, struct dlm_slot *slot); | ||
94 | void (*recover_done) (void *ops_arg, struct dlm_slot *slots, | ||
95 | int num_slots, int our_slot, uint32_t generation); | ||
96 | }; | ||
97 | |||
77 | /* | 98 | /* |
78 | * dlm_new_lockspace | 99 | * dlm_new_lockspace |
79 | * | 100 | * |
80 | * Starts a lockspace with the given name. If the named lockspace exists in | 101 | * Create/join a lockspace. |
81 | * the cluster, the calling node joins it. | 102 | * |
103 | * name: lockspace name, null terminated, up to DLM_LOCKSPACE_LEN (not | ||
104 | * including terminating null). | ||
105 | * | ||
106 | * cluster: cluster name, null terminated, up to DLM_LOCKSPACE_LEN (not | ||
107 | * including terminating null). Optional. When cluster is null, it | ||
108 | * is not used. When set, dlm_new_lockspace() returns -EBADR if cluster | ||
109 | * is not equal to the dlm cluster name. | ||
110 | * | ||
111 | * flags: | ||
112 | * DLM_LSFL_NODIR | ||
113 | * The dlm should not use a resource directory, but statically assign | ||
114 | * resource mastery to nodes based on the name hash that is otherwise | ||
115 | * used to select the directory node. Must be the same on all nodes. | ||
116 | * DLM_LSFL_TIMEWARN | ||
117 | * The dlm should emit netlink messages if locks have been waiting | ||
118 | * for a configurable amount of time. (Unused.) | ||
119 | * DLM_LSFL_FS | ||
120 | * The lockspace user is in the kernel (i.e. filesystem). Enables | ||
121 | * direct bast/cast callbacks. | ||
122 | * DLM_LSFL_NEWEXCL | ||
123 | * dlm_new_lockspace() should return -EEXIST if the lockspace exists. | ||
124 | * | ||
125 | * lvblen: length of lvb in bytes. Must be multiple of 8. | ||
126 | * dlm_new_lockspace() returns an error if this does not match | ||
127 | * what other nodes are using. | ||
128 | * | ||
129 | * ops: callbacks that indicate lockspace recovery points so the | ||
130 | * caller can coordinate its recovery and know lockspace members. | ||
131 | * This is only used by the initial dlm_new_lockspace() call. | ||
132 | * Optional. | ||
133 | * | ||
134 | * ops_arg: arg for ops callbacks. | ||
135 | * | ||
136 | * ops_result: tells caller if the ops callbacks (if provided) will | ||
137 | * be used or not. 0: will be used, -EXXX will not be used. | ||
138 | * -EOPNOTSUPP: the dlm does not have recovery_callbacks enabled. | ||
139 | * | ||
140 | * lockspace: handle for dlm functions | ||
82 | */ | 141 | */ |
83 | 142 | ||
84 | int dlm_new_lockspace(const char *name, int namelen, | 143 | int dlm_new_lockspace(const char *name, const char *cluster, |
85 | dlm_lockspace_t **lockspace, uint32_t flags, int lvblen); | 144 | uint32_t flags, int lvblen, |
145 | const struct dlm_lockspace_ops *ops, void *ops_arg, | ||
146 | int *ops_result, dlm_lockspace_t **lockspace); | ||
86 | 147 | ||
87 | /* | 148 | /* |
88 | * dlm_release_lockspace | 149 | * dlm_release_lockspace |