Whamcloud - gitweb
LU-13246 osd: unlock os_lock if it was locked 47/37547/6
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 12 Feb 2020 05:45:09 +0000 (08:45 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 14 May 2020 05:41:57 +0000 (05:41 +0000)
do not use the global state (which can change concurrently) for that.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Idbdc3639bca50006dac00112205e1fee9c9a0e30
Reviewed-on: https://review.whamcloud.com/37547
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-zfs/osd_scrub.c

index 67610d6..d835708 100644 (file)
@@ -1678,8 +1678,8 @@ static int osd_otable_it_next(const struct lu_env *env, struct dt_it *di)
        struct ptlrpc_thread *thread = &scrub->os_thread;
        struct lustre_mdt_attrs *lma = NULL;
        nvlist_t *nvbuf = NULL;
-       int size = 0;
-       int rc;
+       int rc, size = 0;
+       bool locked;
        ENTRY;
 
        LASSERT(it->ooi_user_ready);
@@ -1715,16 +1715,20 @@ again:
 
        rc = __osd_xattr_load_by_oid(dev, it->ooi_pos, &nvbuf);
 
-       if (!scrub->os_full_speed)
+       locked = false;
+       if (!scrub->os_full_speed) {
                spin_lock(&scrub->os_lock);
+               locked = true;
+       }
        it->ooi_prefetched--;
        if (!scrub->os_full_speed) {
                if (scrub->os_waiting) {
                        scrub->os_waiting = 0;
                        wake_up_all(&thread->t_ctl_waitq);
                }
-               spin_unlock(&scrub->os_lock);
        }
+       if (locked)
+               spin_unlock(&scrub->os_lock);
 
        if (rc == -ENOENT || rc == -EEXIST || rc == -ENODATA)
                goto again;