[OpenAFS-devel] [PATCH 1/2] linux < 2.4 cleanup

Andres Salomon dilinger@athenacr.com
Fri, 06 May 2005 18:05:51 -0400


--=-3iy1XaceQw0ormXBUayM
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

These two patches kill the various #ifdefs that check for kernels older
than 2.4.  I think it's a safe assumption to make that anyone compiling
openafs for linux at this point will not be doing so on anything older
than 2.4, and it removes a lot of cruft.  Since I'm not 100% where
userspace ends and the kernel code begins in the code, I left the
userspace stuff alone (for the most part).

This patch drops the relevant LINUX_VERSION_CODE checks.

If these two patches are accepted, I'll follow up w/ a few more patches
to:
a) convert to using gcc-style architecture identifiers for linux (ie
__ia64__ instead of AFS_IA64_LINUX20_ENV)
b) use KERNEL_VERSION() to check for 2.6 kernels, instead of
AFS_LINUX26_ENV.
c) try to get the param* stuff for linux pared down to something more
generic; let the precompiler sort it out, instead of having a perl
script (as suggested by Derrik) do it.


--=-3iy1XaceQw0ormXBUayM
Content-Disposition: attachment; filename=patch.kernel_version_cleanup
Content-Type: text/x-patch; name=patch.kernel_version_cleanup; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -urN openafs--mainline--0/src/afs/LINUX/osi_misc.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_misc.c
--- openafs--mainline--0/src/afs/LINUX/osi_misc.c	2005-04-27 23:11:51.000000000 -0400
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_misc.c	2005-05-06 11:53:17.716748701 -0400
@@ -343,13 +343,7 @@
 #else
 	    if (ip->i_nrpages) {
 #endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 		truncate_inode_pages(&ip->i_data, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-		truncate_inode_pages(ip, 0);
-#else
-		invalidate_inode_pages(ip);
-#endif
 #if defined(AFS_LINUX24_ENV)
 		if (ip->i_data.nrpages) {
 #else
diff -urN openafs--mainline--0/src/afs/LINUX/osi_module.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_module.c
--- openafs--mainline--0/src/afs/LINUX/osi_module.c	2005-04-24 19:53:44.000000000 -0400
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_module.c	2005-05-06 12:08:16.706258133 -0400
@@ -29,10 +29,8 @@
 
 #include <linux/proc_fs.h>
 #include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #include <linux/init.h>
 #include <linux/sched.h>
-#endif
 
 extern struct file_system_type afs_fs_type;
 
@@ -282,13 +280,8 @@
 }
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 int __init
 afs_init(void)
-#else
-int
-init_module(void)
-#endif
 {
     int e;
     RWLOCK_INIT(&afs_xosi, "afs_xosi");
@@ -319,13 +312,8 @@
     return 0;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 void __exit
 afs_cleanup(void)
-#else
-void
-cleanup_module(void)
-#endif
 {
     osi_sysctl_clean();
     osi_syscall_clean();
@@ -340,11 +328,8 @@
     return;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 module_init(afs_init);
 module_exit(afs_cleanup);
-#endif
-
 
 #if !defined(AFS_LINUX24_ENV)
 static long
@@ -356,26 +341,19 @@
     struct task_struct *p, *q;
 
     /* search backward thru the circular list */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     read_lock(&tasklist_lock);
-#endif
-    /* search backward thru the circular list */
 #ifdef DEFINED_PREV_TASK
     for (q = current; p = q; q = prev_task(p)) {
 #else
     for (p = current; p; p = p->prev_task) {
 #endif
 	if (p->pid == 1) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	    read_unlock(&tasklist_lock);
-#endif
 	    return p->addr_limit.seg;
 	}
     }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     read_unlock(&tasklist_lock);
-#endif
     return 0;
 #endif
 }
diff -urN openafs--mainline--0/src/afs/LINUX/osi_syscall.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_syscall.c
--- openafs--mainline--0/src/afs/LINUX/osi_syscall.c	2005-04-03 15:32:39.000000000 -0400
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_syscall.c	2005-05-06 12:12:27.056280893 -0400
@@ -31,10 +31,8 @@
 
 #include <linux/proc_fs.h>
 #include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #include <linux/init.h>
 #include <linux/sched.h>
-#endif
 
 #ifndef NR_syscalls
 #define NR_syscalls 222
diff -urN openafs--mainline--0/src/afs/LINUX/osi_vfsops.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vfsops.c
--- openafs--mainline--0/src/afs/LINUX/osi_vfsops.c	2005-03-10 23:37:18.000000000 -0500
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vfsops.c	2005-05-06 12:13:05.279881992 -0400
@@ -264,17 +264,12 @@
  * pages to disk. So it needs an inode syncing function to update metadata when it
  * has synced some pages of a file to disk.
  */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #ifdef WRITE_INODE_NOT_VOID
 static int
 #else
 static void
 #endif
 afs_write_inode(struct inode *ip, int unused)
-#else
-static void
-afs_write_inode(struct inode *ip)
-#endif
 {
     list_del(&ip->i_list);
     /* and put it back on our dummy list. */
diff -urN openafs--mainline--0/src/afs/LINUX/osi_vm.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vm.c
--- openafs--mainline--0/src/afs/LINUX/osi_vm.c	2004-04-12 12:04:32.000000000 -0400
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vm.c	2005-05-06 12:13:31.435504616 -0400
@@ -51,13 +51,7 @@
     if (avc->opens != 0)
 	return EBUSY;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     truncate_inode_pages(&ip->i_data, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    truncate_inode_pages(ip, 0);
-#else
-    invalidate_inode_pages(ip);
-#endif
     return 0;
 }
 
@@ -124,17 +118,9 @@
 void
 osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     struct inode *ip = AFSTOI(avc);
 
     truncate_inode_pages(&ip->i_data, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = AFSTOI(avc);
-
-    truncate_inode_pages(ip, 0);
-#else
-    invalidate_inode_pages(AFSTOI(avc));
-#endif
 }
 
 /* Purge pages beyond end-of-file, when truncating a file.
@@ -146,15 +132,7 @@
 void
 osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     struct inode *ip = AFSTOI(avc);
 
     truncate_inode_pages(&ip->i_data, alen);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
-    struct inode *ip = AFSTOI(avc);
-
-    truncate_inode_pages(ip, alen);
-#else
-    invalidate_inode_pages(AFSTOI(avc));
-#endif
 }
diff -urN openafs--mainline--0/src/afs/LINUX/osi_vnodeops.c openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vnodeops.c
--- openafs--mainline--0/src/afs/LINUX/osi_vnodeops.c	2005-04-25 10:55:47.000000000 -0400
+++ openafs--kernel_version_cleanup--0/src/afs/LINUX/osi_vnodeops.c	2005-05-06 12:03:52.706619577 -0400
@@ -845,13 +845,12 @@
 #endif
 
 /* Validate a dentry. Return 1 if unchanged, 0 if VFS layer should re-evaluate.
- * In kernels 2.2.10 and above, we are passed an additional flags var which
- * may have either the LOOKUP_FOLLOW OR LOOKUP_DIRECTORY set in which case
+ * We are passed an additional flags var which may have either the
+ * LOOKUP_FOLLOW or LOOKUP_DIRECTORY set in which case
  * we are advised to follow the entry if it is a link or to make sure that 
  * it is a directory. But since the kernel itself checks these possibilities
  * later on, we shouldn't have to do it until later. Perhaps in the future..
  */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
 #ifdef DOP_REVALIDATE_TAKES_NAMEIDATA
 static int
 afs_linux_dentry_revalidate(struct dentry *dp, struct nameidata *nd)
@@ -859,10 +858,6 @@
 static int
 afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 #endif
-#else
-static int
-afs_linux_dentry_revalidate(struct dentry *dp)
-#endif
 {
     cred_t *credp = NULL;
     struct vrequest treq;
@@ -1036,7 +1031,6 @@
 }
 
 /* afs_linux_lookup */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
 #ifdef IOP_LOOKUP_TAKES_NAMEIDATA
 struct dentry *
 afs_linux_lookup(struct inode *dip, struct dentry *dp,
@@ -1045,10 +1039,6 @@
 struct dentry *
 afs_linux_lookup(struct inode *dip, struct dentry *dp)
 #endif
-#else
-int
-afs_linux_lookup(struct inode *dip, struct dentry *dp)
-#endif
 {
     int code = 0;
     cred_t *credp = crref();
@@ -1105,16 +1095,10 @@
     /* It's ok for the file to not be found. That's noted by the caller by
      * seeing that the dp->d_inode field is NULL.
      */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
     if (code == ENOENT)
 	return ERR_PTR(0);
     else
 	return ERR_PTR(-code);
-#else
-    if (code == ENOENT)
-	code = 0;
-    return -code;
-#endif
 }
 
 int
@@ -1434,13 +1418,8 @@
 {
     int code;
     cred_t *credp = crref();
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     char *address;
     afs_offs_t offset = pp->index << PAGE_CACHE_SHIFT;
-#else
-    ulong address = afs_linux_page_address(pp);
-    afs_offs_t offset = pageoff(pp);
-#endif
     uio_t tuio;
     struct iovec iovec;
     struct inode *ip = FILE_INODE(fp);
@@ -1448,14 +1427,8 @@
     struct vcache *avc = ITOAFS(ip);
 
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     address = kmap(pp);
     ClearPageError(pp);
-#else
-    atomic_add(1, &pp->count);
-    set_bit(PG_locked, &pp->flags);	/* other bits? See mm.h */
-    clear_bit(PG_error, &pp->flags);
-#endif
 
     setup_uio(&tuio, &iovec, (char *)address, offset, PAGESIZE, UIO_READ,
 	      AFS_UIOSYS);
@@ -1477,22 +1450,12 @@
 	if (tuio.uio_resid)	/* zero remainder of page */
 	    memset((void *)(address + (PAGESIZE - tuio.uio_resid)), 0,
 		   tuio.uio_resid);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 	flush_dcache_page(pp);
 	SetPageUptodate(pp);
-#else
-	set_bit(PG_uptodate, &pp->flags);
-#endif
     }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     kunmap(pp);
     UnlockPage(pp);
-#else
-    clear_bit(PG_locked, &pp->flags);
-    wake_up(&pp->wait);
-    free_page(address);
-#endif
 
     if (!code && AFS_CHUNKOFFSET(offset) == 0) {
 	struct dcache *tdc;

--=-3iy1XaceQw0ormXBUayM--