linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch] ramfs accounting in -ac broken
@ 2001-05-17 14:54 Christoph Rohland
  0 siblings, 0 replies; only message in thread
From: Christoph Rohland @ 2001-05-17 14:54 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-17 15:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-17 14:54 [Patch] ramfs accounting in -ac broken Christoph Rohland

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).