Whamcloud - gitweb
LU-4367 llite: Make revalidate return 0 for opens 62/11062/4
authorOleg Drokin <oleg.drokin@intel.com>
Fri, 11 Jul 2014 04:30:54 +0000 (00:30 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 25 Jul 2014 18:41:29 +0000 (18:41 +0000)
This is important so that we can properly engage opencache when needed.

This also reshuffles some other logic in ll_revalidate_dentry to
more properly handle intermediate component revalidate logic.

Change-Id: Ib4f272155096d33fe3f45b781e21e5bd4f44ff58
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/11062
Tested-by: Jenkins
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/llite/dcache.c
lustre/llite/file.c

index 2d3d2f7..7243769 100644 (file)
@@ -358,18 +358,25 @@ static int ll_revalidate_dentry(struct dentry *dentry,
 {
        struct inode *dir = dentry->d_parent->d_inode;
 
-       /*
-        * 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 this is intermediate component path lookup and we were able to get
+        * to this dentry, then its lock has not been revoked and the
+        * path component is valid. */
+       if (lookup_flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))
+               return 1;
 
-       if (lookup_flags & (LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE))
+       /* Symlink - always valid as long as the dentry was found */
+       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))
+               return 0;
+
        if (d_need_statahead(dir, dentry) <= 0)
                return 1;
 
index 0457867..52fc9ff 100644 (file)
@@ -666,8 +666,9 @@ restart:
                        /*
                         * Normally called under two situations:
                         * 1. NFS export.
-                        * 2. revalidate with IT_OPEN (revalidate doesn't
-                        *    execute this intent any more).
+                        * 2. A race/condition on MDS resulting in no open
+                        *    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.
                         *