From b184fbf41abbdd68ee148ea4dc6fc2969f05e87b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 28 Dec 2015 17:47:46 +0000 Subject: [PATCH] command.c: Open-code mmd_dup(). This function is short and has only a single caller. The code becomes clearer by open-coding it in the caller. --- command.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 46ede2fe..bde14587 100644 --- a/command.c +++ b/command.c @@ -75,13 +75,6 @@ static void dummy(__a_unused int s) { } -static void mmd_dup(struct misc_meta_data *new_mmd) -{ - mutex_lock(mmd_mutex); - *new_mmd = *mmd; - mutex_unlock(mmd_mutex); -} - /* * Compute human readable vss status text. * @@ -533,7 +526,13 @@ static int com_stat(struct command_context *cc) if (i != cc->argc) return -E_COMMAND_SYNTAX; for (;;) { - mmd_dup(nmmd); + /* + * Copy the mmd structure to minimize the time we hold the mmd + * lock. + */ + mutex_lock(mmd_mutex); + *nmmd = *mmd; + mutex_unlock(mmd_mutex); ret = get_status(nmmd, parser_friendly, &s); ret = send_sb(&cc->scc, s, ret, SBD_OUTPUT, false); if (ret < 0) -- 2.39.2