linux22-fix-20040405
authorChas Williams <chas3@users.sourceforge.net>
Mon, 5 Apr 2004 23:39:51 +0000 (23:39 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 5 Apr 2004 23:39:51 +0000 (23:39 +0000)
FIXES 3909

make linux 2.2 work again

src/afs/LINUX/osi_inode.c
src/afs/LINUX/osi_machdep.h
src/afs/LINUX/osi_misc.c
src/afs/LINUX/osi_vfsops.c
src/afs/LINUX/osi_vnodeops.c
src/afs/afs.h

index 0612db5..36d4c2a 100644 (file)
@@ -28,19 +28,6 @@ RCSID
 #include "afs/osi_inode.h"
 #include "afs/afs_stats.h"     /* statistics stuff */
 
-#define BAD_IGET       -1000
-
-/*
- * SGI dependent system calls
- */
-#ifndef INODESPECIAL
-/*
- * `INODESPECIAL' type inodes are ones that describe volumes.
- */
-#define INODESPECIAL   0xffffffff      /* ... from ../vol/viceinode.h  */
-#endif
-
-
 int
 afs_syscall_icreate(void)
 {
index 3184f7f..5485f3e 100644 (file)
 #define afs_hz HZ
 #include "h/sched.h"
 #define osi_Time() (xtime.tv_sec)
-#if  (CPU == sparc64)
-#define osi_GetTime(V) do { (*(V)).tv_sec = xtime.tv_sec; (*(V)).tv_usec = xtime.tv_usec; } while (0)
-#else
-#define osi_GetTime(V) (*(V)=xtime)
-#endif
+#define osi_GetTime(V) do_gettimeofday((V))
 
 #undef gop_lookupname
 #define gop_lookupname osi_lookupname
  * Use the same type of test as other OS's for compatibility.
  */
 #undef IsAfsVnode
-extern struct vnodeops afs_dir_iops, afs_symlink_iops;
-#define IsAfsVnode(vc) (((vc)->v_op == afs_ops) ? 1 : \
-                       ((vc)->v_op == &afs_dir_iops) ? 1 : \
-                       ((vc)->v_op == &afs_symlink_iops))
-
-#if 0
-/* bcopy is in stds.h, just so fcrypt.c can pick it up. */
-#define bzero(D,C)   memset((D), 0, (C))
-#define bcmp(A,B,C)  memcmp((A), (B), (C))
-#endif
+extern struct vnodeops afs_file_iops, afs_dir_iops, afs_symlink_iops;
+#define IsAfsVnode(v) (((v)->v_op == &afs_file_iops) ? 1 : \
+                       ((v)->v_op == &afs_dir_iops) ? 1 : \
+                       ((v)->v_op == &afs_symlink_iops))
+#undef SetAfsVnode
+#define SetAfsVnode(v)
 
 /* We often need to pretend we're in user space to get memory transfers
  * right for the kernel calls we use.
index 7c928bc..c6bc84a 100644 (file)
@@ -24,16 +24,15 @@ RCSID
 #include "h/smp_lock.h"
 #endif
 
-char *crash_addr = 0;          /* Induce an oops by writing here. */
-
 #if defined(AFS_LINUX24_ENV)
 /* Lookup name and return vnode for same. */
 int
-osi_lookupname_internal(char *aname, uio_seg_t seg, int followlink,
-                       vnode_t ** dirvpp, struct dentry **dpp,
-                       struct nameidata *nd)
+osi_lookupname(char *aname, uio_seg_t seg, int followlink,
+                       vnode_t ** dirvpp, struct dentry **dpp)
 {
     int code;
+    extern struct nameidata afs_cacheNd;
+    struct nameidata *nd = &afs_cacheNd;
 
     code = ENOENT;
     if (seg == AFS_UIOUSER) {
@@ -56,21 +55,11 @@ osi_lookupname_internal(char *aname, uio_seg_t seg, int followlink,
     }
     return code;
 }
-#endif
-
+#else
 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;
-    int code = osi_lookupname_internal(aname, seg, followlink, dirvpp, dpp,
-                                      &nd);
-    if (!code)
-       path_release(&nd);
-
-    return (code);
-#else
     struct dentry *dp = NULL;
     int code;
 
@@ -90,8 +79,8 @@ osi_lookupname(char *aname, uio_seg_t seg, int followlink, vnode_t ** dirvpp,
     }
 
     return code;
-#endif
 }
