Skip to contentSkip to conversation

f2fs: fix args passed to trace_f2fs_lookup_end

PATCH Superseded Wu Bo 3 participants 4 messages May 30, 2023 – May 31, 2023 F2FS file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH v2 1/1 f2fs: fix args passed to trace_f2fs_lookup_end

The NULL return of 'd_splice_alias' dosen't mean error. Thus the successful case will also return NULL, which makes the tracepoint always print 'err=-ENOENT'.

---
 fs/f2fs/namei.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/namei.c +3 -2
index 77a71276ecb1..0c5e4c424eab 100644
@@ -576,8 +576,9 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
 	}
 #endif
 	new = d_splice_alias(inode, dentry);
-	err = PTR_ERR_OR_ZERO(new);
-	trace_f2fs_lookup_end(dir, dentry, ino, !new ? -ENOENT : err);
+	if (IS_ERR(new))
+		err = PTR_ERR(new);
+	trace_f2fs_lookup_end(dir, new ? new : dentry, ino, err);
 	return new;
 out_iput:
 	iput(inode);
Signature · 1 line
2.35.3
maintainer
#2 lore raw
In reply to Wu Bo
Quoted 14 lines · Wu Bo

The NULL return of 'd_splice_alias' dosen't mean error. Thus the successful case will also return NULL, which makes the tracepoint always print 'err=-ENOENT'.

---
 fs/f2fs/namei.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/namei.c +0 -0
index 77a71276ecb1..0c5e4c424eab 100644

fs/f2fs/namei.c static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · line 581

Quoted 8 lines
fs/f2fs/namei.c +3 -2
@@ -576,8 +576,9 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
 	}
 #endif
 	new = d_splice_alias(inode, dentry);
-	err = PTR_ERR_OR_ZERO(new);
-	trace_f2fs_lookup_end(dir, dentry, ino, !new ? -ENOENT : err);
+	if (IS_ERR(new))
+		err = PTR_ERR(new);
+	trace_f2fs_lookup_end(dir, new ? new : dentry, ino, err);

Again, new can be an error pointer, and the previous err was supposed to be zero or -ENOENT.

case 1) dentry exists: err (0) with new (NULL) --> dentry, err=0 case 2) dentry exists: err (0) with new (VALID) --> new, err=0 case 3) dentry exists: err (0) with new (ERR) --> dentry, err=ERR case 4) no dentry exists: err (-ENOENT) with new (NULL) --> dentry, err=-ENOENT case 4) no dentry exists: err (-ENOENT) with new (VALID) --> new, err=-ENOENT case 5) no dentry exists: err (-ENOENT) with new (ERR) --> dentry, err=ERR

	trace_f2fs_lookup_end(dir, !IS_ERR_OR_NULL(new) ? new : dentry,
				ino, IS_ERR(new) ? PTR_ERR(new) : err);
Quoted 5 lines
fs/f2fs/namei.c +0 -0
 	return new;
 out_iput:
 	iput(inode);
Signature · 1 line
2.35.3
maintainer
#3 lore raw
Quoted 34 lines · Jaegeuk Kim
Quoted 14 lines · Wu Bo

The NULL return of 'd_splice_alias' dosen't mean error. Thus the successful case will also return NULL, which makes the tracepoint always print 'err=-ENOENT'.

---
  fs/f2fs/namei.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/namei.c +0 -0
index 77a71276ecb1..0c5e4c424eab 100644

fs/f2fs/namei.c static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · line 581

Quoted 8 lines
fs/f2fs/namei.c +3 -2
@@ -576,8 +576,9 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
  	}
  #endif
  	new = d_splice_alias(inode, dentry);
-	err = PTR_ERR_OR_ZERO(new);
-	trace_f2fs_lookup_end(dir, dentry, ino, !new ? -ENOENT : err);
+	if (IS_ERR(new))
+		err = PTR_ERR(new);
+	trace_f2fs_lookup_end(dir, new ? new : dentry, ino, err);

Again, new can be an error pointer, and the previous err was supposed to be zero or -ENOENT.

case 1) dentry exists: err (0) with new (NULL) --> dentry, err=0 case 2) dentry exists: err (0) with new (VALID) --> new, err=0 case 3) dentry exists: err (0) with new (ERR) --> dentry, err=ERR case 4) no dentry exists: err (-ENOENT) with new (NULL) --> dentry, err=-ENOENT case 4) no dentry exists: err (-ENOENT) with new (VALID) --> new, err=-ENOENT case 5) no dentry exists: err (-ENOENT) with new (ERR) --> dentry, err=ERR

Quoted 2 lines
	trace_f2fs_lookup_end(dir, !IS_ERR_OR_NULL(new) ? new : dentry,
				ino, IS_ERR(new) ? PTR_ERR(new) : err);

Agreed, could you please add above description in commit message?

Thanks,

Quoted 7 lines
Quoted 7 lines
fs/f2fs/namei.c +0 -0
  	return new;
  out_iput:
  	iput(inode);
Signature · 1 line
2.35.3