Whamcloud - gitweb
LU-2744 build: fix 'data race condition' issues 73/6573/4
authorSebastien Buisson <sebastien.buisson@bull.net>
Thu, 6 Jun 2013 12:40:06 +0000 (14:40 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 5 Sep 2013 19:41:33 +0000 (19:41 +0000)
Fix 'data race condition' defects found by Coverity version
6.5.0:
Data race condition (MISSING_LOCK)
Accessing variable without holding lock. Elsewhere,
this variable is accessed with lock held.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: I29825c47f08a893685a62aeea2e49b315149b3d9
Reviewed-on: http://review.whamcloud.com/6573
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/osd-ldiskfs/osd_scrub.c

index 5e6ee4a..a74ca9b 100644 (file)
@@ -395,8 +395,10 @@ static int osd_scrub_prep(struct osd_device *dev)
                scrub->os_full_speed = 1;
 
        scrub->os_in_prior = 0;
+       spin_lock(&scrub->os_lock);
        scrub->os_waiting = 0;
        scrub->os_paused = 0;
+       spin_unlock(&scrub->os_lock);
        scrub->os_new_checked = 0;
        if (sf->sf_pos_last_checkpoint != 0)
                sf->sf_pos_latest_start = sf->sf_pos_last_checkpoint + 1;
@@ -1214,8 +1216,10 @@ static int osd_otable_it_preload(const struct lu_env *env,
               ooc->ooc_pos_preload, rc);
 
        if (scrub->os_waiting && osd_scrub_has_window(scrub, ooc)) {
+               spin_lock(&scrub->os_lock);
                scrub->os_waiting = 0;
                cfs_waitq_broadcast(&scrub->os_thread.t_ctl_waitq);
+               spin_unlock(&scrub->os_lock);
        }
 
        RETURN(rc < 0 ? rc : ooc->ooc_cached_items);