+#endif
 
 /* Intialize cache device info and fragment size for disk cache partition. */
 int
@@ -103,16 +92,12 @@ osi_InitCacheInfo(char *aname)
     extern struct osi_dev cacheDev;
     extern afs_int32 afs_fsfragsize;
     extern struct super_block *afs_cacheSBp;
-    extern struct nameidata afs_cacheNd;
-
-    code =
-       osi_lookupname_internal(aname, AFS_UIOSYS, 1, NULL, &dp,
-                               &afs_cacheNd);
+    code = osi_lookupname(aname, AFS_UIOSYS, 1, NULL, &dp);
     if (code)
        return ENOENT;
 
     cacheInode = dp->d_inode->i_ino;
-    cacheDev.dev = dp->d_inode->i_dev;
+    cacheDev.dev = dp->d_inode->i_sb->s_dev;
     afs_fsfragsize = dp->d_inode->i_sb->s_blocksize - 1;
     afs_cacheSBp = dp->d_inode->i_sb;
 
index 7ef1bc7..cb23a75 100644 (file)
@@ -26,13 +26,15 @@ RCSID
 #include "h/smp_lock.h"
 #endif
 
-#define __NO_VERSION__         /* don't define kernel_verion in module.h */
+#define __NO_VERSION__         /* don't define kernel_version in module.h */
 #include <linux/module.h>
 
 
 struct vcache *afs_globalVp = 0;
 struct vfs *afs_globalVFS = 0;
+#if defined(AFS_LINUX24_ENV)
 struct nameidata afs_cacheNd;
+#endif
 int afs_was_mounted = 0;       /* Used to force reload if mount/unmount/mount */
 
 extern struct super_operations afs_sops;
@@ -167,20 +169,6 @@ afs_root(struct super_block *afsp)
 
 /* super_operations */
 
-/* afs_read_inode
- * called via iget to read in the inode. The passed in inode has i_ino, i_dev
- * and i_sb setup on input. Linux file systems use this to get super block
- * inode information, so we don't really care what happens here.
- * For Linux 2.2, we'll be called if we participate in the inode pool.
- */
-void
-afs_read_inode(struct inode *ip)
-{
-    /* I don't think we ever get called with this. So print if we do. */
-    printf("afs_read_inode: Called for inode %d\n", ip->i_ino);
-}
-
-
 /* afs_notify_change
  * Linux version of setattr call. What to change is in the iattr struct.
  * We need to set bits in both the Linux inode as well as the vcache.
@@ -282,7 +270,9 @@ afs_put_super(struct super_block *sbp)
     afs_globalVFS = 0;
     afs_globalVp = 0;
     afs_shutdown();
+#if defined(AFS_LINUX24_ENV)
     path_release(&afs_cacheNd);
+#endif
 
     osi_linux_verify_alloced_memory();
   done:
@@ -294,23 +284,6 @@ afs_put_super(struct super_block *sbp)
     }
 }
 
-#ifdef NOTUSED
-/* afs_write_super
- * Not required since we don't write out a super block. */
-void
-afs_write_super(struct super_block *sbp)
-{
-}
-
-/* afs_remount_fs
- * Used to remount filesystems with different flags. Not relevant for AFS.
- */
-int
-afs_remount_fs(struct super_block *sbp, int *, char *)
-{
-    return -EINVAL;
-}
-#endif
 
 /* afs_statfs
  * statp is in user space, so we need to cobble together a statfs, then
@@ -357,30 +330,16 @@ afs_umount_begin(struct super_block *sbp)
     afs_shuttingdown = 1;
 }
 
-#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,
-  umount_begin:afs_umount_begin
-};
-#else
-struct super_operations afs_sops = {
-    afs_read_inode,
-    afs_write_inode,           /* afs_write_inode - see doc above. */
-    NULL,                      /* afs_put_inode */
-    afs_delete_inode,
-    afs_notify_change,
-    afs_put_super,
-    NULL,                      /* afs_write_super - see doc above */
-    afs_statfs,
-    NULL,                      /* afs_remount_fs - see doc above */
-    NULL,                      /* afs_clear_inode */
-    afs_umount_begin
-};
+  .write_inode =       afs_write_inode,
+  .delete_inode =      afs_delete_inode,
+  .put_super =         afs_put_super,
+  .statfs =            afs_statfs,
+  .umount_begin =      afs_umount_begin
+#if !defined(AFS_LINUX24_ENV)
+  .notifY_change =     afs_notify_change,
 #endif
