[RFC PATCH v3 1/8] fuse: simplify fuse_lookup_name() interface

Luis Henriques posted 8 patches 1 month, 1 week ago
[RFC PATCH v3 1/8] fuse: simplify fuse_lookup_name() interface
Posted by Luis Henriques 1 month, 1 week ago
fuse_lookup_name() requires a struct fuse_entry_out to be passed in.
However, the only caller that really needs it is fuse_lookup().  And even
this function only cares about the dentry time.

This patch simplifies fuse_lookup_name() so that it doesn't require a struct
as a parameter, replacing it by a local variable.  Instead, there'll be an
(optional) out argument, that can be used to return the dentry time.

Signed-off-by: Luis Henriques <luis@igalia.com>
---
 fs/fuse/dir.c    | 36 +++++++++++++++++++-----------------
 fs/fuse/fuse_i.h |  2 +-
 fs/fuse/inode.c  |  7 ++-----
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ef297b867060..e3000affff88 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -548,10 +548,11 @@ bool fuse_invalid_attr(struct fuse_attr *attr)
 }
 
 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
-		     struct fuse_entry_out *outarg, struct inode **inode)
+		     u64 *time, struct inode **inode)
 {
 	struct fuse_mount *fm = get_fuse_mount_super(sb);
 	FUSE_ARGS(args);
+	struct fuse_entry_out outarg;
 	struct fuse_forget_link *forget;
 	u64 attr_version, evict_ctr;
 	int err;
@@ -570,30 +571,34 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
 	attr_version = fuse_get_attr_version(fm->fc);
 	evict_ctr = fuse_get_evict_ctr(fm->fc);
 
-	fuse_lookup_init(fm->fc, &args, nodeid, name, outarg);
+	fuse_lookup_init(fm->fc, &args, nodeid, name, &outarg);
 	err = fuse_simple_request(fm, &args);
 	/* Zero nodeid is same as -ENOENT, but with valid timeout */
-	if (err || !outarg->nodeid)
+	if (err || !outarg.nodeid)
 		goto out_put_forget;
 
 	err = -EIO;
-	if (fuse_invalid_attr(&outarg->attr))
+	if (fuse_invalid_attr(&outarg.attr))
 		goto out_put_forget;
-	if (outarg->nodeid == FUSE_ROOT_ID && outarg->generation != 0) {
+	if (outarg.nodeid == FUSE_ROOT_ID && outarg.generation != 0) {
 		pr_warn_once("root generation should be zero\n");
-		outarg->generation = 0;
+		outarg.generation = 0;
 	}
 
-	*inode = fuse_iget(sb, outarg->nodeid, outarg->generation,
-			   &outarg->attr, ATTR_TIMEOUT(outarg),
+	*inode = fuse_iget(sb, outarg.nodeid, outarg.generation,
+			   &outarg.attr, ATTR_TIMEOUT(&outarg),
 			   attr_version, evict_ctr);
 	err = -ENOMEM;
 	if (!*inode) {
-		fuse_queue_forget(fm->fc, forget, outarg->nodeid, 1);
+		fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1);
 		goto out;
 	}
 	err = 0;
 
+	if (time)
+		*time = fuse_time_to_jiffies(outarg.entry_valid,
+					     outarg.entry_valid_nsec);
+
  out_put_forget:
 	kfree(forget);
  out:
@@ -603,12 +608,11 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
 static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
 				  unsigned int flags)
 {
-	struct fuse_entry_out outarg;
 	struct fuse_conn *fc;
 	struct inode *inode;
 	struct dentry *newent;
+	u64 time = 0;
 	int err, epoch;
-	bool outarg_valid = true;
 	bool locked;
 
 	if (fuse_is_bad(dir))
@@ -619,12 +623,10 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
 
 	locked = fuse_lock_inode(dir);
 	err = fuse_lookup_name(dir->i_sb, get_node_id(dir), &entry->d_name,
-			       &outarg, &inode);
+			       &time, &inode);
 	fuse_unlock_inode(dir, locked);
-	if (err == -ENOENT) {
-		outarg_valid = false;
+	if (err == -ENOENT)
 		err = 0;
-	}
 	if (err)
 		goto out_err;
 
@@ -639,8 +641,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
 
 	entry = newent ? newent : entry;
 	entry->d_time = epoch;
-	if (outarg_valid)
-		fuse_change_entry_timeout(entry, &outarg);
+	if (time)
+		fuse_dentry_settime(entry, time);
 	else
 		fuse_invalidate_entry_cache(entry);
 
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 3184ef864cf0..6178a012f36c 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1149,7 +1149,7 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
 			u64 evict_ctr);
 
 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
