Subject: afs/fs/afs vnode.c,1.5,1.6 file.c,1.6,1.7

From: [email-masked]
Date: Tue, 10 Jun 2003 18:49:52 +0100

Update of /home/cvs/afs/fs/afs
In directory phoenix.infradead.org:/tmp/cvs-serv4409/fs/afs

Modified Files:
	vnode.c file.c 
Log Message:
fix some oopses

Index: vnode.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/vnode.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vnode.c	9 Jun 2003 13:52:04 -0000	1.5
+++ vnode.c	10 Jun 2003 17:49:49 -0000	1.6
@@ -352,7 +352,7 @@
 	struct afs_cache_vnode *cvnode = entry;
 	struct afs_vnode *vnode = source;
 
-	kenter("");
+	_enter("");
 
 	cvnode->vnode = vnode->fid.vnode;

Index: file.c
===================================================================
RCS file: /home/cvs/afs/fs/afs/file.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- file.c	9 Jun 2003 13:39:13 -0000	1.6
+++ file.c	10 Jun 2003 17:49:49 -0000	1.7
@@ -28,6 +28,8 @@
 #endif
 
 static int afs_file_readpage(struct file *file, struct page *page);
+static int afs_file_invalidatepage(struct page *page, unsigned long offset);
+static int afs_file_releasepage(struct page *page, int gfp_flags);
 
 static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off);
 
@@ -50,8 +52,8 @@
 	.readpage	= afs_file_readpage,
 	.sync_page	= block_sync_page,
 	.set_page_dirty	= __set_page_dirty_nobuffers,
-	.releasepage	= cachefs_releasepage,
-	.invalidatepage	= cachefs_invalidatepage,
+	.releasepage	= afs_file_releasepage,
+	.invalidatepage	= afs_file_invalidatepage,
 };
 
 /*****************************************************************************/
@@ -142,7 +144,7 @@
 		/* read BIO submitted (page in cache) */
 	case 0:
 		break;
-		
+
 		/* no page available in cache */
 	case -ENOBUFS:
 	case -ENODATA:
@@ -164,7 +166,7 @@
 				ret = -ESTALE;
 			}
 
-			cachefs_uncache_page(vnode->cache,page,pageio);
+			cachefs_uncache_page(vnode->cache,page);
 			goto error;
 		}
 
@@ -176,7 +178,7 @@
 				       NULL,
 				       GFP_KERNEL) != 0
 		    ) {
-			cachefs_uncache_page(vnode->cache,page,pageio);
+			cachefs_uncache_page(vnode->cache,page);
 			unlock_page(page);
 		}
 	}
@@ -207,3 +209,57 @@
 	_leave(" = %d",ret);
 	return ret;
 } /* end afs_cache_get_page_cookie() */
+
+/*****************************************************************************/
+/*
+ * invalidate part or all of a page
+ */
+static int afs_file_invalidatepage(struct page *page, unsigned long offset)
+{
+	struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
+	int ret = 1;
+
+	_enter("{%lu},%lu",page->index,offset);
+
+	BUG_ON(!PageLocked(page));
+	if (PagePrivate(page)) {
+		cachefs_uncache_page(vnode->cache,page);
+
+		/*
+		 * We release buffers only if the entire page is being invalidated.
+		 * The get_block cached value has been unconditionally invalidated,
+		 * so real IO is not possible anymore.
+		 */
+		if (offset == 0)
+			ret = try_to_release_page(page,0);
+	}
+
+	_leave(" = %d",ret);
+	return ret;
+} /* end afs_file_invalidatepage() */
+
+/*****************************************************************************/
+/*
+ * release a page and cleanup its private data
+ */
+static int afs_file_releasepage(struct page *page, int gfp_flags)
+{
+	struct cachefs_page *pageio;
+	struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
+
+	_enter("{%lu},%x",page->index,gfp_flags);
+
+	if (PagePrivate(page)) {
+		cachefs_uncache_page(vnode->cache,page);
+
+		pageio = (struct cachefs_page *) page->private;
+		page->private = 0;
+		ClearPagePrivate(page);
+
+		if (pageio)
+			kfree(pageio);
+	}
+
+	_leave(" = 0");
+	return 0;
+} /* end afs_file_releasepage() */