PERFORCE change 178714 for review
Efstratios Karatzas
gpf at FreeBSD.org
Mon May 24 14:06:58 UTC 2010
http://p4web.freebsd.org/@@178714?ac=10
Change 178714 by gpf at gpf_desktop on 2010/05/24 14:06:34
* the second parameter from VOP_VPTOCNP() should be vdrop()ed after
the call - done
* dont really need exclusive locks; now I use shared locks
* dir_ilookup() still only works for UFS, added a check so that the
function will return if the fs is not ufs
Affected files ...
.. //depot/projects/soc2010/gpf_audit/vn_fullpath_nocache.c#3 edit
Differences ...
==== //depot/projects/soc2010/gpf_audit/vn_fullpath_nocache.c#3 (text+ko) ====
@@ -75,11 +75,18 @@
KASSERT("dvp != NULL", "dir_ilookup: dvp == NULL");
KASSERT("name != NULL", "dir_ilookup: name == NULL");
+ /* XXXgpf: temporary, must be a better way to check this than f_type or f_fstypename */
+ if (strcmp(vp->v_mount->mnt_stat.f_fstypename, "ufs")) {
+ uprintf("only ufs supported\n");
+ return 1;
+ }
+
foundit = 0;
dirbuflen = ((struct inode *)dvp->v_data)->i_size;
dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK);
td = curthread;
+ /* prep the call to VOP_READDIR() */
iov.iov_base = dirbuf;
iov.iov_len = dirbuflen;
io.uio_iov = &iov;
@@ -90,7 +97,7 @@
io.uio_rw = UIO_READ;
io.uio_td = td;
eofflag = 0;
-
+
error = VOP_READDIR(dvp, &io, td->td_ucred, &eofflag, NULL, NULL);
if (error) {
uprintf("VOP_READDIR failure %d\n", error);
@@ -146,9 +153,9 @@
* Retrieve the full filesystem path that corresponds to a vnode without use of the
* name cache.
* - A directory hint (UFS file_id of the directory that contains the vnode) may be
- * supplied to facilitate the search is our target is not a directory itself.
+ * supplied to facilitate the search if our target is not a directory itself.
* - flags should be set to PARENT_HINT, if the directory hint is supplied
- * and to EXHAUSTIVE_SEARCH, if we are willing to go intro great trouble to get this path
+ * and to EXHAUSTIVE_SEARCH, if we are willing to go intro great trouble to get this path.
*
* Author's note: This only works for UFS filesystems (for now).
* Oh, also EXHAUSTIVE_SEARCH will kernel panic :-D
@@ -187,12 +194,11 @@
* - If our target is a directory, move on to the part where we traverse the '..' entries.
* - If not, either use the directory_hint if it's available or do an exhaustive search on the fs (xD) so
* that we can connect the vp with 'a' parent directory.
- */
+ */
if (vp->v_type != VDIR) {
/* grab the parent directory using the directory_hint */
if ((flags & PARENT_HINT) && vp->v_type != VDIR) {
- /* XXXgpf: should change the locktypes from excl to smth else */
- error = VFS_VGET(vp->v_mount, directory_hint, LK_EXCLUSIVE, &dvp);
+ error = VFS_VGET(vp->v_mount, directory_hint, LK_SHARED, &dvp);
/* in case of failure, proceed to exhaustive search */
if (error) {
uprintf("VFS_VGET failure %d\n", error);
@@ -215,7 +221,7 @@
if ((flags & EXHAUSTIVE_SEARCH) && dvp == NULL) {
/*
* XXXgpf: this actually does not work because when the thread will try to sleep,
- * e.g. in VOP_READDIR the kernel will panic because we have ilocked mp >.<
+ * e.g. in VOP_READDIR, the kernel will panic because we have ilocked mp >.<
*/
MNT_ILOCK(mp);
if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) {
@@ -223,7 +229,7 @@
TAILQ_FOREACH(tvp, &mp->mnt_nvnodelist, v_nmntvnodes) {
if (tvp->v_type == VDIR) {
- vn_lock(tvp, LK_EXCLUSIVE);
+ vn_lock(tvp, LK_SHARED);
/* grab the name that is being used to reference vp */
error = dir_ilookup(vp, tvp, fname, &fnamelen);
@@ -267,7 +273,7 @@
else {
dvp = vp;
vref(dvp);
- vn_lock(dvp, LK_EXCLUSIVE);
+ vn_lock(dvp, LK_SHARED);
}
/*
@@ -318,9 +324,10 @@
buf[--buflen] = '/';
if (dvp != NULL)
vput(dvp);
-
+
+ vdrop(upper_dvp);
dvp = upper_dvp;
- vn_lock(dvp, LK_EXCLUSIVE);
+ vn_lock(dvp, LK_SHARED);
vref(dvp);
} /* while */
More information about the p4-projects
mailing list