- rc = ll_lookup_it_finish(req, it, &icbd, &entry->se_inode);
- if (entry->se_inode != NULL)
- entry->se_dentry = dget(dentry);
+ rc = ll_lookup_it_finish(req, it, &icbd);
+ if (entry->se_inode != NULL) {
+ struct ll_dentry_data *lld = ll_d2d(dentry);
+ struct ll_inode_info *sei = ll_i2info(entry->se_inode);
+
+ /* For statahead lookup case, both MDS_INODELOCK_LOOKUP
+ * and MDS_INODELOCK_UPDATE should be granted */
+ if (likely(bits & MDS_INODELOCK_LOOKUP &&
+ bits & MDS_INODELOCK_UPDATE)) {
+ /* the first dentry ref_count will be dropped by
+ * ll_sai_entry_to_stated(), so hold another ref
+ * in advance */
+ entry->se_dentry = dget(dentry);
+ cfs_spin_lock(&sei->lli_sa_lock);
+ cfs_list_add(&lld->lld_sa_alias,
+ &sei->lli_sa_dentry);
+ cfs_spin_unlock(&sei->lli_sa_lock);
+ sai->sai_nolock = 0;
+ } else {
+ iput(entry->se_inode);
+ entry->se_inode = NULL;
+ sai->sai_nolock++;
+ }
+ }