aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/stack_user.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 4111855a4def..0afb86d9b279 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -200,15 +200,10 @@ static struct ocfs2_live_connection *ocfs2_connection_find(const char *name)
200 * mount path. Since the VFS prevents multiple calls to 200 * mount path. Since the VFS prevents multiple calls to
201 * fill_super(), we can't get dupes here. 201 * fill_super(), we can't get dupes here.
202 */ 202 */
203static int ocfs2_live_connection_new(struct ocfs2_cluster_connection *conn, 203static int ocfs2_live_connection_attach(struct ocfs2_cluster_connection *conn,
204 struct ocfs2_live_connection **c_ret) 204 struct ocfs2_live_connection *c)
205{ 205{
206 int rc = 0; 206 int rc = 0;
207 struct ocfs2_live_connection *c;
208
209 c = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL);
210 if (!c)
211 return -ENOMEM;
212 207
213 mutex_lock(&ocfs2_control_lock); 208 mutex_lock(&ocfs2_control_lock);
214 c->oc_conn = conn; 209 c->oc_conn = conn;
@@ -222,12 +217,6 @@ static int ocfs2_live_connection_new(struct ocfs2_cluster_connection *conn,
222 } 217 }
223 218
224 mutex_unlock(&ocfs2_control_lock); 219 mutex_unlock(&ocfs2_control_lock);
225
226 if (!rc)
227 *c_ret = c;
228 else
229 kfree(c);
230
231 return rc; 220 return rc;
232} 221}
233 222
@@ -840,12 +829,18 @@ const struct dlm_lockspace_ops ocfs2_ls_ops = {
840static int user_cluster_connect(struct ocfs2_cluster_connection *conn) 829static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
841{ 830{
842 dlm_lockspace_t *fsdlm; 831 dlm_lockspace_t *fsdlm;
843 struct ocfs2_live_connection *uninitialized_var(control); 832 struct ocfs2_live_connection *lc;
844 int rc = 0; 833 int rc;
845 834
846 BUG_ON(conn == NULL); 835 BUG_ON(conn == NULL);
847 836
848 rc = ocfs2_live_connection_new(conn, &control); 837 lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL);
838 if (!lc) {
839 rc = -ENOMEM;
840 goto out;
841 }
842
843 rc = ocfs2_live_connection_attach(conn, lc);
849 if (rc) 844 if (rc)
850 goto out; 845 goto out;
851 846
@@ -861,20 +856,24 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
861 conn->cc_version.pv_major, conn->cc_version.pv_minor, 856 conn->cc_version.pv_major, conn->cc_version.pv_minor,
862 running_proto.pv_major, running_proto.pv_minor); 857 running_proto.pv_major, running_proto.pv_minor);
863 rc = -EPROTO; 858 rc = -EPROTO;
864 ocfs2_live_connection_drop(control); 859 ocfs2_live_connection_drop(lc);
860 lc = NULL;
865 goto out; 861 goto out;
866 } 862 }
867 863
868 rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN, 864 rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
869 NULL, NULL, NULL, &fsdlm); 865 NULL, NULL, NULL, &fsdlm);
870 if (rc) { 866 if (rc) {
871 ocfs2_live_connection_drop(control); 867 ocfs2_live_connection_drop(lc);
868 lc = NULL;
872 goto out; 869 goto out;
873 } 870 }
874 871
875 conn->cc_private = control; 872 conn->cc_private = lc;
876 conn->cc_lockspace = fsdlm; 873 conn->cc_lockspace = fsdlm;
877out: 874out:
875 if (rc && lc)
876 kfree(lc);
878 return rc; 877 return rc;
879} 878}
880 879