10
10
* This program is free software; you can redistribute it and/or
11
11
* modify it under the terms of the GNU General Public
12
12
* License, version 2, as published by the Free Software Foundation.
14
14
* This program is distributed in the hope that it will be useful,
15
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
17
* General Public License for more details.
19
19
* You should have received a copy of the GNU General Public
20
20
* License along with this program; if not, write to the
21
21
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
104
errcode_t ocfs2_initialize_dlm(ocfs2_filesys *fs)
104
errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
105
struct o2cb_cluster_desc *desc)
108
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
110
if (!ocfs2_userspace_stack(sb)) {
111
desc->c_stack = NULL;
112
desc->c_cluster = NULL;
116
ret = ocfs2_malloc0(OCFS2_STACK_LABEL_LEN + 1, &desc->c_stack);
120
ret = ocfs2_malloc0(OCFS2_CLUSTER_NAME_LEN + 1, &desc->c_cluster);
122
ocfs2_free(&desc->c_stack);
126
memcpy(desc->c_stack, sb->s_cluster_info.ci_stack,
127
OCFS2_STACK_LABEL_LEN);
128
memcpy(desc->c_cluster, sb->s_cluster_info.ci_cluster,
129
OCFS2_CLUSTER_NAME_LEN);
134
errcode_t ocfs2_set_cluster_desc(ocfs2_filesys *fs,
135
struct o2cb_cluster_desc *desc)
138
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
141
if (!desc->c_stack[0] || !desc->c_cluster ||
142
!desc->c_cluster[0]) {
143
ret = OCFS2_ET_INVALID_ARGUMENT;
147
if (!ocfs2_uses_extended_slot_map(sb)) {
148
sb->s_feature_incompat |=
149
OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP;
150
ret = ocfs2_format_slot_map(fs);
154
sb->s_feature_incompat |=
155
OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
156
memcpy(sb->s_cluster_info.ci_stack, desc->c_stack,
157
OCFS2_STACK_LABEL_LEN);
158
memcpy(sb->s_cluster_info.ci_cluster, desc->c_cluster,
159
OCFS2_CLUSTER_NAME_LEN);
161
sb->s_feature_incompat &=
162
~OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
165
ret = ocfs2_write_super(fs);
171
errcode_t ocfs2_initialize_dlm(ocfs2_filesys *fs, const char *service)
106
173
struct o2dlm_ctxt *dlm_ctxt = NULL;
107
174
errcode_t ret = 0;
109
ret = ocfs2_start_heartbeat(fs);
113
ret = o2dlm_initialize(DEFAULT_DLMFS_PATH, fs->uuid_str, &dlm_ctxt);
175
struct o2cb_cluster_desc cluster;
176
struct o2cb_region_desc desc;
179
ret = ocfs2_fill_cluster_desc(fs, &cluster);
183
ret = ocfs2_fill_heartbeat_desc(fs, &desc);
187
desc.r_service = (char *)service;
189
ret = o2cb_begin_group_join(&cluster, &desc);
194
* NULL c_stack means o2cb, means use DLMFS, means
195
* pass DLMFS_PATH. If we're using a userspace stack, pass NULL.
200
stack_path = DEFAULT_DLMFS_PATH;
201
ret = o2dlm_initialize(stack_path, fs->uuid_str, &dlm_ctxt);
115
203
/* What to do with an error code? */
116
ocfs2_stop_heartbeat(fs);
205
/* Ignore the result of complete_group_join, as we want
206
* to propagate our o2dlm_initialize() error */
207
o2cb_complete_group_join(&cluster, &desc, ret);
120
fs->fs_dlm_ctxt = dlm_ctxt;
211
ret = o2cb_complete_group_join(&cluster, &desc, 0);
214
fs->fs_dlm_ctxt = dlm_ctxt;
216
o2dlm_destroy(dlm_ctxt);
126
errcode_t ocfs2_shutdown_dlm(ocfs2_filesys *fs)
222
errcode_t ocfs2_shutdown_dlm(ocfs2_filesys *fs, const char *service)
225
struct o2cb_cluster_desc cluster;
226
struct o2cb_region_desc desc;
130
228
ret = o2dlm_destroy(fs->fs_dlm_ctxt);