From: Li Xi Date: Wed, 24 Jul 2013 03:33:05 +0000 (-0700) Subject: LU-3611 quota: Fix order of locking and allocating memory. X-Git-Tag: 2.4.53~37 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f4caf6de3ecff7f72fdf6b804da30823c4d0979d;hp=6350af100c204a4db794e7472951ab72c3bc20ef LU-3611 quota: Fix order of locking and allocating memory. mgs_pool_cmd() locks fsdb_mutex and then allocates mti. It will leave fsdb_mutex locked if it fails to allocate memory. This patch fixes the problem. Signed-off-by: Li Xi Change-Id: I10f92522c509052916a7d7134d73c4923cfaf33e Reviewed-on: http://review.whamcloud.com/7065 Reviewed-by: Keith Mannthey Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index baaec4a..1d4f58c 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -3887,14 +3887,13 @@ int mgs_pool_cmd(const struct lu_env *env, struct mgs_device *mgs, break; } - mutex_lock(&fsdb->fsdb_mutex); - if (canceled_label != NULL) { OBD_ALLOC_PTR(mti); if (mti == NULL) GOTO(out_cancel, rc = -ENOMEM); } + mutex_lock(&fsdb->fsdb_mutex); /* write pool def to all MDT logs */ for (i = 0; i < INDEX_MAP_SIZE * 8; i++) { if (test_bit(i, fsdb->fsdb_mdt_index_map)) {