delete VERBOSE #ifdef's
[unix-history] / usr / src / sys / ufs / ffs / inode.h
index 390eea3..6b56de2 100644 (file)
@@ -2,71 +2,83 @@
  * Copyright (c) 1982, 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)inode.h     7.10 (Berkeley) %G%
+ *     @(#)inode.h     7.29 (Berkeley) %G%
  */
 
  */
 
-#ifdef KERNEL
-#include "../ufs/dinode.h"
-#else
-#include <ufs/dinode.h>
-#endif
+#include <ufs/ufs/dinode.h>
 
 /*
 
 /*
- * The I node is the focus of all file activity in UNIX.
- * There is a unique inode allocated for each active file,
- * each current directory, each mounted-on file, text file, and the root.
- * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
- * Data in `struct dinode' is read in from permanent inode on volume.
+ * Theoretically, directories can be more than 2Gb in length,
+ * however, in practice this seems unlikely. So, we define
+ * the type doff_t as a long to keep down the cost of doing
+ * lookup on a 32-bit machine. If you are porting to a 64-bit
+ * architecture, you should make doff_t the same as off_t.
  */
  */
+#define doff_t long
 
 
+/*
+ * The inode is used to describe each active (or recently active)
+ * file in the UFS filesystem. It is composed of two types of
+ * information. The first part is the information that is needed
+ * only while the file is active (such as the identity of the file
+ * and linkage to speed its lookup). The second part is the 
+ * permannent meta-data associated with the file which is read
+ * in from the permanent dinode from long term storage when the
+ * file becomes active, and is put back when the file is no longer
+ * being used.
+ */
 struct inode {
 struct inode {
-       struct  inode *i_chain[2]; /* hash chain, MUST be first */
+       struct  inode *i_next;  /* hash chain forward */
+       struct  inode **i_prev; /* hash chain back */
        struct  vnode *i_vnode; /* vnode associated with this inode */
        struct  vnode *i_devvp; /* vnode for block I/O */
        u_long  i_flag;         /* see below */
        dev_t   i_dev;          /* device where inode resides */
        struct  vnode *i_vnode; /* vnode associated with this inode */
        struct  vnode *i_devvp; /* vnode for block I/O */
        u_long  i_flag;         /* see below */
        dev_t   i_dev;          /* device where inode resides */
-       ino_t   i_number;       /* i number, 1-to-1 with device address */
-       struct  fs *i_fs;       /* file sys associated with this inode */
-       struct  dquot *i_dquot; /* quota structure controlling this file */
-       long    i_diroff;       /* offset in dir, where we found last entry */
-       off_t   i_endoff;       /* end of useful stuff in directory */
-       long    i_spare0;
-       long    i_spare1;
-       long    i_spare2;
-       struct  dinode i_din;   /* the on-disk inode */
+       ino_t   i_number;       /* the identity of the inode */
+       union {                 /* associated filesystem */
+               struct  fs *fs;         /* FFS */
+               struct  lfs *lfs;       /* LFS */
+       } inode_u;
+#define        i_fs    inode_u.fs
+#define        i_lfs   inode_u.lfs
+       struct  dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot structures */
+       u_quad_t i_modrev;      /* revision level for lease */
+       struct  lockf *i_lockf; /* head of byte-level lock list */
+       pid_t   i_lockholder;   /* DEBUG: holder of inode lock */
+       pid_t   i_lockwaiter;   /* DEBUG: latest blocked for inode lock */
+       /*
+        * Side effects; used during directory lookup.
+        */
+       doff_t  i_endoff;       /* end of useful stuff in directory */
+       doff_t  i_diroff;       /* offset in dir, where we found last entry */
+       doff_t  i_offset;       /* offset of free space in directory */
+       long    i_count;        /* size of free slot in directory */
+       ino_t   i_ino;          /* inode number of found directory */
+       u_long  i_reclen;       /* size of found directory entry */
+       /*
+        * the on-disk dinode itself.
+        */
+       struct  dinode i_din;   /* the on-disk dinode */
+       long    i_spare[12];    /* spares to round up to 256 bytes */
 };
 
 #define        i_mode          i_din.di_mode
 #define        i_nlink         i_din.di_nlink
 #define        i_uid           i_din.di_uid
 #define        i_gid           i_din.di_gid
 };
 
 #define        i_mode          i_din.di_mode
 #define        i_nlink         i_din.di_nlink
 #define        i_uid           i_din.di_uid
 #define        i_gid           i_din.di_gid
-/* ugh! -- must be fixed */
-#if defined(vax) || defined(tahoe)
-#define        i_size          i_din.di_qsize.val[0]
-#endif
+#define i_size         i_din.di_size
 #define        i_db            i_din.di_db
 #define        i_ib            i_din.di_ib
 #define        i_atime         i_din.di_atime
 #define        i_mtime         i_din.di_mtime
 #define        i_ctime         i_din.di_ctime
 #define i_blocks       i_din.di_blocks
 #define        i_db            i_din.di_db
 #define        i_ib            i_din.di_ib
 #define        i_atime         i_din.di_atime
 #define        i_mtime         i_din.di_mtime
 #define        i_ctime         i_din.di_ctime
 #define i_blocks       i_din.di_blocks
-#define        i_rdev          i_din.di_db[0]
+#define        i_rdev          i_din.di_rdev
+#define        i_shortlink     i_din.di_shortlink
 #define i_flags                i_din.di_flags
 #define i_gen          i_din.di_gen
 #define i_flags                i_din.di_flags
 #define i_gen          i_din.di_gen
-#define        i_forw          i_chain[0]
-#define        i_back          i_chain[1]
 
 /* flags */
 #define        ILOCKED         0x0001          /* inode is locked */
 
 /* flags */
 #define        ILOCKED         0x0001          /* inode is locked */
@@ -81,29 +93,11 @@ struct inode {
 #define        ILWAIT          0x0400          /* someone waiting on file lock */
 
 #ifdef KERNEL
 #define        ILWAIT          0x0400          /* someone waiting on file lock */
 
 #ifdef KERNEL
-/*
- * Convert between inode pointers and vnode pointers
- */
+/* Convert between inode pointers and vnode pointers. */
 #define VTOI(vp)       ((struct inode *)(vp)->v_data)
 #define ITOV(ip)       ((ip)->i_vnode)
 
 #define VTOI(vp)       ((struct inode *)(vp)->v_data)
 #define ITOV(ip)       ((ip)->i_vnode)
 
-/*
- * Convert between vnode types and inode formats
- */
-extern enum vtype      iftovt_tab[];
-extern int             vttoif_tab[];
-#define IFTOVT(mode)   (iftovt_tab[((mode) & IFMT) >> 13])
-#define VTTOIF(indx)   (vttoif_tab[(int)(indx)])
-
-#define MAKEIMODE(indx, mode)  (int)(VTTOIF(indx) | (mode))
-
-u_long nextgennumber;          /* next generation number to assign */
-
-extern ino_t   dirpref();
-
-/*
- * Lock and unlock inodes.
- */
+/* Lock and unlock inodes. */
 #ifdef notdef
 #define        ILOCK(ip) { \
        while ((ip)->i_flag & ILOCKED) { \
 #ifdef notdef
 #define        ILOCK(ip) { \
        while ((ip)->i_flag & ILOCKED) { \
@@ -121,35 +115,30 @@ extern ino_t      dirpref();
        } \
 }
 #else
        } \
 }
 #else
