Whamcloud - gitweb
LU-2744 build: fix 'data race condition' issues 74/6574/4
authorSebastien Buisson <sebastien.buisson@bull.net>
Thu, 6 Jun 2013 12:41:34 +0000 (14:41 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 5 Sep 2013 19:54:12 +0000 (19:54 +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: I9ce06aee1e5ac033025288ad55bf0c3935a3a9cb
Reviewed-on: http://review.whamcloud.com/6574
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/osp/osp_precreate.c

index 329ae47..208d912 100644 (file)
@@ -721,7 +721,9 @@ out:
        if (req)
                ptlrpc_req_finished(req);
 
+       spin_lock(&d->opd_pre_lock);
        d->opd_pre_recovering = 0;
+       spin_unlock(&d->opd_pre_lock);
 
        /*
         * If rc is zero, the pre-creation window should have been emptied.
@@ -795,8 +797,10 @@ void osp_pre_update_status(struct osp_device *d, int rc)
                               d->opd_syn_changes, d->opd_syn_rpc_in_progress);
                } else if (old == -ENOSPC) {
                        d->opd_pre_status = 0;
+                       spin_lock(&d->opd_pre_lock);
                        d->opd_pre_grow_slow = 0;
                        d->opd_pre_grow_count = OST_MIN_PRECREATE;
+                       spin_unlock(&d->opd_pre_lock);
                        cfs_waitq_signal(&d->opd_pre_waitq);
                        CDEBUG(D_INFO, "%s: no space: "LPU64" blocks, "LPU64
                               " free, "LPU64" used, "LPU64" avail -> %d: "