
From: <pmeda@akamai.com>

5th: Moved the in-range map's version update logic to m_show from
m_start and m_next.  This fixes the loss of records on the reads of
size > 4096 on boundaries.

Jeremy, can you please verify it now? This is on top of 2.6.10-mm3.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/proc/task_mmu.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff -puN fs/proc/task_mmu.c~fix-loss-of-records-on-size-4096-in-proc-pid-maps fs/proc/task_mmu.c
--- 25/fs/proc/task_mmu.c~fix-loss-of-records-on-size-4096-in-proc-pid-maps	2005-02-22 18:17:11.000000000 -0800
+++ 25-akpm/fs/proc/task_mmu.c	2005-02-22 18:17:11.000000000 -0800
@@ -87,6 +87,7 @@ static void pad_len_spaces(struct seq_fi
 
 static int show_map(struct seq_file *m, void *v)
 {
+	struct task_struct *task = m->private;
 	struct vm_area_struct *map = v;
 	struct mm_struct *mm = map->vm_mm;
 	struct file *file = map->vm_file;
@@ -138,6 +139,8 @@ static int show_map(struct seq_file *m, 
 		}
 	}
 	seq_putc(m, '\n');
+	if (m->count < m->size)  /* map is copied successfully */
+		m->version = (map != get_gate_vma(task))? map->vm_start: 0;
 	return 0;
 }
 
@@ -160,10 +163,8 @@ static void *m_start(struct seq_file *m,
 		return NULL;
 
 	mm = get_task_mm(task);
-	if (!mm) {
-		m->version = -1UL;
+	if (!mm)
 		return NULL;
-	}
 
 	tail_map = get_gate_vma(task);
 	down_read(&mm->mmap_sem);
@@ -190,13 +191,11 @@ static void *m_start(struct seq_file *m,
 		tail_map = NULL; /* After gate map */
 
 out:
-	if (map && map != tail_map) {
-		m->version = map->vm_start;
+	if (map)
 		return map;
-	}
 
 	/* End of maps has reached */
-	m->version = -1UL;
+	m->version = (tail_map != NULL)? 0: -1UL;
 	up_read(&mm->mmap_sem);
 	mmput(mm);
 	return tail_map;
@@ -220,12 +219,9 @@ static void *m_next(struct seq_file *m, 
 	struct vm_area_struct *tail_map = get_gate_vma(task);
 
 	(*pos)++;
-	if (map && (map != tail_map) && map->vm_next) {
-		m->version = map->vm_next->vm_start;
+	if (map && (map != tail_map) && map->vm_next)
 		return map->vm_next;
-	}
 	m_stop(m, v);
-	m->version = -1UL;
 	return (map != tail_map)? tail_map: NULL;
 }
 
_
