Whamcloud - gitweb
LU-17453 llite: use dget_parent to access dentry.d_parent
[fs/lustre-release.git] / lustre / llite / statahead.c
index 35aae94..f798e3b 100644 (file)
@@ -2089,9 +2089,9 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry,
        struct ll_inode_info *lli = ll_i2info(dir);
        struct ll_statahead_info *sai = NULL;
        struct ll_statahead_context *ctx = NULL;
-       struct dentry *parent = dentry->d_parent;
+       struct dentry *parent;
        struct task_struct *task;
-       struct ll_sb_info *sbi = ll_i2sbi(parent->d_inode);
+       struct ll_sb_info *sbi;
        int first = LS_FIRST_DE;
        int rc = 0;
 
@@ -2100,14 +2100,19 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry,
        if (sa_pattern_detect(dir, dentry, &first) == false)
                RETURN(0);
 
+       parent = dget_parent(dentry);
+       sbi = ll_i2sbi(d_inode(parent));
        if (unlikely(atomic_inc_return(&sbi->ll_sa_running) >
                                       sbi->ll_sa_running_max)) {
                CDEBUG(D_READA,
                       "Too many concurrent statahead instances, avoid new statahead instance temporarily.\n");
+               dput(parent);
                GOTO(out, rc = -EMFILE);
        }
 
+       /* on success ll_sai_alloc holds a ref on parent */
        sai = ll_sai_alloc(parent);
+       dput(parent);
        if (!sai)
                GOTO(out, rc = -ENOMEM);