if (dentry->d_inode && dentry->d_inode->i_op->follow_link)
return 1;
- /* Last path component lookup for open or create - we always
- * return 0 here to go through re-lookup and properly signal
- * MDS whenever we do or do not want an open-cache to be engaged.
- * For create we also ensure the entry is really created no matter
- * what races might have happened.
- * LU-4367 */
- if (lookup_flags & (LOOKUP_OPEN | LOOKUP_CREATE))
+ /*
+ * if open&create is set, talk to MDS to make sure file is created if
+ * necessary, because we can't do this in ->open() later since that's
+ * called on an inode. return 0 here to let lookup to handle this.
+ */
+ if ((lookup_flags & (LOOKUP_OPEN | LOOKUP_CREATE)) ==
+ (LOOKUP_OPEN | LOOKUP_CREATE))
return 0;
if (!dentry_may_statahead(dir, dentry))
} else {
LASSERT(*och_usecount == 0);
if (!it->it_disposition) {
+ struct ll_dentry_data *ldd = ll_d2d(file->f_path.dentry);
/* We cannot just request lock handle now, new ELC code
means that one of other OPEN locks for this file
could be cancelled, and since blocking ast handler
* handle to be returned from LOOKUP|OPEN request,
* for example if the target entry was a symlink.
*
- * Always fetch MDS_OPEN_LOCK if this is not setstripe.
+ * Only fetch MDS_OPEN_LOCK if this is in NFS path,
+ * marked by a bit set in ll_iget_for_nfs. Clear the
+ * bit so that it's not confusing later callers.
*
+ * NB; when ldd is NULL, it must have come via normal
+ * lookup path only, since ll_iget_for_nfs always calls
+ * ll_d_init().
+ */
+ if (ldd && ldd->lld_nfs_dentry) {
+ ldd->lld_nfs_dentry = 0;
+ it->it_flags |= MDS_OPEN_LOCK;
+ }
+
+ /*
* Always specify MDS_OPEN_BY_FID because we don't want
* to get file with different fid.
*/
- it->it_flags |= MDS_OPEN_LOCK | MDS_OPEN_BY_FID;
+ it->it_flags |= MDS_OPEN_BY_FID;
rc = ll_intent_file_open(file, NULL, 0, it);
if (rc)
GOTO(out_openerr, rc);
/* N.B. d_obtain_alias() drops inode ref on error */
result = d_obtain_alias(inode);
+ if (!IS_ERR(result)) {
+ int rc;
+
+ rc = ll_d_init(result);
+ if (rc < 0) {
+ dput(result);
+ result = ERR_PTR(rc);
+ } else {
+ struct ll_dentry_data *ldd = ll_d2d(result);
+
+ /*
+ * Need to signal to the ll_file_open that
+ * we came from NFS and so opencache needs to be
+ * enabled for this one
+ */
+ ldd->lld_nfs_dentry = 1;
+ }
+ }
RETURN(result);
}