Skip to content

Commit 24aa338

Browse files
Goldwyn Rodriguestorvalds
authored andcommitted
ocfs2: shift allocation ocfs2_live_connection to user_connect()
We perform this because the DLM recovery callbacks will require the ocfs2_live_connection structure to record the node information when dlm_new_lockspace() is updated (in the last patch of the series). Before calling dlm_new_lockspace(), we need the structure ready for the .recover_done() callback, which would set oc_this_node. This is the reason we allocate ocfs2_live_connection beforehand in user_connect(). [AKPM] rc initialization is not required because it assigned in case of errors. It will be cleared by compiler anyways. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reveiwed-by: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 66e188f commit 24aa338

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

fs/ocfs2/stack_user.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,10 @@ static struct ocfs2_live_connection *ocfs2_connection_find(const char *name)
200200
* mount path. Since the VFS prevents multiple calls to
201201
* fill_super(), we can't get dupes here.
202202
*/
203-
static int ocfs2_live_connection_new(struct ocfs2_cluster_connection *conn,
204-
struct ocfs2_live_connection **c_ret)
203+
static int ocfs2_live_connection_attach(struct ocfs2_cluster_connection *conn,
204+
struct ocfs2_live_connection *c)
205205
{
206206
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;
212207

213208
mutex_lock(&ocfs2_control_lock);
214209
c->oc_conn = conn;
@@ -222,12 +217,6 @@ static int ocfs2_live_connection_new(struct ocfs2_cluster_connection *conn,
222217
}
223218

224219
mutex_unlock(&ocfs2_control_lock);
225-
226-
if (!rc)
227-
*c_ret = c;
228-
else
229-
kfree(c);
230-
231220
return rc;
232221
}
233222

@@ -840,12 +829,18 @@ const struct dlm_lockspace_ops ocfs2_ls_ops = {
840829
static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
841830
{
842831
dlm_lockspace_t *fsdlm;
843-
struct ocfs2_live_connection *uninitialized_var(control);
844-
int rc = 0;
832+
struct ocfs2_live_connection *lc;
833+
int rc;
845834

846835
BUG_ON(conn == NULL);
847836

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);
849844
if (rc)
850845
goto out;
851846

@@ -861,20 +856,24 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
861856
conn->cc_version.pv_major, conn->cc_version.pv_minor,
862857
running_proto.pv_major, running_proto.pv_minor);
863858
rc = -EPROTO;
864-
ocfs2_live_connection_drop(control);
859+
ocfs2_live_connection_drop(lc);
860+
lc = NULL;
865861
goto out;
866862
}
867863

868864
rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
869865
NULL, NULL, NULL, &fsdlm);
870866
if (rc) {
871-
ocfs2_live_connection_drop(control);
867+
ocfs2_live_connection_drop(lc);
868+
lc = NULL;
872869
goto out;
873870
}
874871

875-
conn->cc_private = control;
872+
conn->cc_private = lc;
876873
conn->cc_lockspace = fsdlm;
877874
out:
875+
if (rc && lc)
876+
kfree(lc);
878877
return rc;
879878
}
880879

0 commit comments

Comments
 (0)