- struct lookup_intent *it = *itp;
-#ifdef HAVE_VFS_INTENT_PATCHES
- if (it) {
- LASSERTF(it->it_magic == INTENT_MAGIC,
- "%p has bad intent magic: %x\n",
- it, it->it_magic);
- }
-#endif
-
- if (!it || it->it_op == IT_GETXATTR)
- it = *itp = deft;
-
-#ifdef HAVE_VFS_INTENT_PATCHES
- it->it_op_release = ll_intent_release;
-#endif
-}
-
-int ll_revalidate_it(struct dentry *de, int lookup_flags,
- struct lookup_intent *it)
-{
- struct md_op_data *op_data;
- struct ptlrpc_request *req = NULL;
- struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
- struct obd_export *exp;
- struct inode *parent;
- int rc, first = 0;
-
- ENTRY;
- CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name,
- LL_IT2STR(it));
-
- if (de->d_inode == NULL) {
- /* We can only use negative dentries if this is stat or lookup,
- for opens and stuff we do need to query server. */
- /* If there is IT_CREAT in intent op set, then we must throw
- away this negative dentry and actually do the request to
- kernel to create whatever needs to be created (if possible)*/
- if (it && (it->it_op & IT_CREAT))
- RETURN(0);
-
-#ifdef DCACHE_LUSTRE_INVALID
- if (de->d_flags & DCACHE_LUSTRE_INVALID)
- RETURN(0);
-#endif
-
- rc = ll_have_md_lock(de->d_parent->d_inode,
- MDS_INODELOCK_UPDATE);
- GOTO(out_sa, rc);
- }
-
- exp = ll_i2mdexp(de->d_inode);
-
- /* Never execute intents for mount points.
- * Attributes will be fixed up in ll_inode_revalidate_it */
- if (d_mountpoint(de))
- GOTO(out_sa, rc = 1);
-
- /* Root of the lustre tree. Always valid.
- * Attributes will be fixed up in ll_inode_revalidate_it */
- if (de == de->d_sb->s_root)
- GOTO(out_sa, rc = 1);
-
- OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
- ll_frob_intent(&it, &lookup_it);
- LASSERT(it);
- parent = de->d_parent->d_inode;
-
- op_data = ll_prep_md_op_data(NULL, parent, de->d_inode,
- de->d_name.name, de->d_name.len,
- 0, LUSTRE_OPC_ANY, NULL);
- if (IS_ERR(op_data))
- RETURN(PTR_ERR(op_data));
-
- if ((it->it_op == IT_OPEN) && de->d_inode) {
- struct inode *inode = de->d_inode;
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_client_handle **och_p;
- __u64 *och_usecount;
-
- /*
- * We used to check for MDS_INODELOCK_OPEN here, but in fact
- * just having LOOKUP lock is enough to justify inode is the
- * same. And if inode is the same and we have suitable
- * openhandle, then there is no point in doing another OPEN RPC
- * just to throw away newly received openhandle. There are no
- * security implications too, if file owner or access mode is
- * change, LOOKUP lock is revoked.
- */
-
-
- if (it->it_flags & FMODE_WRITE) {
- och_p = &lli->lli_mds_write_och;
- och_usecount = &lli->lli_open_fd_write_count;
- } else if (it->it_flags & FMODE_EXEC) {
- och_p = &lli->lli_mds_exec_och;
- och_usecount = &lli->lli_open_fd_exec_count;
- } else {
- och_p = &lli->lli_mds_read_och;
- och_usecount = &lli->lli_open_fd_read_count;
- }
- /* Check for the proper lock. */
- if (!ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP))
- goto do_lock;
- down(&lli->lli_och_sem);
- if (*och_p) { /* Everything is open already, do nothing */
- /*(*och_usecount)++; Do not let them steal our open
- handle from under us */
- /* XXX The code above was my original idea, but in case
- we have the handle, but we cannot use it due to later
- checks (e.g. O_CREAT|O_EXCL flags set), nobody
- would decrement counter increased here. So we just
- hope the lock won't be invalidated in between. But
- if it would be, we'll reopen the open request to
- MDS later during file open path */
- up(&lli->lli_och_sem);
- ll_finish_md_op_data(op_data);
- RETURN(1);
- } else {
- up(&lli->lli_och_sem);
- }
- }