[OpenAFS-devel] another patch for linux 2.4 kernels...

Chas Williams chas@cmf.nrl.navy.mil
Fri, 10 Nov 2000 11:45:39 -0500


this patch adds writepage() support to file aops().  mmap() uses this
and i only had it partly working before.  after this patch this i can
actually build emacs in afs space once again.

just comparing the afs code to the other filesystems code, it looks
like afs_linux_updatepage() should really be called
afs_linux_writepage_sync() [and have the the sync arg dropped since 
it isnt used]  this would make things a bit clearer for future developers.
kunmap() shoud be probably moved to there as well and placed inside
the lock/unlock kernel.

comments?

Index: src/afs/LINUX/osi_vnodeops.c
===================================================================
RCS file: /afs/cmf/users/chas/cvsroot/openafs/src/afs/LINUX/osi_vnodeops.c,v
retrieving revision 1.3
retrieving revision 1.5
diff -u -u -r1.3 -r1.5
--- osi_vnodeops.c	2000/11/03 04:31:53	1.3
+++ osi_vnodeops.c	2000/11/10 16:29:36	1.5
@@ -1155,10 +1155,35 @@
     return -code;
 }
 
-#ifdef NOTUSED
-/* afs_linux_writepage - is this used anywhere?  swap files via nfs? */
-int afs_linux_writepage(struct inode *ip, struct page *) { return -EINVAL };
+#if defined(AFS_LINUX24_ENV)
+int afs_linux_writepage(struct file *file, struct page *page)
+{
+
+	struct dentry *dentry = file->f_dentry;
+        struct inode *inode = dentry->d_inode;
+        unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+        unsigned offset = PAGE_CACHE_SIZE;
+	long status;
 
+        /* easy case */
+        if (page->index < end_index)
+                goto do_it;
+        /* things got complicated... */
+        offset = inode->i_size & (PAGE_CACHE_SIZE-1);
+        /* OK, are we completely out? */
+        if (page->index >= end_index+1 || !offset)
+                return -EIO;
+do_it:
+        status = afs_linux_updatepage(file, page, 0, offset, 1);
+	kunmap(page);
+	if (status == offset)
+		return 0;
+	else
+		return status;
+}
+#endif
+
+#ifdef NOTUSED
 /* afs_linux_bmap - supports generic_readpage, but we roll our own. */
 int afs_linux_bmap(struct inode *ip, int) { return -EINVAL; }
 
@@ -1286,6 +1311,7 @@
 
 struct address_space_operations afs_file_aops = {
         readpage: afs_linux_readpage,
+	writepage: afs_linux_writepage,
         commit_write: afs_linux_commit_write,
         prepare_write: afs_linux_prepare_write,
 };