Small cleanups for do_path_lookup
cover Small cleanups for do_path_lookup
The following 2 patches are trivial cleanups to do_path_lookup in namei.c. Since these changes are trivial, they can go into 2.6.22-rc1 without any problems.
Josef 'Jeff' Sipek (2):
fs: Fix indentation in do_path_lookup
fs: Use path_walk in do_path_lookup
diffstat for good measure:
fs/namei.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
Josef 'Jeff' Sipek.
PATCH 1/2 fs: Fix indentation in do_path_lookup
--- fs/namei.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/namei.c +1 -1
@@ -1159,7 +1159,7 @@ out:if (likely (retval ==0 )) {if (unlikely (!audit_dummy_context () && nd && nd->dentry && nd->dentry->d_inode)) -audit_inode (name, nd->dentry->d_inode); +audit_inode (name, nd->dentry->d_inode); } out_fail:return retval;
Signature · 1 line
1.5.0.3.1043.g4342
Re: [PATCH 1/2] fs: Fix indentation in do_path_lookup
Quoted 10 lines · Josef 'Jeff' Sipek
Signed-off-by Josef 'Jeff' Sipek <[email protected]>--- fs/namei.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/namei.c +0
-0
fs/namei.c out: · line 1163
Quoted 6 lines
fs/namei.c +1
-1@@ -1159,7 +1159,7 @@ out:if (likely (retval ==0 )) {if (unlikely (!audit_dummy_context () && nd && nd->dentry && nd->dentry->d_inode)) -audit_inode (name, nd->dentry->d_inode); +audit_inode (name, nd->dentry->d_inode); }
Actually this area should get some more changes. There should be no likely retval == 0 branch because it only contains another branch, and nd is guaranteed to be zero.
So it should become:
if (unlikely(!retval && !audit_dummy_context() && nd->dentry && nd->dentry->d_inode)) audit_inode(name, nd->dentry->d_inode);
PATCH 1/1 fs: Fix indentation in do_path_lookup
--- fs/namei.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
fs/namei.c +2 -4
@@ -1156,11 +1156,9 @@ static int fastcall do_path_lookup(int dfd, const char *name, current->total_link_count =0 ; retval =link_path_walk (name, nd); out: -if (likely (retval ==0 )) { -if (unlikely (!audit_dummy_context () && nd && nd->dentry && - nd->dentry->d_inode)) +if (unlikely (!retval && !audit_dummy_context () && nd && + nd->dentry && nd->dentry->d_inode))audit_inode (name, nd->dentry->d_inode); - } out_fail:return retval;
Signature · 1 line
1.5.2.rc1.20.g86b9
Re: [PATCH] fs: Fix indentation in do_path_lookup
fs/namei.c static int fastcall do_path_lookup(int dfd, const char *name, · line 1160
Quoted 2 lines · Josef 'Jeff' Sipek
fs/namei.c +2
-0+if (unlikely (!retval && !audit_dummy_context () && nd && + nd->dentry && nd->dentry->d_inode))
the check for nd is not needed either as I hopefully mentioned in my last mail.
Re: [PATCH 1/2] fs: Fix indentation in do_path_lookup
In reply to Christoph HellwigQuoted 17 lines · Christoph Hellwig
Quoted 16 lines · Josef 'Jeff' Sipek
Signed-off-by Josef 'Jeff' Sipek <[email protected]>--- fs/namei.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/namei.c +1
-1@@ -1159,7 +1159,7 @@ out:if (likely (retval ==0 )) {if (unlikely (!audit_dummy_context () && nd && nd->dentry && nd->dentry->d_inode)) -audit_inode (name, nd->dentry->d_inode); +audit_inode (name, nd->dentry->d_inode); }
...
Quoted 1 line
nd is guaranteed to be zero.
Should that say non-zero?
Josef "Jeff" Sipek.
Signature · 1 line
Humans were created by water to transport it upward.
Re: [PATCH 1/2] fs: Fix indentation in do_path_lookup
Quoted 19 lines · Josef Sipek
Quoted 17 lines · Christoph Hellwig
Quoted 16 lines · Josef 'Jeff' Sipek
Signed-off-by Josef 'Jeff' Sipek <[email protected]>--- fs/namei.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/namei.c +1
-1@@ -1159,7 +1159,7 @@ out:if (likely (retval ==0 )) {if (unlikely (!audit_dummy_context () && nd && nd->dentry && nd->dentry->d_inode)) -audit_inode (name, nd->dentry->d_inode); +audit_inode (name, nd->dentry->d_inode); }...
Quoted 3 lines
Quoted 1 line
nd is guaranteed to be zero.
Should that say non-zero?
Yes, sorry.
PATCH 2/2 fs: Use path_walk in do_path_lookup
In reply to Josef 'Jeff' SipekSince, path_walk sets the total_link_count to 0, and calls link_path_walk, we can just call path_walk directly.
--- fs/namei.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/namei.c +2 -2
@@ -1153,8 +1153,8 @@ static int fastcall do_path_lookup(int dfd, const char *name,fput_light (file, fput_needed); } - current->total_link_count =0 ; - retval =link_path_walk (name, nd); + + retval =path_walk (name, nd); out:if (likely (retval ==0 )) { if (unlikely(!audit_dummy_context() && nd && nd->dentry &&
Signature · 1 line
1.5.0.3.1043.g4342
Re: [PATCH 2/2] fs: Use path_walk in do_path_lookup
Quoted 2 lines · Josef 'Jeff' Sipek
Since,
path_walksets thetotal_link_countto 0, and callslink_path_walk, we can just callpath_walkdirectly.
Ok.