Skip to contentSkip to conversation

ocfs2: update seq_file index in ocfs2_dlm_seq_next

PATCH In review Wengang Wang 3 participants 6 messages Nov 8, 2024 – Feb 15, 2025 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: update seq_file index in ocfs2_dlm_seq_next

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
 fs/ocfs2/dlmglue.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +1 -0
index 60df52e4c1f8..349d131369cf 100644
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 	}
 	spin_unlock(&ocfs2_dlm_tracking_lock);
 
+	m->index++;
 	return iter;
 }
 
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer
#1 lore raw
Quoted 19 lines · Wengang Wang

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
 fs/ocfs2/dlmglue.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +0 -0
index 60df52e4c1f8..349d131369cf 100644

fs/ocfs2/dlmglue.c static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) · line 3123

Quoted 4 lines
fs/ocfs2/dlmglue.c +1 -0
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 	}
 	spin_unlock(&ocfs2_dlm_tracking_lock);
 
+	m->index++;

We can directly use '(*pos)++' instead.

Thanks,
Joseph

Quoted 3 lines
fs/ocfs2/dlmglue.c +0 -0
 	return iter;
 }
 
#2 lore raw
Quoted 29 lines · Joseph Qi
Quoted 22 lines · Wengang Wang

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
fs/ocfs2/dlmglue.c | 1 +

1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +0 -0
index 60df52e4c1f8..349d131369cf 100644
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 }
 spin_unlock(&ocfs2_dlm_tracking_lock);
 
Quoted 4 lines

fs/ocfs2/dlmglue.c static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) · line 3123

Quoted 1 line
fs/ocfs2/dlmglue.c +1 -0
+ m->index++;

We can directly use '(*pos)++' instead.

The input/output "pos” indicates more an offset into the file. Actually the output for an item is not really 1 byte in length, so incrementing the offset by 1 sounds a bit strange to me. Instead If we increment the “index”, It would be easier to understand it as for next item. Though updating “index” or updating “*pos” instead makes no difference to binary running, the code understanding is different. I know other seq_operations.next functions are directly incrementing the “*pos”, I think updating “index” is better. Well, if you persist (*pos)++, I will also let it go.

Thanks,
Wengang

maintainer
#3 lore raw
Quoted 29 lines · Wengang Wang
Quoted 29 lines · Joseph Qi
Quoted 22 lines · Wengang Wang

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
fs/ocfs2/dlmglue.c | 1 +

1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +0 -0
index 60df52e4c1f8..349d131369cf 100644
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 }
 spin_unlock(&ocfs2_dlm_tracking_lock);
 
Quoted 7 lines
Quoted 4 lines

fs/ocfs2/dlmglue.c static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) · line 3123

Quoted 1 line
fs/ocfs2/dlmglue.c +1 -0
+ m->index++;

We can directly use '(*pos)++' instead.

The input/output "pos” indicates more an offset into the file. Actually the output for an item is not really 1 byte in length, so incrementing the offset by 1 sounds a bit strange to me. Instead If we increment the “index”, It would be easier to understand it as for next item. Though updating “index” or updating “*pos” instead makes no difference to binary running, the code understanding is different. I know other seq_operations.next functions are directly incrementing the “*pos”, I think updating “index” is better. Well, if you persist (*pos)++, I will also let it go.

From seq_read_iter(), the input pos is equivalent to '&m->index'. So the above two ways seems have no functional difference.
IMO, we'd better hide the m->index logic into seqfile and just use pos instead like other .next implementations.

Thanks,
Joseph

#4 lore raw
Quoted 37 lines · On Mon, 11 Nov 2024 17:35:49 +0800 Joseph Qi <[email protected]>…
Quoted 34 lines · Wengang Wang
Quoted 33 lines · Joseph Qi
Quoted 19 lines · Wengang Wang

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
fs/ocfs2/dlmglue.c | 1 +

1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +0 -0
index 60df52e4c1f8..349d131369cf 100644

fs/ocfs2/dlmglue.c static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) · line 3123

Quoted 4 lines
fs/ocfs2/dlmglue.c +1 -0
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 }
 spin_unlock(&ocfs2_dlm_tracking_lock);
 
+ m->index++;

We can directly use '(*pos)++' instead.

Quoted 6 lines
Quoted 3 lines

The input/output "pos” indicates more an offset into the file. Actually the output for an item is not really 1 byte in length, so incrementing the offset by 1 sounds a bit strange to me. Instead If we increment the “index”, It would be easier to understand it as for next item. Though updating “index” or updating “*pos” instead makes no difference to binary running, the code understanding is different. I know other seq_operations.next functions are directly incrementing the “*pos”, I think updating “index” is better. Well, if you persist (*pos)++, I will also let it go.

From seq_read_iter(), the input pos is equivalent to '&m->index'. So the

above two ways seems have no functional difference.
IMO, we'd better hide the m->index logic into seqfile and just use pos instead like other .next implementations.

Did we ever fix this?

#5 lore raw
Quoted 43 lines · Andrew Morton
Quoted 37 lines · On Mon, 11 Nov 2024 17:35:49 +0800 Joseph Qi <[email protected]>…
Quoted 34 lines · Wengang Wang
Quoted 33 lines · Joseph Qi
Quoted 19 lines · Wengang Wang

The following INFO level message was seen:

seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index

Fix:
Updata m->index to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.

---
fs/ocfs2/dlmglue.c | 1 +

1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +0 -0
index 60df52e4c1f8..349d131369cf 100644

fs/ocfs2/dlmglue.c static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) · line 3123

Quoted 4 lines
fs/ocfs2/dlmglue.c +1 -0
@@ -3120,6 +3120,7 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 }
 spin_unlock(&ocfs2_dlm_tracking_lock);
 
+ m->index++;

We can directly use '(*pos)++' instead.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

The input/output "pos” indicates more an offset into the file. Actually the output for an item is not really 1 byte in length, so incrementing the offset by 1 sounds a bit strange to me. Instead If we increment the “index”, It would be easier to understand it as for next item. Though updating “index” or updating “*pos” instead makes no difference to binary running, the code understanding is different. I know other seq_operations.next functions are directly incrementing the “*pos”, I think updating “index” is better. Well, if you persist (*pos)++, I will also let it go.

From seq_read_iter(), the input pos is equivalent to '&m->index'. So the

above two ways seems have no functional difference.
IMO, we'd better hide the m->index logic into seqfile and just use pos instead like other .next implementations.

Did we ever fix this?

Yes, fix is already in upstream code.

Thanks,
Wengang