Re: [PATCH] 2.3.14: bug-fix for raw IO error recovery

Andrea Arcangeli (andrea@suse.de)
Fri, 20 Aug 1999 13:30:58 +0200 (CEST)


On Thu, 19 Aug 1999, Linus Torvalds wrote:

>The thing is, that this is exactly what ERR_PTR and friends are there for,
>and they do it RIGHT instead of just making assumptions about things. So

I agree to not use the int -1 casted to pointer, sorry.

BTW, this make me to think about similar problems: GFP now returns an
unsigned long. What if the _address_ space of the machine is larger than
its largest _data_ word?

Returning to the raw-io issue (not strictly about the not alien-arch-clean
implementation), could it be ok? I reimplemented it in the safe way:

--- 2.3.14-pre2-rawio/mm/memory.c.~1~ Thu Aug 12 02:53:25 1999
+++ 2.3.14-pre2-rawio/mm/memory.c Fri Aug 20 13:21:36 1999
@@ -411,18 +411,17 @@
* Given a physical address, is there a useful struct page pointing to it?
*/

-static struct page * get_page_map(unsigned long page)
+static int get_page_map(unsigned long page, struct page ** map)
{
- struct page *map;
-
+ *map = NULL;
if (MAP_NR(page) >= max_mapnr)
- return 0;
+ return 1;
if (page == ZERO_PAGE(page))
return 0;
- map = mem_map + MAP_NR(page);
- if (PageReserved(map))
+ *map = mem_map + MAP_NR(page);
+ if (PageReserved(*map))
return 0;
- return map;
+ return 1;
}

/*
@@ -484,7 +483,12 @@
map = NULL;
goto retry;
}
- map = get_page_map(page);
+ if (!get_page_map(page, &map))
+ {
+ dprintk(KERN_WARNING
+ "Forbidden page_map in map_user_kiobuf\n");
+ goto out_unlock_page_table;
+ }
if (map) {
if (TryLockPage(map)) {
goto retry;
@@ -504,6 +508,8 @@
dprintk ("map_user_kiobuf: end OK\n");
return 0;

+ out_unlock_page_table:
+ spin_unlock(&mm->page_table_lock);
out_unlock:
up(&mm->mmap_sem);
unmap_kiobuf(iobuf);

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/