+};
 
 /************** Support routines ************************/
 
index d30c6e3..06de2a9 100644 (file)
@@ -9,9 +9,7 @@
 
 /*
  * Linux specific vnodeops. Also includes the glue routines required to call
- * AFS vnodeops. The "NOTUSED" #define is used to indicate routines and
- * calling sequences present in an ops table that we don't actually use.
- * They are present solely for documentation purposes.
+ * AFS vnodeops.
  *
  * So far the only truly scary part is that Linux relies on the inode cache
  * to be up to date. Don't you dare break a callback and expect an fstat
@@ -55,13 +53,6 @@ extern struct inode_operations afs_dir_iops;
 extern struct inode_operations afs_symlink_iops;
 
 
-#ifdef NOTUSED
-static int
-afs_linux_lseek(struct inode *ip, struct file *fp, off_t, int)
-{
-}
-#endif
-
 static ssize_t
 afs_linux_read(struct file *fp, char *buf, size_t count, loff_t * offp)
 {
@@ -417,9 +408,6 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
     return 0;
 }
 
-#ifdef NOTUSED
-int afs_linux_select(struct inode *ip, struct file *fp, int, select_table *);
-#endif
 
 /* in afs_pioctl.c */
 extern int afs_xioctl(struct inode *ip, struct file *fp, unsigned int com,
@@ -643,16 +631,6 @@ afs_linux_fsync(struct file *fp, struct dentry *dp)
 
 }
 
-#ifdef NOTUSED
-/* No support for async i/o */
-int afs_linux_fasync(struct inode *ip, struct file *fp, int);
-
-/* I don't think it will, at least not as can be detected here. */
-int afs_linux_check_media_change(kdev_t dev);
-
-/* Revalidate media and file system. */
-int afs_linux_file_revalidate(kdev_t dev);
-#endif /* NOTUSED */
 
 static int
 afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp)
@@ -737,74 +715,42 @@ afs_linux_flush(struct file *fp)
     return -code;
 }
 
+#if !defined(AFS_LINUX24_ENV)
 /* Not allowed to directly read a directory. */
 ssize_t
 afs_linux_dir_read(struct file * fp, char *buf, size_t count, loff_t * ppos)
 {
     return -EISDIR;
 }
+#endif
 
 
 
-#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,
-};
+#if !defined(AFS_LINUX24_ENV)
+  .read =      afs_linux_dir_read,
+  .lock =      afs_linux_lock,
+  .fsync =     afs_linux_fsync,
 #else
-struct file_operations afs_dir_fops = {
-    NULL,                      /* afs_linux_lseek */
-    afs_linux_dir_read,
-    NULL,                      /* afs_linux_write */
-    afs_linux_readdir,
-    NULL,                      /* afs_linux_select */
-    afs_xioctl,                        /* close enough to use the ported AFS one */
-    NULL,                      /* afs_linux_mmap */
-    afs_linux_open,
-    NULL,                      /* afs_linux_flush */
-    afs_linux_release,
-    afs_linux_fsync,
-    NULL,                      /* afs_linux_fasync */
-    NULL,                      /* afs_linux_check_media_change */
-    NULL,                      /* afs_linux_file_revalidate */
-    afs_linux_lock,
-};
+  .read =      generic_read_dir,
 #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,
+  .readdir =   afs_linux_readdir,
+  .ioctl =     afs_xioctl,
+  .open =      afs_linux_open,
+  .release =   afs_linux_release,
 };
-#else
+
 struct file_operations afs_file_fops = {
-    NULL,                      /* afs_linux_lseek */
-    afs_linux_read,
-    afs_linux_write,
-    NULL,                      /* afs_linux_readdir */
-    NULL,                      /* afs_linux_select */
-    afs_xioctl,                        /* close enough to use the ported AFS one */
-    afs_linux_mmap,
-    afs_linux_open,
-    afs_linux_flush,
-    afs_linux_release,
-    afs_linux_fsync,
-    NULL,                      /* afs_linux_fasync */
-    NULL,                      /* afs_linux_check_media_change */
-    NULL,                      /* afs_linux_file_revalidate */
-    afs_linux_lock,
+  .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,
 };
