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

Commit ec2447c2 authored by Nick Piggin's avatar Nick Piggin
Browse files

hostfs: simplify locking



Remove dcache_lock locking from hostfs filesystem, and move it into dcache
helpers. All that is required is a coherent path name. Protection from
concurrent modification of the namespace after path name generation is not
provided in current code, because dcache_lock is dropped before the path is
used.

Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
parent b1e6a015
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -2171,7 +2171,7 @@ char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
/*
/*
 * Write full pathname from the root of the filesystem into the buffer.
 * Write full pathname from the root of the filesystem into the buffer.
 */
 */
char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
static char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
{
{
	char *end = buf + buflen;
	char *end = buf + buflen;
	char *retval;
	char *retval;
@@ -2198,7 +2198,18 @@ char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
Elong:
Elong:
	return ERR_PTR(-ENAMETOOLONG);
	return ERR_PTR(-ENAMETOOLONG);
}
}
EXPORT_SYMBOL(__dentry_path);

char *dentry_path_raw(struct dentry *dentry, char *buf, int buflen)
{
	char *retval;

	spin_lock(&dcache_lock);
	retval = __dentry_path(dentry, buf, buflen);
	spin_unlock(&dcache_lock);

	return retval;
}
EXPORT_SYMBOL(dentry_path_raw);


char *dentry_path(struct dentry *dentry, char *buf, int buflen)
char *dentry_path(struct dentry *dentry, char *buf, int buflen)
{
{
+10 −14
Original line number Original line Diff line number Diff line
@@ -92,12 +92,10 @@ __uml_setup("hostfs=", hostfs_args,


static char *__dentry_name(struct dentry *dentry, char *name)
static char *__dentry_name(struct dentry *dentry, char *name)
{
{
	char *p = __dentry_path(dentry, name, PATH_MAX);
	char *p = dentry_path_raw(dentry, name, PATH_MAX);
	char *root;
	char *root;
	size_t len;
	size_t len;


	spin_unlock(&dcache_lock);

	root = dentry->d_sb->s_fs_info;
	root = dentry->d_sb->s_fs_info;
	len = strlen(root);
	len = strlen(root);
	if (IS_ERR(p)) {
	if (IS_ERR(p)) {
@@ -123,25 +121,23 @@ static char *dentry_name(struct dentry *dentry)
	if (!name)
	if (!name)
		return NULL;
		return NULL;


	spin_lock(&dcache_lock);
	return __dentry_name(dentry, name); /* will unlock */
	return __dentry_name(dentry, name); /* will unlock */
}
}


static char *inode_name(struct inode *ino)
static char *inode_name(struct inode *ino)
{
{
	struct dentry *dentry;
	struct dentry *dentry;
	char *name = __getname();
	char *name;
	if (!name)
		return NULL;


	spin_lock(&dcache_lock);
	dentry = d_find_alias(ino);
	if (list_empty(&ino->i_dentry)) {
	if (!dentry)
		spin_unlock(&dcache_lock);
		__putname(name);
		return NULL;
		return NULL;
	}

	dentry = list_first_entry(&ino->i_dentry, struct dentry, d_alias);
	name = dentry_name(dentry);
	return __dentry_name(dentry, name); /* will unlock */

	dput(dentry);

	return name;
}
}


static char *follow_link(char *link)
static char *follow_link(char *link)
+1 −1
Original line number Original line Diff line number Diff line
@@ -311,7 +311,7 @@ extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
extern char *__d_path(const struct path *path, struct path *root, char *, int);
extern char *__d_path(const struct path *path, struct path *root, char *, int);
extern char *d_path(const struct path *, char *, int);
extern char *d_path(const struct path *, char *, int);
extern char *d_path_with_unreachable(const struct path *, char *, int);
extern char *d_path_with_unreachable(const struct path *, char *, int);
extern char *__dentry_path(struct dentry *, char *, int);
extern char *dentry_path_raw(struct dentry *, char *, int);
extern char *dentry_path(struct dentry *, char *, int);
extern char *dentry_path(struct dentry *, char *, int);


/* Allocation counts.. */
/* Allocation counts.. */