mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Rohland <cr@sap.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [Patch] ramfs accounting in -ac broken
Date: 17 May 2001 16:54:03 +0200	[thread overview]
Message-ID: <m3ofsst4ac.fsf@linux.local> (raw)

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


                 reply	other threads:[~2001-05-17 15:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ofsst4ac.fsf@linux.local \
    --to=cr@sap.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®