LINUX: Remove fix_bad_parent
authorAndrew Deason <adeason@sinenomine.net>
Mon, 1 Dec 2014 16:11:38 +0000 (10:11 -0600)
committerDaria Brashear <shadow@your-file-system.com>
Wed, 14 Jan 2015 15:17:37 +0000 (10:17 -0500)
For Linux, fix_bad_parent (and in 1.6 and earlier, check_bad_parent)
served the purpose of fixing mvid if it was "wrong", for volume-root
vcaches (mvstat == 2).

However, in modern Linux, we never really use mvid for root vcaches.
This would normally be used for looking up ".." entries in the root
dir, but Linux handles that for us.

Specifically, the only times an "mvstat == 2" mvid is used are:

 - afs_lookup(), where we specifically check for a ".." lookup. Linux
   cannot give us a lookup for "..", since Linux itself services ".."
   lookups through the dcache.

 - afs_readdir_move(), where we look for ".." entries. Linux does not
   use this function, since Linux reimplements afs_readdir() in
   afs_linux_readdir(), and so this function is never called.

Of course, mvid is used in many other locations, mostly for "mvstat ==
1" vcaches (mountpoints) and a few other special cases. But these are
the instances where mvid is relevant for root dirs.

So, since mvid is never really used for "mvstat == 2" vcaches on
Linux, don't bother trying to keep it up-to-date. Doing so is just
needless waste, and causes problems when there are bugs in
fix_bad_parent. The mvid field is still updated in cross-platform code
from time to time; removing that would be more complex and possibly
not worth the effort.

Change-Id: I5011ba069e5c8ed947ab6ff8d8dd393241d9c4bf
Reviewed-on: http://gerrit.openafs.org/11615
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>

src/afs/LINUX/osi_vnodeops.c

index b2ab9d5..fbaa410 100644 (file)
@@ -932,44 +932,6 @@ canonical_dentry(struct inode *ip)
  * AFS Linux dentry operations
  **********************************************************************/
 
-/* fix_bad_parent() : called if this dentry's vcache is a root vcache
- * that has its mvid (parent dir's fid) pointer set to the wrong directory
- * due to being mounted in multiple points at once. fix_bad_parent()
- * calls afs_lookup() to correct the vcache's mvid, as well as the volume's
- * dotdotfid and mtpoint fid members.
- * Parameters:
- *   dp - dentry to be checked.
- *   credp - credentials
- *   vcp, pvc - item's and parent's vcache pointer
- * Return Values:
- *   None.
- * Sideeffects:
- *   This dentry's vcache's mvid will be set to the correct parent directory's
- *   fid.
- *   This root vnode's volume will have its dotdotfid and mtpoint fids set
- *   to the correct parent and mountpoint fids.
- */
-
-static inline void
-fix_bad_parent(struct dentry *dp, cred_t *credp, struct vcache *vcp, struct vcache *pvc) 
-{
-    struct vcache *avc = NULL;
-    int code;
-
-    /* force a lookup, so vcp->mvid is fixed up */
-    code = afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp);
-    if (code || vcp != avc) {  /* bad, very bad.. */
-       afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING,
-                  "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry",
-                  ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc,
-                  ICL_TYPE_POINTER, dp);
-    }
-    if (avc)
-       AFS_RELE(AFSTOV(avc));
-
-    return;
-}
-
 /* afs_linux_revalidate
  * Ensure vcache is stat'd before use. Return 0 if entry is valid.
  */
@@ -991,25 +953,6 @@ afs_linux_revalidate(struct dentry *dp)
        goto out;
     }
 
-#ifdef notyet
-    /* Make this a fast path (no crref), since it's called so often. */
-    if (vcp->states & CStatd) {
-       struct vcache *pvc = VTOAFS(dp->d_parent->d_inode);
-
-       if (*dp->d_name.name != '/' && vcp->mvstat == 2) {      /* root vnode */
-           if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) { /* bad parent */
-               credp = crref();
-               AFS_GLOCK();
-               fix_bad_parent(dp);     /* check and correct mvid */
-               AFS_GUNLOCK();
-               crfree(credp);
-           }
-       }
-       afs_DestroyAttr(vattr);
-       return 0;
-    }
-#endif
-
     /* This avoids the crref when we don't have to do it. Watch for
      * changes in afs_getattr that don't get replicated here!
      */
@@ -1253,12 +1196,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
                    goto bad_dentry;
                }
            }
-       } else
-           if (locked && *dp->d_name.name != '/' && vcp->mvstat == 2) {        /* root vnode */
-               if (vcp->mvid->Fid.Volume != pvcp->f.fid.Fid.Volume) {  /* bad parent */
-                   fix_bad_parent(dp, credp, vcp, pvcp);       /* check and correct mvid */
-               }
-           }
+       }
 
 #ifdef notdef
        /* If the last looker changes, we should make sure the current