-#define ILOCK(ip)      ilock(ip)
-#define IUNLOCK(ip)    iunlock(ip)
+#define ILOCK(ip)      ufs_ilock(ip)
+#define IUNLOCK(ip)    ufs_iunlock(ip)
 #endif
 
 #endif
 
-#define        IUPDAT(ip, t1, t2, waitfor) { \
-       if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
-               (void) iupdat(ip, t1, t2, waitfor); \
-}
-
 #define        ITIMES(ip, t1, t2) { \
        if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
                (ip)->i_flag |= IMOD; \
                if ((ip)->i_flag&IACC) \
 #define        ITIMES(ip, t1, t2) { \
        if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
                (ip)->i_flag |= IMOD; \
                if ((ip)->i_flag&IACC) \
-                       (ip)->i_atime = (t1)->tv_sec; \
-               if ((ip)->i_flag&IUPD) \
-                       (ip)->i_mtime = (t2)->tv_sec; \
+                       (ip)->i_atime.ts_sec = (t1)->tv_sec; \
+               if ((ip)->i_flag&IUPD) { \
+                       (ip)->i_mtime.ts_sec = (t2)->tv_sec; \
+                       (ip)->i_modrev++; \
+               } \
                if ((ip)->i_flag&ICHG) \
                if ((ip)->i_flag&ICHG) \
-                       (ip)->i_ctime = time.tv_sec; \
+                       (ip)->i_ctime.ts_sec = time.tv_sec; \
                (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
        } \
 }
 
                (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
        } \
 }
 
-/*
- * This overlays the fid sturcture (see mount.h)
- */
+/* This overlays the fid structure (see mount.h). */
 struct ufid {
        u_short ufid_len;       /* length of structure */
        u_short ufid_pad;       /* force long alignment */
        ino_t   ufid_ino;       /* file number (ino) */
        long    ufid_gen;       /* generation number */
 };
 struct ufid {
        u_short ufid_len;       /* length of structure */
        u_short ufid_pad;       /* force long alignment */
        ino_t   ufid_ino;       /* file number (ino) */
        long    ufid_gen;       /* generation number */
 };
-#endif
+#endif /* KERNEL */