cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/1] table_seq_next should increase position index
@ 2020-01-24  6:03 Vasily Averin
  2020-02-26  7:13 ` Vasily Averin
  0 siblings, 1 reply; 2+ messages in thread
From: Vasily Averin @ 2020-01-24  6:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

if seq_file .next fuction does not change position index,
read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/dlm/debug_fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index d6bbccb..c1eda93 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -523,7 +523,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
 		ri->rsb = r;
 		spin_unlock(&ls->ls_rsbtbl[bucket].lock);
 		dlm_put_rsb(rp);
-		++*pos;
+		++(*pos);
 		return ri;
 	}
 	spin_unlock(&ls->ls_rsbtbl[bucket].lock);
@@ -542,6 +542,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
 
 		if (bucket >= ls->ls_rsbtbl_size) {
 			kfree(ri);
+			++(*pos);
 			return NULL;
 		}
 		tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH 1/1] table_seq_next should increase position index
  2020-01-24  6:03 [Cluster-devel] [PATCH 1/1] table_seq_next should increase position index Vasily Averin
@ 2020-02-26  7:13 ` Vasily Averin
  0 siblings, 0 replies; 2+ messages in thread
From: Vasily Averin @ 2020-02-26  7:13 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Could I get any comments?

Unfortunately I do not have enough experience with dlm and cannot verify the patch locally

Usually you can observe following related problems:
- read after lseek beyond end of file, described by NeilBrown in  
 commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")
 "dd if=<AFFECTED_FILE> bs=1000 skip=1" will incorrectly generate whole last line

- read after lseek on into middle of last line will output expected rest of
 last line but then repeat whole last line once again. 

- If .show() function generates multi-line output following bash script will never finish.

 $ q=;while read -r r;do echo "$((++q)) $r";done < AFFECTED_FILE

Thank you,
	Vasily Averin

On 1/24/20 9:03 AM, Vasily Averin wrote:
> if seq_file .next fuction does not change position index,
> read after some lseek can generate unexpected output.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=206283
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> ---
>  fs/dlm/debug_fs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
> index d6bbccb..c1eda93 100644
> --- a/fs/dlm/debug_fs.c
> +++ b/fs/dlm/debug_fs.c
> @@ -523,7 +523,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
>  		ri->rsb = r;
>  		spin_unlock(&ls->ls_rsbtbl[bucket].lock);
>  		dlm_put_rsb(rp);
> -		++*pos;
> +		++(*pos);
>  		return ri;
>  	}
>  	spin_unlock(&ls->ls_rsbtbl[bucket].lock);
> @@ -542,6 +542,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
>  
>  		if (bucket >= ls->ls_rsbtbl_size) {
>  			kfree(ri);
> +			++(*pos);
>  			return NULL;
>  		}
>  		tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
> 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-26  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-24  6:03 [Cluster-devel] [PATCH 1/1] table_seq_next should increase position index Vasily Averin
2020-02-26  7:13 ` Vasily Averin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).