From b860b359d584aa1cf84653d771a347ac3b951bfe Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Sun, 5 Nov 2000 20:13:38 +0000 Subject: [PATCH] initial-linux24-support-20001105 preliminary linux 2.4 kernel support ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== missed file --- src/README | 2 +- src/afs/LINUX/osi_alloc.c | 8 + src/afs/LINUX/osi_cred.c | 4 + src/afs/LINUX/osi_file.c | 36 ++++ src/afs/LINUX/osi_misc.c | 47 +++++- src/afs/LINUX/osi_module.c | 8 + src/afs/LINUX/osi_sleep.c | 8 + src/afs/LINUX/osi_vfs.h | 35 ++++ src/afs/LINUX/osi_vfsops.c | 55 +++++- src/afs/LINUX/osi_vnodeops.c | 325 ++++++++++++++++++++++++++++++++---- src/afs/Makefile | 2 +- src/afs/afs_vcache.c | 28 +++- src/comerr/Makefile | 2 +- src/config/Makefile.i386_linux24 | 46 +++++ src/config/Makefile.ppc_linux24 | 46 +++++ src/config/afs_sysnames.h | 7 + src/config/param.i386_linux24_usr.h | 54 ++++++ src/config/param.ppc_linux24.h | 63 +++++++ src/config/param.ppc_linux24_usr.h | 54 ++++++ src/des/andrew-conf.h | 4 + src/libafs/MakefileProto.LINUX | 11 ++ src/lwp/Makefile | 2 +- src/lwp/process.c | 4 + src/rx/LINUX/rx_kmutex.h | 26 ++- src/rx/LINUX/rx_knet.c | 7 + src/rx/Makefile | 2 +- src/venus/kdump.c | 5 + 27 files changed, 850 insertions(+), 41 deletions(-) create mode 100644 src/config/Makefile.i386_linux24 create mode 100644 src/config/Makefile.ppc_linux24 create mode 100644 src/config/param.i386_linux24_usr.h create mode 100644 src/config/param.ppc_linux24.h create mode 100644 src/config/param.ppc_linux24_usr.h diff --git a/src/README b/src/README index dfe3a0c..e86306c 100644 --- a/src/README +++ b/src/README @@ -77,7 +77,7 @@ B Building 2. Begin building a. For Linux - % make SYS_NAME="i386_linux22" LINUX_VERSION="2.2.14" + % make SYS_NAME="i386_linux22" LINUX_VERS="2.2.14" b. For UNIX versions, specify the system name as given by the system type defined in step A1. diff --git a/src/afs/LINUX/osi_alloc.c b/src/afs/LINUX/osi_alloc.c index f88188e..ab0352d 100644 --- a/src/afs/LINUX/osi_alloc.c +++ b/src/afs/LINUX/osi_alloc.c @@ -45,10 +45,14 @@ unsigned int afs_linux_hash_verify_count = 0; /* used by hash_verify */ struct afs_lhash_stat afs_linux_lsb; /* hash table statistics */ unsigned int afs_linux_hash_bucket_dist[MAX_BUCKET_LEN]; /* bucket population distribution in our hash table */ +#if defined(AFS_LINUX24_ENV) +#include "../h/vmalloc.h" +#else /* externs : can we do this in a better way. Including vmalloc.h causes other * problems.*/ extern void vfree(void * addr); extern void *vmalloc(unsigned long size); +#endif /* Allocator support functions (static) */ @@ -249,7 +253,11 @@ static void get_hash_stats() /************** Linux memory allocator interface functions **********/ +#if defined(AFS_LINUX24_ENV) +DECLARE_MUTEX(afs_linux_alloc_sem); +#else struct semaphore afs_linux_alloc_sem = MUTEX; +#endif void *osi_linux_alloc(unsigned int asize) { diff --git a/src/afs/LINUX/osi_cred.c b/src/afs/LINUX/osi_cred.c index 32065f6..f452e03 100644 --- a/src/afs/LINUX/osi_cred.c +++ b/src/afs/LINUX/osi_cred.c @@ -27,7 +27,11 @@ int ncreds_inuse = 0; * Also assuming a fast path through both down and up if no waiters. Otherwise, * test if no creds in pool before grabbing lock in crfree(). */ +#if defined(AFS_LINUX24_ENV) +static DECLARE_MUTEX(linux_cred_pool_lock); +#else static struct semaphore linux_cred_pool_lock = MUTEX; +#endif #define CRED_LOCK() down(&linux_cred_pool_lock) #define CRED_UNLOCK() up(&linux_cred_pool_lock) diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 25cb2db..0a04ef8 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -11,6 +11,7 @@ #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ #include "../afs/afs_stats.h" /* afs statistics */ +#include "../h/smp_lock.h" int afs_osicred_initialized=0; @@ -54,7 +55,11 @@ void *osi_UFSOpen(ainode) FILE_INODE(filp) = tip; tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ filp->f_flags = O_RDWR; +#if defined(AFS_LINUX24_ENV) + filp->f_op = fops_get(tip->i_fop); +#else filp->f_op = tip->i_op->default_file_ops; +#endif if (filp->f_op && filp->f_op->open) code = filp->f_op->open(tip, filp); if (code) @@ -99,6 +104,31 @@ osi_UFSClose(afile) return 0; } +int osi_notify_change(struct dentry * dentry, struct iattr * attr) +{ + struct inode *inode = dentry->d_inode; + int error; + time_t now = CURRENT_TIME; + unsigned int ia_valid = attr->ia_valid; + + attr->ia_ctime = now; + if (!(ia_valid & ATTR_ATIME_SET)) + attr->ia_atime = now; + if (!(ia_valid & ATTR_MTIME_SET)) + attr->ia_mtime = now; + + lock_kernel(); + if (inode && inode->i_op && inode->i_op->setattr) + error = inode->i_op->setattr(dentry, attr); + else { + error = inode_change_ok(inode, attr); + if (!error) + inode_setattr(inode, attr); + } + unlock_kernel(); + return error; +} + osi_UFSTruncate(afile, asize) register struct osi_file *afile; afs_int32 asize; { @@ -118,6 +148,11 @@ osi_UFSTruncate(afile, asize) MObtainWriteLock(&afs_xosi,321); AFS_GUNLOCK(); down(&inode->i_sem); +#if defined(AFS_LINUX24_ENV) + newattrs.ia_size = asize; + newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; + code = osi_notify_change(&afile->dentry, &newattrs); +#else inode->i_size = newattrs.ia_size = asize; newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; if (inode->i_sb->s_op && inode->i_sb->s_op->notify_change) { @@ -128,6 +163,7 @@ osi_UFSTruncate(afile, asize) if (inode->i_op && inode->i_op->truncate) inode->i_op->truncate(inode); } +#endif code = -code; up(&inode->i_sem); AFS_GLOCK(); diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 0194d4d..edda974 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -22,17 +22,40 @@ char *crash_addr = 0; /* Induce an oops by writing here. */ int osi_lookupname(char *aname, uio_seg_t seg, int followlink, vnode_t **dirvpp, struct dentry **dpp) { +#if defined(AFS_LINUX24_ENV) + struct nameidata nd; +#else struct dentry *dp = NULL; +#endif int code; code = ENOENT; +#if defined(AFS_LINUX24_ENV) + if (seg == AFS_UIOUSER) { + code = followlink ? + user_path_walk(aname, &nd) : user_path_walk_link(aname, &nd); + } + else { + if (path_init(aname, followlink ? LOOKUP_FOLLOW : 0, &nd)) + code = path_walk(aname, &nd); + } + + if (!code) { + if (nd.dentry->d_inode) { + *dpp = nd.dentry; + code = 0; + } + else + path_release(&nd); + } +#else if (seg == AFS_UIOUSER) { dp = followlink ? namei(aname) : lnamei(aname); } else { dp = lookup_dentry(aname, NULL, followlink ? 1 : 0); } - + if (dp && !IS_ERR(dp)) { if (dp->d_inode) { *dpp = dp; @@ -41,6 +64,7 @@ int osi_lookupname(char *aname, uio_seg_t seg, int followlink, else dput(dp); } +#endif return code; } @@ -262,9 +286,17 @@ void osi_linux_free_inode_pages(void) for (i=0; ihnext) { ip = (struct inode*)tvc; +#if defined(AFS_LINUX24_ENV) + if (ip->i_data.nrpages) { +#else if (ip->i_nrpages) { +#endif invalidate_inode_pages(ip); +#if defined(AFS_LINUX24_ENV) + if (ip->i_data.nrpages) { +#else if (ip->i_nrpages) { +#endif printf("Failed to invalidate all pages on inode 0x%x\n", ip); } @@ -283,13 +315,26 @@ void osi_iput(struct inode *ip) extern struct vfs *afs_globalVFS; +#if defined(AFS_LINUX24_ENV) + if (atomic_read(&ip->i_count) == 0 || atomic_read(&ip->i_count) & 0xffff0000) { +#else if (ip->i_count == 0 || ip->i_count & 0xffff0000) { +#endif osi_Panic("IPUT Bad refCount %d on inode 0x%x\n", +#if defined(AFS_LINUX24_ENV) + atomic_read(&ip->i_count), ip); +#else ip->i_count, ip); +#endif } if (afs_globalVFS && afs_globalVFS == ip->i_sb ) { +#if defined(AFS_LINUX24_ENV) + atomic_dec(&ip->i_count); + if (!atomic_read(&ip->i_count)) +#else ip->i_count --; if (!ip->i_count) +#endif afs_delete_inode(ip); } else { diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 79ca811..5d29b43 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -31,7 +31,11 @@ extern struct file_system_type afs_file_system; static long get_page_offset(void); +#if defined(AFS_LINUX24_ENV) +DECLARE_MUTEX(afs_global_lock); +#else struct semaphore afs_global_lock = MUTEX; +#endif int afs_global_owner = 0; unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */ @@ -96,6 +100,9 @@ void cleanup_module(void) static long get_page_offset(void) { +#if defined(AFS_PPC_LINUX22_ENV) + return PAGE_OFFSET; +#else struct task_struct *p; /* search backward thru the circular list */ @@ -104,4 +111,5 @@ static long get_page_offset(void) return p->addr_limit.seg; return 0; +#endif } diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c index 82451ab..f1b75d8 100644 --- a/src/afs/LINUX/osi_sleep.c +++ b/src/afs/LINUX/osi_sleep.c @@ -124,7 +124,11 @@ typedef struct afs_event { int seq; /* Sequence number: this is incremented by wakeup calls; wait will not return until it changes */ +#if defined(AFS_LINUX24_ENV) + wait_queue_head_t cond; +#else struct wait_queue *cond; +#endif } afs_event_t; #define HASHSIZE 128 @@ -156,7 +160,11 @@ static afs_event_t *afs_getevent(char *event) afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; +#if defined(AFS_LINUX24_ENV) + init_waitqueue_head(&newp->cond); +#else init_waitqueue(&newp->cond); +#endif newp->seq = 0; } newp->event = event; diff --git a/src/afs/LINUX/osi_vfs.h b/src/afs/LINUX/osi_vfs.h index 747846b..74f7515 100644 --- a/src/afs/LINUX/osi_vfs.h +++ b/src/afs/LINUX/osi_vfs.h @@ -34,31 +34,63 @@ typedef struct vnode { uid_t i_uid; gid_t i_gid; kdev_t i_rdev; +#if defined(AFS_LINUX24_ENV) + loff_t i_size; +#else off_t i_size; +#endif time_t i_atime; time_t i_mtime; time_t i_ctime; unsigned long i_blksize; unsigned long i_blocks; unsigned long i_version; +#if !defined(AFS_LINUX24_ENV) unsigned long i_nrpages; +#endif struct semaphore i_sem; +#if defined(AFS_LINUX24_ENV) + struct semaphore i_zombie; +#else struct semaphore i_atomic_write; +#endif struct inode_operations *i_op; +#if defined(AFS_LINUX24_ENV) + struct file_operations *i_fop; +#endif struct super_block *i_sb; +#if defined(AFS_LINUX24_ENV) + wait_queue_head_t i_wait; +#else struct wait_queue *i_wait; +#endif struct file_lock *i_flock; +#if defined(AFS_LINUX24_ENV) + struct address_space *i_mapping; + struct address_space i_data; +#else struct vm_area_struct *i_mmap; struct page *i_pages; +#endif struct dquot *i_dquot[MAXQUOTAS]; +#if defined(AFS_LINUX24_ENV) + struct pipe_inode_info *i_pipe; + struct block_device *i_bdev; +#endif unsigned long i_state; unsigned int i_flags; +#if !defined(AFS_LINUX24_ENV) unsigned char i_pipe; +#endif unsigned char i_sock; +#if defined(AFS_LINUX24_ENV) + atomic_t i_writecount; +#else int i_writecount; +#endif unsigned int i_attr_flags; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10) __u32 i_generation; @@ -93,6 +125,9 @@ typedef struct vnode { #define i_number i_ino #define v_count i_count #define v_op i_op +#if defined(AFS_LINUX24_ENV) +#define v_fop i_fop +#endif #define v_type i_mode #define v_vfsp i_sb #define vfs_vnodecovered s_covered diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index c04a20e..3e9faa1 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -17,6 +17,9 @@ #include "../afs/afsincludes.h" #include "../afs/afs_stats.h" #include "../h/locks.h" +#if defined(AFS_LINUX24_ENV) +#include "../h/smp_lock.h" +#endif #define __NO_VERSION__ /* don't define kernel_verion in module.h */ #include @@ -47,6 +50,9 @@ void put_inode_on_dummy_list(struct inode *ip); * 2) Mount call comes to us via do_mount -> read_super -> afs_read_super. * We are expected to setup the super_block. See afs_read_super. */ +#if defined(AFS_LINUX24_ENV) +DECLARE_FSTYPE(afs_file_system, "afs", afs_read_super, 0); +#else struct file_system_type afs_file_system = { "afs", /* name - used by mount operation. */ 0, /* requires_dev - no for network filesystems. mount() will @@ -54,6 +60,7 @@ struct file_system_type afs_file_system = { afs_read_super, /* wrapper to afs_mount */ NULL /* pointer to next file_system_type once registered. */ }; +#endif /* afs_read_super * read the "super block" for AFS - roughly eguivalent to struct vfs. @@ -72,7 +79,9 @@ struct super_block *afs_read_super(struct super_block *sb, void *data, afs_was_mounted = 1; /* Set basics of super_block */ +#if !defined(AFS_LINUX24_ENV) lock_super(sb); +#endif MOD_INC_USE_COUNT; afs_globalVFS = sb; @@ -84,7 +93,9 @@ struct super_block *afs_read_super(struct super_block *sb, void *data, if (code) MOD_DEC_USE_COUNT; +#if !defined(AFS_LINUX24_ENV) unlock_super(sb); +#endif AFS_GUNLOCK(); return code ? NULL : sb; @@ -110,13 +121,23 @@ static int afs_root(struct super_block *afsp) (struct vcache*)0, WRITE_LOCK); if (tvp) { extern struct inode_operations afs_dir_iops; +#if defined(AFS_LINUX24_ENV) + extern struct file_operations afs_dir_fops; +#endif /* "/afs" is a directory, reset inode ops accordingly. */ tvp->v.v_op = &afs_dir_iops; +#if defined(AFS_LINUX24_ENV) + tvp->v.v_fop = &afs_dir_fops; +#endif /* setup super_block and mount point inode. */ afs_globalVp = tvp; +#if defined(AFS_LINUX24_ENV) + afsp->s_root = d_alloc_root((struct inode*)tvp); +#else afsp->s_root = d_alloc_root((struct inode*)tvp, NULL); +#endif afsp->s_root->d_op = &afs_dentry_operations; } else code = ENOENT; @@ -212,15 +233,27 @@ void afs_delete_inode(struct inode *ip) struct vcache *vc = (struct vcache*)ip; AFS_GLOCK(); +#if defined(AFS_LINUX24_ENV) + lock_kernel(); + if (atomic_read(&ip->i_count) > 1) +#else if (ip->i_count > 1) +#endif printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip); ObtainWriteLock(&vc->lock, 504); afs_InactiveVCache(vc, credp); +#if defined(AFS_LINUX24_ENV) + atomic_set(&ip->i_count, 0); +#else ip->i_count = 0; +#endif ip->i_nlink = 0; /* iput checks this after calling this routine. */ ReleaseWriteLock(&vc->lock); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); } @@ -273,16 +306,22 @@ int afs_remount_fs(struct super_block *sbp, int *, char *) * statp is in user space, so we need to cobble together a statfs, then * copy it. */ +#if defined(AFS_LINUX24_ENV) +int afs_statfs(struct super_block *sbp, struct statfs *statp) +#else int afs_statfs(struct super_block *sbp, struct statfs *statp, int size) +#endif { struct statfs stat; AFS_STATCNT(afs_statfs); +#if !defined(AFS_LINUX24_ENV) if (size < sizeof(struct statfs)) return; memset(&stat, 0, size); +#endif stat.f_type = 0; /* Can we get a real type sometime? */ stat.f_bsize = sbp->s_blocksize; stat.f_blocks = stat.f_bfree = stat.f_bavail = stat.f_files = @@ -290,12 +329,25 @@ int afs_statfs(struct super_block *sbp, struct statfs *statp, int size) stat.f_fsid.val[0] = AFS_VFSMAGIC; stat.f_fsid.val[1] = AFS_VFSFSID; stat.f_namelen = 256; - + +#if defined(AFS_LINUX24_ENV) + *statp = stat; +#else memcpy_tofs(statp, &stat, size); +#endif return 0; } +#if defined(AFS_LINUX24_ENV) +struct super_operations afs_sops = { + read_inode: afs_read_inode, + write_inode: afs_write_inode, + delete_inode: afs_delete_inode, + put_super: afs_put_super, + statfs: afs_statfs, +}; +#else struct super_operations afs_sops = { afs_read_inode, afs_write_inode, /* afs_write_inode - see doc above. */ @@ -309,6 +361,7 @@ struct super_operations afs_sops = { NULL, /* afs_clear_inode */ NULL, /* afs_umount_begin */ }; +#endif /************** Support routines ************************/ diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index de2c51f..1c45181 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -26,10 +26,18 @@ #include "../afs/afs_stats.h" #include "../h/mm.h" #include "../h/pagemap.h" +#if defined(AFS_LINUX24_ENV) +#include "../h/smp_lock.h" +#endif extern struct vcache *afs_globalVp; extern struct dentry_operations *afs_dops; +#if defined(AFS_LINUX24_ENV) +extern struct inode_operations afs_file_iops; +extern struct address_space_operations afs_file_aops; +struct address_space_operations afs_symlink_aops; +#endif extern struct inode_operations afs_dir_iops; extern struct inode_operations afs_symlink_iops; @@ -215,7 +223,8 @@ tagain: len = strlen(de->name); /* filldir returns -EINVAL when the buffer is full. */ - code = (*filldir)(dirbuf, de->name, len, offset, ino); + /* code = (*filldir)(dirbuf, de->name, len, offset, ino); */ + code = (*filldir)(dirbuf, de->name, len, offset, ino, DT_DIR); DRelease(de, 0); if (code) break; @@ -301,10 +310,16 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) int code; AFS_GLOCK(); +#if defined(AFS_LINUX24_ENV) + afs_Trace3(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp, + ICL_TYPE_POINTER, vmap->vm_start, + ICL_TYPE_INT32, vmap->vm_end - vmap->vm_start); +#else afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32, vmap->vm_end - vmap->vm_start, ICL_TYPE_INT32, vmap->vm_offset); +#endif /* get a validated vcache entry */ code = afs_InitReq(&treq, credp); @@ -322,36 +337,38 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) AFS_GLOCK(); } - ObtainWriteLock(&vcp->lock,531); - /* Set out vma ops so we catch the close. The following test should be - * the same as used in generic_file_mmap. - */ - if ((vmap->vm_flags & VM_SHARED) && (vmap->vm_flags & VM_MAYWRITE)) { - if (!afs_shared_mmap_ops_inited) { - afs_shared_mmap_ops_inited = 1; - afs_shared_mmap_ops = *vmap->vm_ops; - afs_shared_mmap_ops.close = afs_linux_vma_close; + if (code == 0) { + ObtainWriteLock(&vcp->lock,531); + /* Set out vma ops so we catch the close. The following test should be + * the same as used in generic_file_mmap. + */ + if ((vmap->vm_flags & VM_SHARED) && (vmap->vm_flags & VM_MAYWRITE)) { + if (!afs_shared_mmap_ops_inited) { + afs_shared_mmap_ops_inited = 1; + afs_shared_mmap_ops = *vmap->vm_ops; + afs_shared_mmap_ops.close = afs_linux_vma_close; + } + vmap->vm_ops = &afs_shared_mmap_ops; } - vmap->vm_ops = &afs_shared_mmap_ops; - } - else { - if (!afs_private_mmap_ops_inited) { - afs_private_mmap_ops_inited = 1; - afs_private_mmap_ops = *vmap->vm_ops; - afs_private_mmap_ops.close = afs_linux_vma_close; + else { + if (!afs_private_mmap_ops_inited) { + afs_private_mmap_ops_inited = 1; + afs_private_mmap_ops = *vmap->vm_ops; + afs_private_mmap_ops.close = afs_linux_vma_close; + } + vmap->vm_ops = &afs_private_mmap_ops; } - vmap->vm_ops = &afs_private_mmap_ops; - } - /* Add an open reference on the first mapping. */ - if (vcp->mapcnt == 0) { - vcp->execsOrWriters++; - vcp->opens++; - vcp->states |= CMAPPED; + /* Add an open reference on the first mapping. */ + if (vcp->mapcnt == 0) { + vcp->execsOrWriters++; + vcp->opens++; + vcp->states |= CMAPPED; + } + ReleaseWriteLock(&vcp->lock); + vcp->mapcnt++; } - ReleaseWriteLock(&vcp->lock); - vcp->mapcnt++; AFS_GUNLOCK(); crfree(credp); @@ -364,7 +381,13 @@ int afs_linux_open(struct inode *ip, struct file *fp) cred_t *credp = crref(); AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif code = afs_open((struct vcache**)&ip, fp->f_flags, credp); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); @@ -385,26 +408,42 @@ static int afs_linux_release(struct inode *ip, struct file *fp) struct vcache *vcp = (struct vcache*)ip; AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif if (vcp->flushcnt) { vcp->flushcnt--; /* protected by AFS global lock. */ } else { code = afs_close(vcp, fp->f_flags, credp); } +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); return -code; } +#if defined(AFS_LINUX24_ENV) +static int afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync) +#else static int afs_linux_fsync(struct file *fp, struct dentry *dp) +#endif { int code; struct inode *ip = FILE_INODE(fp); cred_t *credp = crref(); AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif code = afs_fsync((struct vcache*)ip, credp); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); return -code; @@ -464,7 +503,11 @@ int afs_linux_flush(struct file *fp) cred_t *credp; /* Only do this on the last close of the file pointer. */ +#if defined(AFS_LINUX24_ENV) + if (atomic_read(&fp->f_count) > 1) +#else if (fp->f_count > 1) +#endif return 0; credp = crref(); @@ -486,6 +529,15 @@ int afs_linux_dir_read(struct file *fp, char *buf, size_t count, loff_t *ppos) +#if defined(AFS_LINUX24_ENV) +struct file_operations afs_dir_fops = { + read: generic_read_dir, + readdir: afs_linux_readdir, + ioctl: afs_xioctl, + open: afs_linux_open, + release: afs_linux_release, +}; +#else struct file_operations afs_dir_fops = { NULL, /* afs_linux_lseek */ afs_linux_dir_read, @@ -503,7 +555,21 @@ struct file_operations afs_dir_fops = { NULL, /* afs_linux_file_revalidate */ afs_linux_lock, }; +#endif +#if defined(AFS_LINUX24_ENV) +struct file_operations afs_file_fops = { + read: afs_linux_read, + write: afs_linux_write, + ioctl: afs_xioctl, + mmap: afs_linux_mmap, + open: afs_linux_open, + flush: afs_linux_flush, + release: afs_linux_release, + fsync: afs_linux_fsync, + lock: afs_linux_lock, +}; +#else struct file_operations afs_file_fops = { NULL, /* afs_linux_lseek */ afs_linux_read, @@ -521,6 +587,7 @@ struct file_operations afs_file_fops = { NULL, /* afs_linux_file_revalidate */ afs_linux_lock, }; +#endif /********************************************************************** @@ -538,9 +605,15 @@ static int afs_linux_revalidate(struct dentry *dp) struct vcache *vcp = (struct vcache*)dp->d_inode; AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif /* If it's a negative dentry, then there's nothing to do. */ if (!vcp) { +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); return 0; } @@ -550,6 +623,9 @@ static int afs_linux_revalidate(struct dentry *dp) if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */ check_bad_parent(dp); /* check and correct mvid */ vcache2inode(vcp); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); return 0; } @@ -559,6 +635,9 @@ static int afs_linux_revalidate(struct dentry *dp) if (!code) code = afs_VerifyVCache(vcp, &treq); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); @@ -584,9 +663,15 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) struct vcache *vcp = (struct vcache*)dp->d_inode; AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif /* If it's a negative dentry, then there's nothing to do. */ if (!vcp) { +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); return 0; } @@ -596,6 +681,9 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */ check_bad_parent(dp); /* check and correct mvid */ vcache2inode(vcp); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); return 0; } @@ -605,6 +693,9 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) if (!code) code = afs_VerifyVCache(vcp, &treq); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); @@ -614,16 +705,36 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) /* afs_dentry_iput */ static void afs_dentry_iput(struct dentry *dp, struct inode *ip) { +#if defined(AFS_LINUX24_ENV) + if (atomic_read(&ip->i_count) == 0 || atomic_read(&ip->i_count) & 0xffff0000) { +#else if (ip->i_count == 0 || ip->i_count & 0xffff0000) { +#endif osi_Panic("Bad refCount %d on inode 0x%x\n", +#if defined(AFS_LINUX24_ENV) + atomic_read(&ip->i_count), ip); +#else ip->i_count, ip); +#endif } +#if defined(AFS_LINUX24_ENV) + atomic_dec(&ip->i_count); + if (!atomic_read(&ip->i_count)) { +#else ip->i_count --; if (!ip->i_count) { +#endif afs_delete_inode(ip); } } +#if defined(AFS_LINUX24_ENV) +struct dentry_operations afs_dentry_operations = { + d_revalidate: afs_linux_dentry_revalidate, + d_iput: afs_dentry_iput, +}; +struct dentry_operations *afs_dops = &afs_dentry_operations; +#else struct dentry_operations afs_dentry_operations = { afs_linux_dentry_revalidate, /* d_validate(struct dentry *) */ NULL, /* d_hash */ @@ -633,6 +744,7 @@ struct dentry_operations afs_dentry_operations = { afs_dentry_iput /* d_iput(struct dentry *, struct inode *) */ }; struct dentry_operations *afs_dops = &afs_dentry_operations; +#endif /********************************************************************** * AFS Linux inode operations @@ -665,10 +777,26 @@ int afs_linux_create(struct inode *dip, struct dentry *dp, int mode) if (!code) { vattr2inode(ip, &vattr); /* Reset ops if symlink or directory. */ +#if defined(AFS_LINUX24_ENV) + if (S_ISREG(ip->i_mode)) { + ip->i_op = &afs_file_iops; + ip->i_fop = &afs_file_fops; + ip->i_data.a_ops = &afs_file_aops; + } else if (S_ISDIR(ip->i_mode)) { + ip->i_op = &afs_dir_iops; + ip->i_fop = &afs_dir_fops; + } else if (S_ISLNK(ip->i_mode)) { + ip->i_op = &afs_symlink_iops; + ip->i_data.a_ops = &afs_symlink_aops; + ip->i_mapping = &ip->i_data; + } else + printk("afs_linux_create: FIXME\n"); +#else if (S_ISDIR(ip->i_mode)) ip->i_op = &afs_dir_iops; else if (S_ISLNK(ip->i_mode)) ip->i_op = &afs_symlink_iops; +#endif dp->d_op = afs_dops; d_instantiate(dp, ip); @@ -696,10 +824,26 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp) if (vcp) { struct inode *ip = (struct inode*)vcp; /* Reset ops if symlink or directory. */ +#if defined(AFS_LINUX24_ENV) + if (S_ISREG(ip->i_mode)) { + ip->i_op = &afs_file_iops; + ip->i_fop = &afs_file_fops; + ip->i_data.a_ops = &afs_file_aops; + } else if (S_ISDIR(ip->i_mode)) { + ip->i_op = &afs_dir_iops; + ip->i_fop = &afs_dir_fops; + } else if (S_ISLNK(ip->i_mode)) { + ip->i_op = &afs_symlink_iops; + ip->i_data.a_ops = &afs_symlink_aops; + ip->i_mapping = &ip->i_data; + } else + printk("afs_linux_lookup: FIXME\n"); +#else if (S_ISDIR(ip->i_mode)) ip->i_op = &afs_dir_iops; else if (S_ISLNK(ip->i_mode)) ip->i_op = &afs_symlink_iops; +#endif } dp->d_op = afs_dops; d_add(dp, (struct inode*)vcp); @@ -753,7 +897,11 @@ int afs_linux_unlink(struct inode *dip, struct dentry *dp) if (!list_empty(&dp->d_hash)) { d_drop(dp); /* Install a definite non-existence if we're the only user. */ +#if defined(AFS_LINUX24_ENV) + if (atomic_read(&dp->d_count) == 1) +#else if (dp->d_count == 1) +#endif putback = 1; } @@ -807,6 +955,9 @@ int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) if (tvcp) { tvcp->v.v_op = &afs_dir_iops; +#if defined(AFS_LINUX24_ENV) + tvcp->v.v_fop = &afs_dir_fops; +#endif dp->d_op = afs_dops; d_instantiate(dp, (struct inode*)tvcp); } @@ -897,6 +1048,7 @@ static int afs_linux_ireadlink(struct inode *ip, char *target, int maxlen, return -code; } +#if !defined(AFS_LINUX24_ENV) /* afs_linux_readlink * Fill target (which is in user space) with contents of symlink. */ @@ -921,8 +1073,6 @@ struct dentry * afs_linux_follow_link(struct dentry *dp, { int code = 0; char *name; - struct dentry *res; - AFS_GLOCK(); name = osi_Alloc(PATH_MAX+1); @@ -973,9 +1123,20 @@ int afs_linux_readpage(struct file *fp, struct page *pp) set_bit(PG_locked, &pp->flags); /* other bits? See mm.h */ clear_bit(PG_error, &pp->flags); +#if defined(AFS_LINUX24_ENV) + setup_uio(&tuio, &iovec, (char*)address, pp->index << PAGE_CACHE_SHIFT, + PAGESIZE, UIO_READ, AFS_UIOSYS); +#else setup_uio(&tuio, &iovec, (char*)address, pp->offset, PAGESIZE, UIO_READ, AFS_UIOSYS); +#endif +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif code = afs_rdwr((struct vcache*)ip, &tuio, UIO_READ, 0, credp); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif if (!code) { if (tuio.uio_resid) /* zero remainder of page */ @@ -999,7 +1160,7 @@ int afs_linux_readpage(struct file *fp, struct page *pp) } #ifdef NOTUSED -/* afs_linux_writepage - is this used anywhere? */ +/* afs_linux_writepage - is this used anywhere? swap files via nfs? */ int afs_linux_writepage(struct inode *ip, struct page *) { return -EINVAL }; /* afs_linux_bmap - supports generic_readpage, but we roll our own. */ @@ -1060,12 +1221,21 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, credp = crref(); AFS_GLOCK(); +#ifdef AFS_LINUX24_ENV + lock_kernel(); +#endif afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, atomic_read(&pp->count), ICL_TYPE_INT32, 99999); +#if defined(AFS_LINUX24_ENV) + setup_uio(&tuio, &iovec, page_addr + offset, + (pp->index << PAGE_CACHE_SHIFT) + offset, count, + UIO_WRITE, AFS_UIOSYS); +#else setup_uio(&tuio, &iovec, page_addr + offset, pp->offset + offset, count, UIO_WRITE, AFS_UIOSYS); +#endif code = afs_write(vcp, &tuio, fp->f_flags, credp, 0); @@ -1077,6 +1247,9 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, ICL_TYPE_INT32, atomic_read(&pp->count), ICL_TYPE_INT32, code); +#ifdef AFS_LINUX24_ENV + unlock_kernel(); +#endif AFS_GUNLOCK(); crfree(credp); @@ -1084,8 +1257,42 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, return code; } +#if defined(AFS_LINUX24_ENV) +static int afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) +{ + long status; + loff_t pos = ((loff_t)page->index<mapping->host; + char *p = (char *)kmap(page); + int code; + + AFS_GLOCK(); + lock_kernel(); + code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS); + unlock_kernel(); + AFS_GUNLOCK(); + + if (code<0) + goto fail; + p[code] = '\0'; /* null terminate? */ + SetPageUptodate(page); + kunmap(page); + UnlockPage(page); + return 0; + +fail: + SetPageError(page); + kunmap(page); + UnlockPage(page); + return code; +} + +struct address_space_operations afs_symlink_aops = { + readpage: afs_symlink_filler +}; + +struct inode_operations afs_symlink_iops = { + readlink: page_readlink, + follow_link: page_follow_link, + setattr: afs_notify_change, +}; +#else struct inode_operations afs_symlink_iops = { NULL, /* file operations */ NULL, /* create */ @@ -1162,3 +1424,4 @@ struct inode_operations afs_symlink_iops = { NULL, /* updatepage */ afs_linux_revalidate, /* tho the code appears to indicate not used? */ }; +#endif diff --git a/src/afs/Makefile b/src/afs/Makefile index aa9f848..a73f40f 100644 --- a/src/afs/Makefile +++ b/src/afs/Makefile @@ -32,7 +32,7 @@ kinstall: AFS_component_version_number.c case ${SYS_NAME} in \ sgi_* ) \ gencat -m afszcm.cat afs_trace.msf ;; \ - i386_linux* ) \ + *_linux* ) \ gencat --new afszcm.cat afs_trace.msf ;; \ * ) \ gencat afszcm.cat afs_trace.msf ;; \ diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index aa24daf..385374c 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -585,22 +585,37 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp, struct list_head *cur; struct list_head *head = &ip->i_dentry; int all = 1; - retry: + restart: +#if defined(AFS_LINUX24_ENV) + spin_lock(&dcache_lock); +#endif cur = head; while ((cur = cur->next) != head) { struct dentry *dentry = list_entry(cur, struct dentry, d_alias); +#if defined(AFS_LINUX24_ENV) + if (!atomic_read(&dentry->d_count)) { +#else if (!dentry->d_count) { +#endif AFS_GUNLOCK(); +#if defined(AFS_LINUX24_ENV) + dget_locked(dentry); + spin_unlock(&dcache_lock); +#else dget(dentry); +#endif d_drop(dentry); dput(dentry); AFS_GLOCK(); - goto retry; + goto restart; } else { all = 0; } } +#if defined(AFS_LINUX24_ENV) + spin_unlock(&dcache_lock); +#endif if (all) vn --; } } @@ -904,8 +919,17 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp, { struct inode *ip = (struct inode*)tvc; sema_init(&ip->i_sem, 1); +#if defined(AFS_LINUX24_ENV) + sema_init(&ip->i_zombie, 1); + init_waitqueue_head(&ip->i_wait); + spin_lock_init(&ip->i_data.i_shared_lock); + INIT_LIST_HEAD(&ip->i_data.pages); + ip->i_data.host = (void*) ip; + ip->i_mapping = &ip->i_data; +#else sema_init(&ip->i_atomic_write, 1); init_waitqueue(&ip->i_wait); +#endif INIT_LIST_HEAD(&ip->i_hash); INIT_LIST_HEAD(&ip->i_dentry); if (afs_globalVFS) { diff --git a/src/comerr/Makefile b/src/comerr/Makefile index df1d3e8..ff7839f 100644 --- a/src/comerr/Makefile +++ b/src/comerr/Makefile @@ -86,7 +86,7 @@ doc: com_err.dvi # compile_et: compile_et.o error_table.o case $(SYS_NAME) in \ - i386_linux* ) \ + *_linux* ) \ ${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o ${utilib};; \ * ) \ ${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o ${utilib} -ll;; \ diff --git a/src/config/Makefile.i386_linux24 b/src/config/Makefile.i386_linux24 new file mode 100644 index 0000000..f85a382 --- /dev/null +++ b/src/config/Makefile.i386_linux24 @@ -0,0 +1,46 @@ +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = LINUX + +# Base directory for linux kernel source. Actually a prefix which is complete +# when LINUX_VERS is appended to it. +LINUX_SRCDIR = /usr/src/linux- +# Default list of Linux kernels to build. Build will run only if all +# can be built. To build a different set, specify LINUX_VERS to make. +LINUX_VERS = 2.3.99-pre3 + +# +# compilation and link editor flags +DBG=-g +OPTMZ=-O2 +PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC +# Put -O2 here to _ensure_ all Makefiles pick it up. +XCFLAGS= -O2 +MT_CFLAGS=-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS} +XLDFLAGS= +SHARE_LDFLAGS = -shared -Xlinker -x +SHLIB_SUFFIX=so +SHLIB_CFLAGS= +# +# libraries +MTLIBS=-lpthread +TXLIBS= /usr/lib/libncurses.so +XLIBS= +# +# programs +AR=ar +AS=as +CP=cp +INSTALL=${SRCDIR}bin/install +LD=ld +MT_CC=cc +MV=mv +RANLIB=ranlib +RM=rm +WASHTOOL=${SRCDIR}bin/washtool +# +# Other OS specific requirements +# +YACC = bison -y +LEX = flex -l +# Used in des library. +CRYPT_OBJ = crypt.o diff --git a/src/config/Makefile.ppc_linux24 b/src/config/Makefile.ppc_linux24 new file mode 100644 index 0000000..3230ad6 --- /dev/null +++ b/src/config/Makefile.ppc_linux24 @@ -0,0 +1,46 @@ +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = LINUX + +# Base directory for linux kernel source. Actually a prefix which is complete +# when LINUX_VERS is appended to it. +LINUX_SRCDIR = /usr/src/linux- +# Default list of Linux kernels to build. Build will run only if all +# can be built. To build a different set, specify LINUX_VERS to make. +LINUX_VERS = 2.4.0-test9 + +# +# compilation and link editor flags +DBG=-g +OPTMZ=-O2 +PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC +# Put -O2 here to _ensure_ all Makefiles pick it up. +XCFLAGS= -O2 +MT_CFLAGS=-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS} +XLDFLAGS= +SHARE_LDFLAGS = -shared -Xlinker -x +SHLIB_SUFFIX=so +SHLIB_CFLAGS= +# +# libraries +MTLIBS=-lpthread +TXLIBS= /usr/lib/libncurses.so +XLIBS= +# +# programs +AR=ar +AS=as +CP=cp +INSTALL=${SRCDIR}bin/install +LD=ld +MT_CC=cc +MV=mv +RANLIB=ranlib +RM=rm +WASHTOOL=${SRCDIR}bin/washtool +# +# Other OS specific requirements +# +YACC = bison -y +LEX = flex -l +# Used in des library. +CRYPT_OBJ = crypt.o diff --git a/src/config/afs_sysnames.h b/src/config/afs_sysnames.h index 4c25810..437314a 100644 --- a/src/config/afs_sysnames.h +++ b/src/config/afs_sysnames.h @@ -107,6 +107,13 @@ #define SYS_NAME_ID_i386_linux2 1500 #define SYS_NAME_ID_i386_linux22 1501 +#define SYS_NAME_ID_i386_linux24 1502 + +#define SYS_NAME_ID_ppc_linux2 1600 +#define SYS_NAME_ID_ppc_linux22 1601 +#define SYS_NAME_ID_ppc_linux24 1602 + + /* * Placeholder to keep system-wide standard flags since this file is included by all diff --git a/src/config/param.i386_linux24_usr.h b/src/config/param.i386_linux24_usr.h new file mode 100644 index 0000000..01c1ab1 --- /dev/null +++ b/src/config/param.i386_linux24_usr.h @@ -0,0 +1,54 @@ +#ifndef _PARAM_USR_I386_LINUX24_H_ +#define _PARAM_USR_I386_LINUX24_H_ + +/* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel, + * it's a judgment call. If something is obviously i386 specific, use that + * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2" + * in the sysname is the current version of the client. This takes into + * account the perferred OS user space configuration as well as the kernel. + */ + +#define UKERNEL 1 /* user space kernel */ +#define AFS_ENV 1 +#define AFS_USR_LINUX20_ENV 1 +#define AFS_USR_LINUX22_ENV 1 +#define AFS_USR_LINUX24_ENV 1 +#define AFS_NONFSTRANS 1 + +#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */ +#define AFS_SYSCALL 137 +#define AFS_64BIT_IOPS_ENV 1 +#define AFS_NAMEI_ENV 1 /* User space interface to file system */ +#include + +#define AFS_USERSPACE_IP_ADDR 1 +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + + +/* Machine / Operating system information */ +#define SYS_NAME "i386_linux24" +#define SYS_NAME_ID SYS_NAME_ID_i386_linux24 +#define AFSLITTLE_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ + +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS 1 +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define VATTR_NULL usr_vattr_null + +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif + +#endif /* _PARAM_USR_I386_LINUX24_H_ */ diff --git a/src/config/param.ppc_linux24.h b/src/config/param.ppc_linux24.h new file mode 100644 index 0000000..b88c0c0 --- /dev/null +++ b/src/config/param.ppc_linux24.h @@ -0,0 +1,63 @@ +#ifndef _PARAM_PPC_LINUX24_H_ +#define _PARAM_PPC_LINUX24_H_ + +/* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel, + * it's a judgment call. If something is obviously ppc specific, use that + * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2" + * in the sysname is the current version of the client. This takes into + * account the perferred OS user space configuration as well as the kernel. + */ + +#define AFS_LINUX20_ENV 1 +#define AFS_LINUX22_ENV 1 +#define AFS_LINUX24_ENV 1 +#define AFS_PPC_LINUX20_ENV 1 +#define AFS_PPC_LINUX22_ENV 1 +#define AFS_PPC_LINUX24_ENV 1 +#define AFS_NONFSTRANS 1 + +#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */ +#define AFS_SYSCALL 137 +#define AFS_64BIT_IOPS_ENV 1 +#define AFS_NAMEI_ENV 1 /* User space interface to file system */ +#include + +#define AFS_USERSPACE_IP_ADDR 1 +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + + +/* Machine / Operating system information */ +#define SYS_NAME "ppc_linux24" +#define SYS_NAME_ID SYS_NAME_ID_ppc_linux24 +#define AFSBIG_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ + +#if defined(__KERNEL__) && !defined(KDUMP_KERNEL) +#include +#ifdef CONFIG_SMP +#undef CONFIG_SMP +#endif +/* Using "AFS_SMP" to map to however many #define's are required to get + * MP to compile for Linux + */ +#ifdef AFS_SMP +#define CONFIG_SMP +#define __SMP__ +#define AFS_GLOBAL_SUNLOCK +#endif + +#endif /* __KERNEL__ && !DUMP_KERNEL*/ + +#ifdef KERNEL +#ifndef MIN +#define MIN(A,B) ((A) < (B) ? (A) : (B)) +#endif +#ifndef MAX +#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#endif +#endif /* KERNEL */ + +#endif /* _PARAM_PPC_LINUX24_H_ */ diff --git a/src/config/param.ppc_linux24_usr.h b/src/config/param.ppc_linux24_usr.h new file mode 100644 index 0000000..bc9c781 --- /dev/null +++ b/src/config/param.ppc_linux24_usr.h @@ -0,0 +1,54 @@ +#ifndef _PARAM_USR_PPC_LINUX24_H_ +#define _PARAM_USR_PPC_LINUX24_H_ + +/* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel, + * it's a judgment call. If something is obviously ppc specific, use that + * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2" + * in the sysname is the current version of the client. This takes into + * account the perferred OS user space configuration as well as the kernel. + */ + +#define UKERNEL 1 /* user space kernel */ +#define AFS_ENV 1 +#define AFS_USR_LINUX20_ENV 1 +#define AFS_USR_LINUX22_ENV 1 +#define AFS_USR_LINUX24_ENV 1 +#define AFS_NONFSTRANS 1 + +#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */ +#define AFS_SYSCALL 137 +#define AFS_64BIT_IOPS_ENV 1 +#define AFS_NAMEI_ENV 1 /* User space interface to file system */ +#include + +#define AFS_USERSPACE_IP_ADDR 1 +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + + +/* Machine / Operating system information */ +#define SYS_NAME "ppc_linux24" +#define SYS_NAME_ID SYS_NAME_ID_ppc_linux24 +#define AFSBIG_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ + +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS 1 +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define VATTR_NULL usr_vattr_null + +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif + +#endif /* _PARAM_USR_PPC_LINUX24_H_ */ diff --git a/src/des/andrew-conf.h b/src/des/andrew-conf.h index 9dbb4b6..5613adf 100644 --- a/src/des/andrew-conf.h +++ b/src/des/andrew-conf.h @@ -41,7 +41,11 @@ #include "conf-winnt.h" #else #ifdef AFS_LINUX20_ENV +#ifdef AFS_PPC_LINUX20_ENV +#include "conf-ppc-linux.h" +#else #include "conf-i386-linux.h" +#endif #else Sorry, you lose. Figure out what the machine looks like and fix this file to include it. diff --git a/src/libafs/MakefileProto.LINUX b/src/libafs/MakefileProto.LINUX index 44b09e6..ae406bd 100644 --- a/src/libafs/MakefileProto.LINUX +++ b/src/libafs/MakefileProto.LINUX @@ -36,10 +36,17 @@ AFS_OS_NONFSOBJS = CC = gcc LD = ld # -Wall + CCFLAGS = -O2 -fomit-frame-pointer \ -fno-strength-reduce -pipe -m486 -malign-loops=2 -malign-jumps=2 \ -malign-functions=2 DEFINES = -D__KERNEL__ -DCPU=586 -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF} + +CCFLAGS = -O2 -fomit-frame-pointer -fno-strength-reduce \ + -fno-strict-aliasing -fsigned-char -msoft-float -pipe \ + -fno-builtin -ffixed-r2 +DEFINES = -D__KERNEL__ -D__powerpc__ -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF} + INCLUDES = -I. -I../ CFLAGS = $(CCFLAGS) $(DEFINES) $(INCLUDES) @@ -84,7 +91,11 @@ ${COMPDIRS}: rm -f sys; \ ln -s $${IDIR} sys; \ rm -f asm; \ + ln -s ${LINUX_SRCDIR}$$v/include/asm-i386 asm ; \ + + ln -s ${LINUX_SRCDIR}$$v/include/asm-ppc asm ; \ + for m in ${MPS} ; do \ KDIR=${KOBJ}-$$v-$$m ; \ echo Building in directory: $${KDIR} ; \ diff --git a/src/lwp/Makefile b/src/lwp/Makefile index dda9287..cfacbe4 100644 --- a/src/lwp/Makefile +++ b/src/lwp/Makefile @@ -66,7 +66,7 @@ process.o : process.s process.c $(CC) -c -I${SRCDIR}include -KPIC -G0 process.s;; \ sgi_61 | sgi_62 | sgi_63 ) \ $(CC) -c ${XCFLAGS} -I${SRCDIR}include -KPIC -G0 process.s;; \ - hp* | i386_linux* | sgi_64 | sgi_65) \ + hp* | *_linux* | sgi_64 | sgi_65) \ ${CC} ${CFLAGS} -c process.c;; \ ncrx86_*) \ /usr/ccs/lib/cpp -P -I${SRCDIR}include process.s process.ss; \ diff --git a/src/lwp/process.c b/src/lwp/process.c index ad6e676..706752b 100644 --- a/src/lwp/process.c +++ b/src/lwp/process.c @@ -31,7 +31,11 @@ extern char PRE_Block; /* used in lwp.c and process.s */ #elif defined(AFS_HPUX_ENV) #define LWP_SP 1 #elif defined(AFS_LINUX20_ENV) +#if defined(AFS_PPC_LINUX20_ENV) +#define LWP_SP 0 +#else #define LWP_SP 4 +#endif #else Need offset to SP in jmp_buf for this platform. #endif diff --git a/src/rx/LINUX/rx_kmutex.h b/src/rx/LINUX/rx_kmutex.h index 66ed1c8..6a53dd1 100644 --- a/src/rx/LINUX/rx_kmutex.h +++ b/src/rx/LINUX/rx_kmutex.h @@ -39,8 +39,11 @@ typedef struct afs_kmutex { int owner; } afs_kmutex_t; +#if defined(AFS_LINUX24_ENV) +typedef wait_queue_head_t afs_kcondvar_t; +#else typedef struct wait_queue *afs_kcondvar_t; - +#endif static inline int MUTEX_ISMINE(afs_kmutex_t *l) { @@ -50,7 +53,11 @@ static inline int MUTEX_ISMINE(afs_kmutex_t *l) static inline void afs_mutex_init(afs_kmutex_t *l) { +#if defined(AFS_LINUX24_ENV) + init_MUTEX(&l->sem); +#else l->sem = MUTEX; +#endif l->owner = 0; } #define MUTEX_INIT(a,b,c,d) afs_mutex_init(a) @@ -85,7 +92,11 @@ static inline void MUTEX_EXIT(afs_kmutex_t *l) up(&l->sem); } +#if defined(AFS_LINUX24_ENV) +#define CV_INIT(cv,b,c,d) init_waitqueue_head((wait_queue_head_t *)(cv)) +#else #define CV_INIT(cv,b,c,d) init_waitqueue((struct wait_queue**)(cv)) +#endif #define CV_DESTROY(cv) /* CV_WAIT and CV_TIMEDWAIT rely on the fact that the Linux kernel has @@ -99,7 +110,11 @@ static inline CV_WAIT(afs_kcondvar_t *cv, afs_kmutex_t *l) if (isAFSGlocked) AFS_GUNLOCK(); MUTEX_EXIT(l); +#if defined(AFS_LINUX24_ENV) + interruptible_sleep_on((wait_queue_head_t *)cv); +#else interruptible_sleep_on((struct wait_queue**)cv); +#endif MUTEX_ENTER(l); if (isAFSGlocked) AFS_GLOCK(); @@ -115,7 +130,11 @@ static inline CV_TIMEDWAIT(afs_kcondvar_t *cv, afs_kmutex_t *l, int waittime) if (isAFSGlocked) AFS_GUNLOCK(); MUTEX_EXIT(l); +#if defined(AFS_LINUX24_ENV) + t = interruptible_sleep_on_timeout((wait_queue_head_t *)cv, t); +#else t = interruptible_sleep_on_timeout((struct wait_queue**)cv, t); +#endif MUTEX_ENTER(l); if (isAFSGlocked) AFS_GLOCK(); @@ -123,8 +142,13 @@ static inline CV_TIMEDWAIT(afs_kcondvar_t *cv, afs_kmutex_t *l, int waittime) return 0; } +#if defined(AFS_LINUX24_ENV) +#define CV_SIGNAL(cv) wake_up((wait_queue_head_t *)cv) +#define CV_BROADCAST(cv) wake_up((wait_queue_head_t *)cv) +#else #define CV_SIGNAL(cv) wake_up((struct wait_queue**)cv) #define CV_BROADCAST(cv) wake_up((struct wait_queue**)cv) +#endif #else diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c index 9d3dcfa..37a39f4 100644 --- a/src/rx/LINUX/rx_knet.c +++ b/src/rx/LINUX/rx_knet.c @@ -15,6 +15,9 @@ #include "../afs/param.h" #ifdef AFS_LINUX22_ENV #include "../rx/rx_kcommon.h" +#if defined(AFS_LINUX24_ENV) +#include "../h/smp_lock.h" +#endif #include /* rxk_NewSocket @@ -38,7 +41,11 @@ struct osi_socket *rxk_NewSocket(short aport) code = sockp->ops->bind(sockp, (struct sockaddr*)&myaddr, sizeof(myaddr)); if (code<0) { +#if defined(AFS_LINUX24_ENV) + printk("sock_release(rx_socket) FIXME\n"); +#else sock_release(sockp); +#endif return NULL; } diff --git a/src/rx/Makefile b/src/rx/Makefile index afcc7ef..5fc6a0b 100644 --- a/src/rx/Makefile +++ b/src/rx/Makefile @@ -124,7 +124,7 @@ kinstall: includes $(INSTALL) DUX/*.[ch] $(KERNELDIR)rx;; \ hp_ux* ) \ $(INSTALL) HPUX/*.[ch] $(KERNELDIR)rx;; \ - i386_linux* ) \ + *_linux* ) \ $(INSTALL) LINUX/*.[ch] $(KERNELDIR)rx;; \ rs_aix* ) \ $(INSTALL) AIX/*.[ch] $(KERNELDIR)rx;; \ diff --git a/src/venus/kdump.c b/src/venus/kdump.c index f270d8f..89d4c32 100644 --- a/src/venus/kdump.c +++ b/src/venus/kdump.c @@ -2423,8 +2423,13 @@ void print_vnode(kmem, vep, ptr, pnt) vep->i_nrpages); printf("\ti_op=0x%x, i_dev=0x%x, i_rdev=0x%x, i_sb=0x%x\n", vep->i_op, vep->i_dev, vep->i_rdev, vep->i_sb); +#ifdef AFS_LINUX24_ENV + printf("\ti_sem: count=%d, sleepers=%d, wait=0x%x\n", + vep->i_sem.count, vep->i_sem.sleepers, vep->i_sem.wait); +#else printf("\ti_sem: count=%d, waking=%d, wait=0x%x\n", vep->i_sem.count, vep->i_sem.waking, vep->i_sem.wait); +#endif printf("\ti_hash=0x%x:0x%x, i_list=0x%x:0x%x, i_dentry=0x%x:0x%x\n", vep->i_hash.prev, vep->i_hash.next, vep->i_list.prev, vep->i_list.next, -- 1.9.4