I'm trying to understand some code in exportfs. The particular code is
in find_exported_dentry. Here is some pseudocode from
find_exported_dentry. I've stripped out the error-checking code and
included invariants that describe what I believe is going on.

INPUT: struct dentry *pd

/* struct dentry *pd is a disconnected dentry that we want to connect.
it was
* probably created with d_alloc_anon. Note that IS_ROOT(pd) is TRUE.

/* call export ops to get parent of pd */
ppd = CALL(nops, get_parent)(pd);

/* call export ops to get name of pd */
CALL(nops, get_parent)(ppd, nbuf, pd)

/* perform a lookup using the name we received. We know that pd is a
* of ppd, and we know that pd's name is 'nbuf', so the lookup should
* and return us a non-anonymous dentry.
npd = lookup_one_len(nbuf, ppd, strlen(nbuf));

/* In my test run, pd != ndp. This is because pd is an anonymous dentry
and npd is
* a non-anonymous one, containing a name. Code comments say this is

if (IS_ROOT(pd)) {
/* something went wrong, we have to give up */

The function is failing for me on that last IS_ROOT check in the if
statement. What I'm confused about is when was pd supposed to have gone
from unconnected to connected? In my test runs, npd is connected but pd
is not. They both have the same inode number.