[LU-6516] double spin unlock in ofd_inconsistency_verification_main Created: 27/Apr/15  Updated: 29/Dec/15  Resolved: 18/Aug/15

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.8.0

Type: Bug Priority: Minor
Reporter: Oleg Drokin Assignee: Jian Yu
Resolution: Fixed Votes: 0
Labels: patch

Issue Links:
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

found by smatch, in ofd_inconsistency_verification_main:

        spin_unlock(&ofd->ofd_inconsistency_lock);
        if (rc != 0)
                RETURN(rc);

        OBD_ALLOC_PTR(lr);
        if (unlikely(lr == NULL))
                GOTO(out, rc = -ENOMEM);
...
        thread_set_flags(thread, SVC_STOPPED);
        wake_up_all(&thread->t_ctl_waitq);
        spin_unlock(&ofd->ofd_inconsistency_lock);


 Comments   
Comment by Ulka Vaze (Inactive) [ 18/May/15 ]

Hi,

Yes this seems to be issue. Earlier we are taking lock and waking up threads.
See this code -

spin_lock(&ofd->ofd_inconsistency_lock);
    thread_set_flags(thread, rc != 0 ? SVC_STOPPED : SVC_RUNNING);
    wake_up_all(&thread->t_ctl_waitq);
    spin_unlock(&ofd->ofd_inconsistency_lock);
 

However in out we did not lock again.

thread_set_flags(thread, SVC_STOPPED);
    wake_up_all(&thread->t_ctl_waitq);
    spin_unlock(&ofd->ofd_inconsistency_lock);
    lu_env_fini(&env);

    return rc;

This is because in normal case we have spinlock already taken.
But if memory allocation failed then this will not work.
Probable solution is -
OBD_ALLOC_PTR(lr);
if (unlikely(lr == NULL))
GOTO(out1, rc = ENOMEM);<--- added new lable

out1:
spin_lock(&ofd->ofd_inconsistency_lock);
thread_set_flags(thread, rc != 0 ? SVC_STOPPED : SVC_RUNNING);
wake_up_all(&thread->t_ctl_waitq);
spin_unlock(&ofd->ofd_inconsistency_lock);
lu_env_fini(&env);

return rc;

Please advice.
-Ulka

Comment by Gerrit Updater [ 20/May/15 ]

Ulka Vaze (ulka.vaze@yahoo.in) uploaded a new patch: http://review.whamcloud.com/14875
Subject: LU-6516 ofd: double unlock of spinlock
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 1095e21567f7cfb5906d9e7178e950567fb924a4

Comment by Gerrit Updater [ 18/Aug/15 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/14875/
Subject: LU-6516 ofd: fix double spin_unlock
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 490ea83a486c0c44274f4d4f6f77d8e0e16835d5

Comment by Peter Jones [ 18/Aug/15 ]

Landed for 2.8

Generated at Sat Feb 10 02:00:53 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.