Skip to contentSkip to conversation

2.4.5-ac13 ramfs and tmpfs accounting

PATCH New Christoph Rohland 1 participant 1 message Jun 13, 2001

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.5-ac13 ramfs and tmpfs accounting

Hi Alan,

ramfs accounting does not get notified when a clean page gets dropped from the inode.

Also tmpfs should use the new function to do accurate accounting. Else the cached field in -ac will get spurious negative values.

The following patch fixes both.

Greetings
Christoph

fs/ramfs/inode.c +2 -2
diff -uNr 5-ac13/fs/ramfs/inode.c 5-ac13-a/fs/ramfs/inode.c
@@ -289,7 +289,7 @@
 	return 0;
 }
 
-static void ramfs_truncatepage(struct page *page)
+static void ramfs_removepage(struct page *page)
 {
 	struct inode *inode = (struct inode *)page->mapping->host;
 
@@ -659,7 +659,7 @@
 	writepage:	ramfs_writepage,
 	prepare_write:	ramfs_prepare_write,
 	commit_write:	ramfs_commit_write,
-	truncatepage:	ramfs_truncatepage,
+	removepage:	ramfs_removepage,
 };
 
 static struct file_operations ramfs_file_operations = {
include/linux/fs.h +1 -1
diff -uNr 5-ac13/include/linux/fs.h 5-ac13-a/include/linux/fs.h
@@ -368,7 +368,7 @@
 	int (*sync_page)(struct page *);
 	int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
 	int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
-	void (*truncatepage)(struct page *); /* called from truncate_complete_page */
+	void (*removepage)(struct page *); /* called when page gets removed from the inode */
 	/* Unfortunately this kludge is needed for FIBMAP. Don't use it */
 	int (*bmap)(struct address_space *, long);
 };
mm/filemap.c +3 -3
diff -uNr 5-ac13/mm/filemap.c 5-ac13-a/mm/filemap.c
@@ -82,6 +82,9 @@
 {
 	struct address_space * mapping = page->mapping;
 
+	if (mapping->a_ops->removepage)
+		mapping->a_ops->removepage(page);
+	
 	mapping->nrpages--;
 	list_del(&page->list);
 	page->mapping = NULL;
@@ -206,9 +209,6 @@
 	if (!page->buffers || block_flushpage(page, 0))
 		lru_cache_del(page);
 
-	if (page->mapping->a_ops->truncatepage)
-		page->mapping->a_ops->truncatepage(page);
-	
 	/*
 	 * We remove the page from the page cache _after_ we have
 	 * destroyed all buffer-cache references to it. Otherwise some
mm/shmem.c +14 -37

83 lines not on this page · raw message