Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd90b509 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds
Browse files

knfsd: exportfs: add find_disconnected_root helper



Break the loop that finds the root of a disconnected subtree into a helper of
its own to make reading easier and document the intent.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fb66a198
Loading
Loading
Loading
Loading
+23 −16
Original line number Original line Diff line number Diff line
@@ -70,6 +70,27 @@ find_acceptable_alias(struct dentry *result,
	return NULL;
	return NULL;
}
}


/*
 * Find root of a disconnected subtree and return a reference to it.
 */
static struct dentry *
find_disconnected_root(struct dentry *dentry)
{
	dget(dentry);
	spin_lock(&dentry->d_lock);
	while (!IS_ROOT(dentry) &&
	       (dentry->d_parent->d_flags & DCACHE_DISCONNECTED)) {
		struct dentry *parent = dentry->d_parent;
		dget(parent);
		spin_unlock(&dentry->d_lock);
		dput(dentry);
		dentry = parent;
		spin_lock(&dentry->d_lock);
	}
	spin_unlock(&dentry->d_lock);
	return dentry;
}

/**
/**
 * find_exported_dentry - helper routine to implement export_operations->decode_fh
 * find_exported_dentry - helper routine to implement export_operations->decode_fh
 * @sb:		The &super_block identifying the filesystem
 * @sb:		The &super_block identifying the filesystem
@@ -166,21 +187,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
	 */
	 */
	noprogress = 0;
	noprogress = 0;
	while (target_dir->d_flags & DCACHE_DISCONNECTED && noprogress++ < 10) {
	while (target_dir->d_flags & DCACHE_DISCONNECTED && noprogress++ < 10) {
		struct dentry *pd = target_dir;
		struct dentry *pd = find_disconnected_root(target_dir);

		dget(pd);
		spin_lock(&pd->d_lock);
		while (!IS_ROOT(pd) &&
				(pd->d_parent->d_flags&DCACHE_DISCONNECTED)) {
			struct dentry *parent = pd->d_parent;

			dget(parent);
			spin_unlock(&pd->d_lock);
			dput(pd);
			pd = parent;
			spin_lock(&pd->d_lock);
		}
		spin_unlock(&pd->d_lock);


		if (!IS_ROOT(pd)) {
		if (!IS_ROOT(pd)) {
			/* must have found a connected parent - great */
			/* must have found a connected parent - great */