Skip to contentSkip to conversation

walk_component(): get inode in lookup_slow branch statement block

PATCH In review sunliming 3 participants 6 messages Jun 22, 2022 – Jun 23, 2022 VFS

lore
Share & tools
lore

sunliming

author
#0 lore raw

PATCH 1/1 walk_component(): get inode in lookup_slow branch statement block

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

---
 fs/namei.c | 2 ++
 1 file changed, 2 insertions(+)
fs/namei.c +2 -0
index 1f28d3f463c3..a1a3e9514f46 100644
@@ -2014,6 +2014,8 @@ static const char *walk_component(struct nameidata *nd, int flags)
 		dentry = lookup_slow(&nd->last, nd->path.dentry, nd->flags);
 		if (IS_ERR(dentry))
 			return ERR_CAST(dentry);
+
+		inode = d_backing_inode(dentry);
 	}
 	if (!(flags & WALK_MORE) && nd->depth)
 		put_link(nd);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 3 lines · sunliming

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

Take a good look at handle_mounts() and the things it does when *not* in RCU mode (i.e. LOOKUP_RCU is not set). Specifically,
*inode = d_backing_inode(path->dentry);
*seqp = 0; /* out of RCU mode, so the value doesn't matter */
this part.

IOW, the values passed to step_into() in inode/seq are overridden unless we stay in RCU mode. And if we'd been through lookup_slow(), we'd been out of RCU mode since before we called step_into().

#2 lore raw
Quoted 12 lines · Al Viro <[email protected]> 于2022年6月22日周三 18:35写道:
Quoted 3 lines · sunliming

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

Take a good look at handle_mounts() and the things it does when *not* in RCU mode (i.e. LOOKUP_RCU is not set). Specifically,
*inode = d_backing_inode(path->dentry);
*seqp = 0; /* out of RCU mode, so the value doesn't matter */
this part.

Quoted 3 lines

IOW, the values passed to step_into() in inode/seq are overridden unless we stay in RCU mode. And if we'd been through lookup_slow(), we'd been out of RCU mode since before we called step_into().

It might be more appropriate and easier to understand to do this before parameter passing in the top-level walk_component function?

maintainer
#3 lore raw
Quoted 13 lines · sunliming
Quoted 12 lines · Al Viro <[email protected]> 于2022年6月22日周三 18:35写道:
Quoted 3 lines · sunliming

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

Take a good look at handle_mounts() and the things it does when *not* in RCU mode (i.e. LOOKUP_RCU is not set). Specifically,
*inode = d_backing_inode(path->dentry);
*seqp = 0; /* out of RCU mode, so the value doesn't matter */
this part.

Quoted 6 lines
Quoted 3 lines

IOW, the values passed to step_into() in inode/seq are overridden unless we stay in RCU mode. And if we'd been through lookup_slow(), we'd been out of RCU mode since before we called step_into().

It might be more appropriate and easier to understand to do this before parameter passing in the top-level walk_component function?

It's possible to fall out of RCU mode *inside* step_into(), so we need it done there anyway. Unfortunately ;-/

#4 lore raw
Quoted 19 lines · Al Viro <[email protected]> 于2022年6月23日周四 11:48写道:
Quoted 17 lines · sunliming
Quoted 15 lines · Al Viro <[email protected]> 于2022年6月22日周三 18:35写道:
Quoted 3 lines · sunliming

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

Take a good look at handle_mounts() and the things it does when *not* in RCU mode (i.e. LOOKUP_RCU is not set). Specifically,
*inode = d_backing_inode(path->dentry);
*seqp = 0; /* out of RCU mode, so the value doesn't matter */
this part.

IOW, the values passed to step_into() in inode/seq are overridden unless we stay in RCU mode. And if we'd been through lookup_slow(), we'd been out of RCU mode since before we called step_into().

Quoted 5 lines
Quoted 2 lines

It might be more appropriate and easier to understand to do this before parameter passing in the top-level walk_component function?

It's possible to fall out of RCU mode *inside* step_into(), so we need it done there anyway. Unfortunately ;-/

Thanks for your explanation

#5 lore raw
In reply to Al Viro
Quoted 12 lines · Al Viro <[email protected]> 于2022年6月22日周三 18:35写道:
Quoted 3 lines · sunliming

The inode variable is used as a parameter by the step_into function, but is not assigned a value in the sub-lookup_slow branch path. So get the inode in the sub-lookup_slow branch path.

Take a good look at handle_mounts() and the things it does when *not* in RCU mode (i.e. LOOKUP_RCU is not set). Specifically,
*inode = d_backing_inode(path->dentry);
*seqp = 0; /* out of RCU mode, so the value doesn't matter */
this part.

Quoted 3 lines

IOW, the values passed to step_into() in inode/seq are overridden unless we stay in RCU mode. And if we'd been through lookup_slow(), we'd been out of RCU mode since before we called step_into().

OK,I got it.