-		     struct fuse_entry_out *outarg, struct inode **inode);
+		     u64 *time, struct inode **inode);
 
 /**
  * Send FORGET command
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 38ca362ee2ca..8231c207abea 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1089,14 +1089,12 @@ static struct dentry *fuse_get_dentry(struct super_block *sb,
 
 	inode = ilookup5(sb, handle->nodeid, fuse_inode_eq, &handle->nodeid);
 	if (!inode) {
-		struct fuse_entry_out outarg;
 		const struct qstr name = QSTR_INIT(".", 1);
 
 		if (!fc->export_support)
 			goto out_err;
 
-		err = fuse_lookup_name(sb, handle->nodeid, &name, &outarg,
-				       &inode);
+		err = fuse_lookup_name(sb, handle->nodeid, &name, NULL, &inode);
 		if (err && err != -ENOENT)
 			goto out_err;
 		if (err || !inode) {
@@ -1190,14 +1188,13 @@ static struct dentry *fuse_get_parent(struct dentry *child)
 	struct fuse_conn *fc = get_fuse_conn(child_inode);
 	struct inode *inode;
 	struct dentry *parent;
-	struct fuse_entry_out outarg;
 	int err;
 
 	if (!fc->export_support)
 		return ERR_PTR(-ESTALE);
 
 	err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode),
-			       &dotdot_name, &outarg, &inode);
+			       &dotdot_name, NULL, &inode);
 	if (err) {
 		if (err == -ENOENT)
 			return ERR_PTR(-ESTALE);
Re: [RFC PATCH v3 1/8] fuse: simplify fuse_lookup_name() interface
Posted by Miklos Szeredi 1 month, 1 week ago
On Wed, 25 Feb 2026 at 12:25, Luis Henriques <luis@igalia.com> wrote:

> @@ -570,30 +571,34 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
>         attr_version = fuse_get_attr_version(fm->fc);
>         evict_ctr = fuse_get_evict_ctr(fm->fc);
>
> -       fuse_lookup_init(fm->fc, &args, nodeid, name, outarg);
> +       fuse_lookup_init(fm->fc, &args, nodeid, name, &outarg);
>         err = fuse_simple_request(fm, &args);
>         /* Zero nodeid is same as -ENOENT, but with valid timeout */
> -       if (err || !outarg->nodeid)
> +       if (err || !outarg.nodeid)
>                 goto out_put_forget;

And now the timeout is skipped for the !outarg.nodeid  case...

Thanks,
Miklos
Re: [RFC PATCH v3 1/8] fuse: simplify fuse_lookup_name() interface
Posted by Luis Henriques 1 month, 1 week ago
On Fri, Feb 27 2026, Miklos Szeredi wrote:

> On Wed, 25 Feb 2026 at 12:25, Luis Henriques <luis@igalia.com> wrote:
>
>> @@ -570,30 +571,34 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name
>>         attr_version = fuse_get_attr_version(fm->fc);
>>         evict_ctr = fuse_get_evict_ctr(fm->fc);
>>
>> -       fuse_lookup_init(fm->fc, &args, nodeid, name, outarg);
>> +       fuse_lookup_init(fm->fc, &args, nodeid, name, &outarg);
>>         err = fuse_simple_request(fm, &args);
>>         /* Zero nodeid is same as -ENOENT, but with valid timeout */
>> -       if (err || !outarg->nodeid)
>> +       if (err || !outarg.nodeid)
>>                 goto out_put_forget;
>
> And now the timeout is skipped for the !outarg.nodeid  case...

Oops, yeah I missed that.  I'll fix it for the next iteration, thanks!

Cheers,
-- 
Luís