Hi Alan,

The ramfs accounting is broken for shared mmaps. It simply does not
recognize the pages allocated by writing into a shared mapping but
takes them into account when freed.

The attached patch should fix that.

Greetings
                Christoph

--- 4-ac9/fs/ramfs/inode.c      Thu May 17 16:51:57 2001
+++ u4ac9/fs/ramfs/inode.c      Thu May 17 14:47:48 2001
@@ -163,9 +163,6 @@
        struct ramfs_sb_info *rsb = RAMFS_SB(inode->i_sb);
        int ret = 1;
 
-       if (PageDirty(page)) /* It's already been allocated */
-               return 1;
-
        lock_rsb(rsb);
                
        if ( (rsb->free_pages > 0) &&
@@ -185,8 +182,7 @@
 {
        struct ramfs_sb_info *rsb = RAMFS_SB(inode->i_sb);
 
-       if (! PageDirty(page)) /* The page was never allocated 
-                                 this can happen if it was only read */
+       if (! Page_Uptodate(page))
                return;
 
        lock_rsb(rsb);
@@ -241,6 +237,8 @@
 static int ramfs_readpage(struct file *file, struct page * page)
 {
        if (!Page_Uptodate(page)) {
+               if (!ramfs_alloc_page(file->f_dentry->d_inode, page))
+                       return -ENOSPC;
                memset(kmap(page), 0, PAGE_CACHE_SIZE);
                kunmap(page);
                flush_dcache_page(page);
@@ -266,11 +264,12 @@
        struct inode *inode = (struct inode *)page->mapping->host;
        void *addr;
        
-       if (! ramfs_alloc_page(inode, page))
-               return -ENOSPC;
-
        addr = (void *) kmap(page);
        if (!Page_Uptodate(page)) {
+               if (! ramfs_alloc_page(inode, page)) {
+                       kunmap(page);
+                       return -ENOSPC;
+               }
                memset(addr, 0, PAGE_CACHE_SIZE);
                flush_dcache_page(page);
                SetPageUptodate(page);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to