-#endif
 
 
 /**********************************************************************
@@ -989,24 +935,12 @@ afs_dentry_delete(struct dentry *dp)
     return 0;
 }
 
-#if defined(AFS_LINUX24_ENV)
-struct dentry_operations afs_dentry_operations = {
-  d_revalidate:afs_linux_dentry_revalidate,
-  d_iput:afs_dentry_iput,
-  d_delete:afs_dentry_delete,
-};
-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 */
-    NULL,                      /* d_compare */
-    afs_dentry_delete,         /* d_delete(struct dentry *) */
-    NULL,                      /* d_release(struct dentry *) */
-    afs_dentry_iput            /* d_iput(struct dentry *, struct inode *) */
+  .d_revalidate =      afs_linux_dentry_revalidate,
+  .d_iput =            afs_dentry_iput,
+  .d_delete =          afs_dentry_delete,
 };
 struct dentry_operations *afs_dops = &afs_dentry_operations;
-#endif
 
 /**********************************************************************
  * AFS Linux inode operations
@@ -1485,24 +1419,6 @@ afs_linux_writepage(struct page *pp)
 }
 #endif
 
-#ifdef NOTUSED
-/* afs_linux_bmap - supports generic_readpage, but we roll our own. */
-int
-afs_linux_bmap(struct inode *ip, int)
-{
-    return -EINVAL;
-}
-
-/* afs_linux_truncate
- * Handles discarding disk blocks if this were a device. ext2 indicates we
- * may need to zero partial last pages of memory mapped files.
- */
-void
-afs_linux_truncate(struct inode *ip)
-{
-}
-#endif
-
 /* afs_linux_permission
  * Check access rights - returns error if can't check or permission denied.
  */
@@ -1528,15 +1444,6 @@ afs_linux_permission(struct inode *ip, int mode)
 }
 
 
-#ifdef NOTUSED
-/* msdos sector mapping hack for memory mapping. */
-int
-afs_linux_smap(struct inode *ip, int)
-{
-    return -EINVAL;
-}
-#endif
-
 #if defined(AFS_LINUX24_ENV)
 int
 afs_linux_writepage_sync(struct inode *ip, struct page *pp,
@@ -1668,88 +1575,50 @@ afs_linux_prepare_write(struct file *file, struct page *page, unsigned from,
 extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp);
 #endif
 
-#if defined(AFS_LINUX24_ENV)
 struct inode_operations afs_file_iops = {
-  revalidate:afs_linux_revalidate,
-  setattr:afs_notify_change,
-  permission:afs_linux_permission,
-};
-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,
-};
-
-struct inode_operations *afs_ops = &afs_file_iops;
+#if defined(AFS_LINUX24_ENV)
+  .permission =                afs_linux_permission,
+  .revalidate =                afs_linux_revalidate,
+  .setattr =           afs_notify_change,
 #else
-struct inode_operations afs_iops = {
-    &afs_file_fops,            /* file operations */
-    NULL,                      /* afs_linux_create */
-    NULL,                      /* afs_linux_lookup */
-    NULL,                      /* afs_linux_link */
-    NULL,                      /* afs_linux_unlink */
-    NULL,                      /* afs_linux_symlink */
-    NULL,                      /* afs_linux_mkdir */
-    NULL,                      /* afs_linux_rmdir */
-    NULL,                      /* afs_linux_mknod */
-    NULL,                      /* afs_linux_rename */
-    NULL,                      /* afs_linux_readlink */
-    NULL,                      /* afs_linux_follow_link */
-    afs_linux_readpage,
-    NULL,                      /* afs_linux_writepage */
-    NULL,                      /* afs_linux_bmap */
-    NULL,                      /* afs_linux_truncate */
-    afs_linux_permission,
-    NULL,                      /* afs_linux_smap */
-    afs_linux_updatepage,
-    afs_linux_revalidate,
+  .default_file_ops =  &afs_file_fops,
+  .readpage =          afs_linux_readpage,
+  .revalidate =                afs_linux_revalidate,
+  .updatepage =                afs_linux_updatepage,
+#endif
 };
 
-struct inode_operations *afs_ops = &afs_iops;
+#if defined(AFS_LINUX24_ENV)
+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,
+};
 #endif
 
+
 /* Separate ops vector for directories. Linux 2.2 tests type of inode
  * by what sort of operation is allowed.....
  */
