Unverified Commit d4db7103 authored by Christian Brauner's avatar Christian Brauner
Browse files

Merge patch series "Minor cleanup preparation for some dir-locking API changes"

NeilBrown <neil@brown.name> says:

The following 4 patches provide further cleanup that serves as
preparation for some dir-locking API changes that I want to make.

* patches from https://lore.kernel.org/20250608230952.20539-1-neil@brown.name:
  exportfs: use lookup_one_unlocked()
  coda: use iterate_dir() in coda_readdir()
  VFS: Minor fixes for porting.rst
  VFS: merge lookup_one_qstr_excl_raw() back into lookup_one_qstr_excl()

Link: https://lore.kernel.org/20250608230952.20539-1-neil@brown.name


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parents 19272b37 ce349003
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -1224,9 +1224,6 @@ lookup_noperm_unlocked(), lookup_noperm_positive_unlocked(). They now
take a qstr instead of separate name and length.  QSTR() can be used
when strlen() is needed for the length.

For try_lookup_noperm() a reference to the qstr is passed in case the
hash might subsequently be needed.

These function no longer do any permission checking - they previously
checked that the caller has 'X' permission on the parent.  They must
ONLY be used internally by a filesystem on itself when it knows that
+2 −10
Original line number Diff line number Diff line
@@ -429,17 +429,9 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
	cfi = coda_ftoc(coda_file);
	host_file = cfi->cfi_container;

	if (host_file->f_op->iterate_shared) {
		struct inode *host_inode = file_inode(host_file);
		ret = -ENOENT;
		if (!IS_DEADDIR(host_inode)) {
			inode_lock_shared(host_inode);
			ret = host_file->f_op->iterate_shared(host_file, ctx);
			file_accessed(host_file);
			inode_unlock_shared(host_inode);
		}
	ret = iterate_dir(host_file, ctx);
	if (ret != -ENOTDIR)
		return ret;
	}
	/* Venus: we must read Venus dirents from a file */
	return coda_venus_readdir(coda_file, ctx);
}
+1 −3
Original line number Diff line number Diff line
@@ -549,15 +549,13 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
			goto err_result;
		}

		inode_lock(target_dir->d_inode);
		nresult = lookup_one(mnt_idmap(mnt), &QSTR(nbuf), target_dir);
		nresult = lookup_one_unlocked(mnt_idmap(mnt), &QSTR(nbuf), target_dir);
		if (!IS_ERR(nresult)) {
			if (unlikely(nresult->d_inode != result->d_inode)) {
				dput(nresult);
				nresult = ERR_PTR(-ESTALE);
			}
		}
		inode_unlock(target_dir->d_inode);
		/*
		 * At this point we are done with the parent, but it's pinned
		 * by the child dentry anyway.
+14 −23
Original line number Diff line number Diff line
@@ -1665,9 +1665,17 @@ static struct dentry *lookup_dcache(const struct qstr *name,
	return dentry;
}

static struct dentry *lookup_one_qstr_excl_raw(const struct qstr *name,
					       struct dentry *base,
					       unsigned int flags)
/*
 * Parent directory has inode locked exclusive.  This is one
 * and only case when ->lookup() gets called on non in-lookup
 * dentries - as the matter of fact, this only gets called
 * when directory is guaranteed to have no in-lookup children
 * at all.
 * Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't passed.
 * Will return -EEXIST if name is found and LOOKUP_EXCL was passed.
 */
struct dentry *lookup_one_qstr_excl(const struct qstr *name,
				    struct dentry *base, unsigned int flags)
{
	struct dentry *dentry;
	struct dentry *old;
@@ -1675,7 +1683,7 @@ static struct dentry *lookup_one_qstr_excl_raw(const struct qstr *name,

	dentry = lookup_dcache(name, base, flags);
	if (dentry)
		return dentry;
		goto found;

	/* Don't create child dentry for a dead directory. */
	dir = base->d_inode;
@@ -1691,24 +1699,7 @@ static struct dentry *lookup_one_qstr_excl_raw(const struct qstr *name,
		dput(dentry);
		dentry = old;
	}
	return dentry;
}

/*
 * Parent directory has inode locked exclusive.  This is one
 * and only case when ->lookup() gets called on non in-lookup
 * dentries - as the matter of fact, this only gets called
 * when directory is guaranteed to have no in-lookup children
 * at all.
 * Will return -ENOENT if name isn't found and LOOKUP_CREATE wasn't passed.
 * Will return -EEXIST if name is found and LOOKUP_EXCL was passed.
 */
struct dentry *lookup_one_qstr_excl(const struct qstr *name,
				    struct dentry *base, unsigned int flags)
{
	struct dentry *dentry;

	dentry = lookup_one_qstr_excl_raw(name, base, flags);
found:
	if (IS_ERR(dentry))
		return dentry;
	if (d_is_negative(dentry) && !(flags & LOOKUP_CREATE)) {
@@ -2790,7 +2781,7 @@ struct dentry *kern_path_locked_negative(const char *name, struct path *path)
	if (unlikely(type != LAST_NORM))
		return ERR_PTR(-EINVAL);
	inode_lock_nested(parent_path.dentry->d_inode, I_MUTEX_PARENT);
	d = lookup_one_qstr_excl_raw(&last, parent_path.dentry, 0);
	d = lookup_one_qstr_excl(&last, parent_path.dentry, LOOKUP_CREATE);
	if (IS_ERR(d)) {
		inode_unlock(parent_path.dentry->d_inode);
		return d;