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

Commit e2dfa935 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Al Viro
Browse files

vfs: factor out lookup_mountpoint from new_mountpoint



I am shortly going to add a new user of struct mountpoint that
needs to look up existing entries but does not want to create
a struct mountpoint if one does not exist.  Therefore to keep
the code simple and easy to read split out lookup_mountpoint
from new_mountpoint.

Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0a5eb7c8
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -703,11 +703,10 @@ bool __is_local_mountpoint(struct dentry *dentry)
	return is_covered;
}

static struct mountpoint *new_mountpoint(struct dentry *dentry)
static struct mountpoint *lookup_mountpoint(struct dentry *dentry)
{
	struct hlist_head *chain = mp_hash(dentry);
	struct mountpoint *mp;
	int ret;

	hlist_for_each_entry(mp, chain, m_hash) {
		if (mp->m_dentry == dentry) {
@@ -718,6 +717,14 @@ static struct mountpoint *new_mountpoint(struct dentry *dentry)
			return mp;
		}
	}
	return NULL;
}

static struct mountpoint *new_mountpoint(struct dentry *dentry)
{
	struct hlist_head *chain = mp_hash(dentry);
	struct mountpoint *mp;
	int ret;

	mp = kmalloc(sizeof(struct mountpoint), GFP_KERNEL);
	if (!mp)
@@ -1818,7 +1825,9 @@ static struct mountpoint *lock_mount(struct path *path)
	namespace_lock();
	mnt = lookup_mnt(path);
	if (likely(!mnt)) {
		struct mountpoint *mp = new_mountpoint(dentry);
		struct mountpoint *mp = lookup_mountpoint(dentry);
		if (!mp)
			mp = new_mountpoint(dentry);
		if (IS_ERR(mp)) {
			namespace_unlock();
			mutex_unlock(&dentry->d_inode->i_mutex);