
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	Fri Jan 14 15:35:02 2005
+++ 25-akpm/fs/proc/task_mmu.c	Fri Jan 14 15:35:02 2005
@@ -79,6 +79,7 @@ out:
 
 static int show_map(struct seq_file *m, void *v)
 {
+	struct task_struct *task = m->private;
 	struct vm_area_struct *map = v;
 	struct file *file = map->vm_file;
 	int flags = map->vm_flags;
@@ -110,6 +111,8 @@ static int show_map(struct seq_file *m, 
 		seq_path(m, file->f_vfsmnt, file->f_dentry, "");
 	}
 	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;
 }
 
@@ -132,10 +135,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);
@@ -162,13 +163,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;
@@ -192,12 +191,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;
 }
 
_
