[LU-5274] ll_statahead_thread() may leak parent, uses parent after dput Created: 30/Jun/14  Updated: 14/Jun/18  Resolved: 14/Aug/14

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

Type: Bug Priority: Major
Reporter: John Hammond Assignee: Zhenyu Xu
Resolution: Fixed Votes: 0
Labels: malloc, patch, statahead

Issue Links:
Related
is related to LU-5071 statahead.c:1704:do_statahead_enter()... Resolved
Severity: 3
Rank (Obsolete): 14717

 Description   

In ll_statahead_thread() if ll_prep_md_op_data() returns an error then the parent dentry will be leaked and the parent thread will hang in do_statahead_enter().

static int ll_statahead_thread(void *arg)
{
        struct dentry            *parent = (struct dentry *)arg;

        ...

        thread->t_pid = current_pid();
        CDEBUG(D_READA, "statahead thread starting: sai %p, parent %.*s\n",
               sai, parent->d_name.len, parent->d_name.name);

        op_data = ll_prep_md_op_data(NULL, dir, dir, NULL, 0, 0,
                                     LUSTRE_OPC_ANY, dir);
        if (IS_ERR(op_data))
                RETURN(PTR_ERR(op_data));

        ...

        spin_lock(&plli->lli_sa_lock);
        if (thread_is_init(thread))
                /* If someone else has changed the thread state
                 * (e.g. already changed to SVC_STOPPING), we can't just
                 * blindly overwrite that setting. */
                thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&plli->lli_sa_lock);
        wake_up(&thread->t_ctl_waitq);

At the end of the same function parent is passed to CDEBUG() after dput():

        dput(parent);
        CDEBUG(D_READA, "statahead thread stopped: sai %p, parent %.*s\n",
               sai, parent->d_name.len, parent->d_name.name);
        return rc;
}


 Comments   
Comment by Andreas Dilger [ 02/Jul/14 ]

The patch http://review.whamcloud.com/10940 fixes one of the two problems described here.

Comment by Peter Jones [ 11/Jul/14 ]

Bobijam

Could you please review the patch from Li Xi and see whether the autotest failures are related to the changes or not?

Thanks

Peter

Comment by Zhenyu Xu [ 11/Jul/14 ]

no, it's not related to the patch change itself, sanity-quota 7c test error is reported in LU-4448,

Comment by John Hammond [ 31/Jul/14 ]

The updated version of http://review.whamcloud.com/10940 has landed to master and addressed both issues.

Generated at Sat Feb 10 01:50:03 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.