-#else /* !HAVE_IOP_ATOMIC_OPEN */
-static struct lookup_intent *
-ll_convert_intent(struct open_intent *oit, int lookup_flags, bool is_readonly)
-{
- struct lookup_intent *it;
-
- OBD_ALLOC_PTR(it);
- if (!it)
- return ERR_PTR(-ENOMEM);
-
- if (lookup_flags & LOOKUP_OPEN) {
- it->it_op = IT_OPEN;
- /* Avoid file creation for ro bind mount point(is_readonly) */
- if ((lookup_flags & LOOKUP_CREATE) && !is_readonly)
- it->it_op |= IT_CREAT;
- it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
- it->it_flags = ll_namei_to_lookup_intent_flag(oit->flags &
- ~(is_readonly ? O_CREAT : 0));
- it->it_flags &= ~MDS_OPEN_FL_INTERNAL;
- } else {
- it->it_op = IT_GETATTR;
- }
-
- return it;
-}
-
-static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
- struct nameidata *nd)
-{
- struct dentry *de;
- ENTRY;
-
- if (nd && !(nd->flags & (LOOKUP_CONTINUE|LOOKUP_PARENT))) {
- struct lookup_intent *it;
-
- if (ll_d2d(dentry) && ll_d2d(dentry)->lld_it) {
- it = ll_d2d(dentry)->lld_it;
- ll_d2d(dentry)->lld_it = NULL;
- } else {
- /*
- * Optimize away (CREATE && !OPEN). Let .create handle
- * the race. But only if we have write permissions
- * there, otherwise we need to proceed with lookup.
- * LU-4185
- */
- if ((nd->flags & LOOKUP_CREATE) &&
- !(nd->flags & LOOKUP_OPEN) &&
- (inode_permission(parent,
- MAY_WRITE | MAY_EXEC) == 0))
- RETURN(NULL);
-
- it = ll_convert_intent(&nd->intent.open, nd->flags,
- (nd->path.mnt->mnt_flags & MNT_READONLY) ||
- (nd->path.mnt->mnt_sb->s_flags & SB_RDONLY));
- if (IS_ERR(it))
- RETURN((struct dentry *)it);
- }
-
- de = ll_lookup_it(parent, dentry, it, NULL, NULL, NULL);
- if (de)
- dentry = de;
- if ((nd->flags & LOOKUP_OPEN) && !IS_ERR(dentry)) { /* Open */
- if (dentry->d_inode &&
- it_disposition(it, DISP_OPEN_OPEN)) { /* nocreate */
- if (S_ISFIFO(dentry->d_inode->i_mode)) {
- /* We cannot call open here as it might
- * deadlock. This case is unreachable in
- * practice because of
- * OBD_CONNECT_NODEVOH. */
- } else {
- struct file *filp;
-
- nd->intent.open.file->private_data = it;
- filp = lookup_instantiate_filp(nd,
- dentry,
- NULL);
- if (IS_ERR(filp)) {
- if (de)
- dput(de);
- de = (struct dentry *)filp;
- }
- }
- } else if (it_disposition(it, DISP_OPEN_CREATE)) {
- /* XXX This can only reliably work on assumption
- * that there are NO hashed negative dentries.*/
- ll_d2d(dentry)->lld_it = it;
- it = NULL; /* Will be freed in ll_create_nd */
- /* We absolutely depend on ll_create_nd to be
- * called to not leak this intent and possible
- * data attached to it */
- }
- }
-
- if (it) {
- ll_intent_release(it);
- OBD_FREE(it, sizeof(*it));
- }
- } else {
- de = ll_lookup_it(parent, dentry, NULL, NULL, NULL, NULL);
- }
-
- RETURN(de);
-}
-#endif /* HAVE_IOP_ATOMIC_OPEN */
-