-#if defined(AFS_LINUX24_ENV)
+
 struct inode_operations afs_dir_iops = {
-  create:afs_linux_create,
-  lookup:afs_linux_lookup,
-  link:afs_linux_link,
-  unlink:afs_linux_unlink,
-  symlink:afs_linux_symlink,
-  mkdir:afs_linux_mkdir,
-  rmdir:afs_linux_rmdir,
-  rename:afs_linux_rename,
-  revalidate:afs_linux_revalidate,
-  setattr:afs_notify_change,
-  permission:afs_linux_permission,
-};
+#if !defined(AFS_LINUX24_ENV)
+  .default_file_ops =  &afs_dir_fops,
 #else
-struct inode_operations afs_dir_iops = {
-    &afs_dir_fops,             /* file operations for directories */
-    afs_linux_create,
-    afs_linux_lookup,
-    afs_linux_link,
-    afs_linux_unlink,
-    afs_linux_symlink,
-    afs_linux_mkdir,
-    afs_linux_rmdir,
-    NULL,                      /* afs_linux_mknod */
-    afs_linux_rename,
-    NULL,                      /* afs_linux_readlink */
-    NULL,                      /* afs_linux_follow_link */
-    NULL,                      /* afs_linux_readpage */
-    NULL,                      /* afs_linux_writepage */
-    NULL,                      /* afs_linux_bmap */
-    NULL,                      /* afs_linux_truncate */
-    afs_linux_permission,
-    NULL,                      /* afs_linux_smap */
-    NULL,                      /* afs_linux_updatepage */
-    afs_linux_revalidate,
-};
+  .setattr =           afs_notify_change,
 #endif
+  .create =            afs_linux_create,
+  .lookup =            afs_linux_lookup,
+  .link =              afs_linux_link,
+  .unlink =            afs_linux_unlink,
+  .symlink =           afs_linux_symlink,
+  .mkdir =             afs_linux_mkdir,
+  .rmdir =             afs_linux_rmdir,
+  .rename =            afs_linux_rename,
+  .revalidate =                afs_linux_revalidate,
+  .permission =                afs_linux_permission,
+};
 
 /* We really need a separate symlink set of ops, since do_follow_link()
  * determines if it _is_ a link by checking if the follow_link op is set.
@@ -1788,35 +1657,19 @@ afs_symlink_filler(struct file *file, struct page *page)
 }
 
 struct address_space_operations afs_symlink_aops = {
-  readpage:afs_symlink_filler
+  .readpage =  afs_symlink_filler
 };
+#endif
 
 struct inode_operations afs_symlink_iops = {
-  readlink:page_readlink,
-  follow_link:page_follow_link,
-  setattr:afs_notify_change,
-};
+#if defined(AFS_LINUX24_ENV)
+  .readlink =          page_readlink,
+  .follow_link =       page_follow_link,
+  .setattr =           afs_notify_change,
 #else
-struct inode_operations afs_symlink_iops = {
-    NULL,                      /* file operations */
-    NULL,                      /* create */
-    NULL,                      /* lookup */
-    NULL,                      /* link */
-    NULL,                      /* unlink */
-    NULL,                      /* symlink */
-    NULL,                      /* mkdir */
-    NULL,                      /* rmdir */
-    NULL,                      /* afs_linux_mknod */
-    NULL,                      /* rename */
-    afs_linux_readlink,
-    afs_linux_follow_link,
-    NULL,                      /* readpage */
-    NULL,                      /* afs_linux_writepage */
-    NULL,                      /* afs_linux_bmap */
-    NULL,                      /* afs_linux_truncate */
-    afs_linux_permission,      /* tho the code appears to indicate not used? */
-    NULL,                      /* afs_linux_smap */
-    NULL,                      /* updatepage */
-    afs_linux_revalidate,      /* tho the code appears to indicate not used? */
-};
+  .readlink =          afs_linux_readlink,
+  .follow_link =       afs_linux_follow_link,
+  .permission =                afs_linux_permission,
+  .revalidate =                afs_linux_revalidate,
 #endif
+};
index e35c0e6..cf95716 100644 (file)
@@ -551,7 +551,7 @@ struct SimpleLocks {
 #define vrefCount   v.v_count
 #endif /* AFS_XBSD_ENV */
 
-#ifdef AFS_LINUX24_ENV
+#if defined(AFS_LINUX24_ENV)
 #define VREFCOUNT(v)           atomic_read(&((vnode_t *) v)->v_count)
 #define VREFCOUNT_SET(v, c)    atomic_set(&((vnode_t *) v)->v_count, c)
 #define VREFCOUNT_DEC(v)       atomic_dec(&((vnode_t *) v)->v_count)