From: Bruce Korb Date: Mon, 28 Nov 2011 20:02:21 +0000 (-0800) Subject: LU-881 utils: running bumped w/o lock X-Git-Tag: 2.1.53~51 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9b62cf1f91bf50eaf5e1ef63024b2b6f78f28794;hp=598996a12f5818190635e1f3a948c9e6a77297b5 LU-881 utils: running bumped w/o lock bumped_running accessed without lock Multiple threads man increment shared_data->running until the setting of bumped_running becomes visible. Also, use "bool" -- First released in Issue 6 of POSIX spec: included for alignment with the ISO/IEC 9899:1999 standard When inserting #include , it was noticed that stdio.h was included twice. Collected and ordered system headers so that won't happen again. Signed-off-by: Bruce Korb Change-Id: I45891e125221d29f72efee38580a56888c3a266f Reviewed-on: http://review.whamcloud.com/1749 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: wangdi --- diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 2a84949..4f10404 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -41,35 +41,35 @@ * Author: Robert Read */ -#include #include -#include #include +#include +#include #include +#include #include -#include -#include -#include -#include + #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "obdctl.h" #include /* for struct lov_stripe_md */ #include -#include -#include -#include -#include -#include -#include - #include #include #include -#include #include #define MAX_STRING_SIZE 128 @@ -486,17 +486,18 @@ static inline void shmem_reset(int total_threads) static inline void shmem_bump(void) { - static int bumped_running; + static bool running_not_bumped = true; if (shared_data == NULL || thread <= 0 || thread > MAX_THREADS) return; shmem_lock(); shared_data->counters[thread - 1]++; - if (!bumped_running) + if (running_not_bumped) { shared_data->running++; + running_not_bumped = false; + } shmem_unlock(); - bumped_running = 1; } static void shmem_snap(int total_threads, int live_threads)