move inode tracing out of xfs_vnode.
[safe/jmp/linux-2.6] / fs / xfs / xfs_error.c
index 2a21c50..f227ecd 100644 (file)
 #include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
-#include "xfs_dir.h"
+#include "xfs_ag.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_bmap_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
@@ -59,22 +58,11 @@ xfs_error_trap(int e)
        }
        return e;
 }
-#endif
-
-#if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
 
 int    xfs_etest[XFS_NUM_INJECT_ERROR];
 int64_t        xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
 char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
 
-void
-xfs_error_test_init(void)
-{
-       memset(xfs_etest, 0, sizeof(xfs_etest));
-       memset(xfs_etest_fsid, 0, sizeof(xfs_etest_fsid));
-       memset(xfs_etest_fsname, 0, sizeof(xfs_etest_fsname));
-}
-
 int
 xfs_error_test(int error_tag, int *fsidp, char *expression,
               int line, char *file, unsigned long randfactor)
@@ -82,7 +70,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
        int i;
        int64_t fsid;
 
-       if (random() % randfactor)
+       if (random32() % randfactor)
                return 0;
 
        memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));
@@ -134,36 +122,14 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp)
 }
 
 int
-xfs_errortag_clear(int error_tag, xfs_mount_t *mp)
+xfs_errortag_clearall(xfs_mount_t *mp, int loud)
 {
-       int i;
        int64_t fsid;
+       int cleared = 0;
+       int i;
 
        memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
 
-       for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
-               if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
-                       xfs_etest[i] = 0;
-                       xfs_etest_fsid[i] = 0LL;
-                       kmem_free(xfs_etest_fsname[i],
-                                 strlen(xfs_etest_fsname[i]) + 1);
-                       xfs_etest_fsname[i] = NULL;
-                       cmn_err(CE_WARN, "Cleared XFS error tag #%d",
-                               error_tag);
-                       return 0;
-               }
-       }
-
-       cmn_err(CE_WARN, "XFS error tag %d not on", error_tag);
-
-       return 1;
-}
-
-int
-xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud)
-{
-       int i;
-       int cleared = 0;
 
        for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
                if ((fsid == 0LL || xfs_etest_fsid[i] == fsid) &&
@@ -173,8 +139,7 @@ xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud)
                                xfs_etest[i]);
                        xfs_etest[i] = 0;
                        xfs_etest_fsid[i] = 0LL;
-                       kmem_free(xfs_etest_fsname[i],
-                                 strlen(xfs_etest_fsname[i]) + 1);
+                       kmem_free(xfs_etest_fsname[i]);
                        xfs_etest_fsname[i] = NULL;
                }
        }
@@ -182,21 +147,11 @@ xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud)
        if (loud || cleared)
                cmn_err(CE_WARN,
                        "Cleared all XFS error tags for filesystem \"%s\"",
-                       fsname);
+                       mp->m_fsname);
 
        return 0;
 }
-
-int
-xfs_errortag_clearall(xfs_mount_t *mp)
-{
-       int64_t fsid;
-
-       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
-
-       return xfs_errortag_clearall_umount(fsid, mp->m_fsname, 1);
-}
-#endif /* DEBUG || INDUCE_IO_ERROR */
+#endif /* DEBUG */
 
 static void
 xfs_fs_vcmn_err(int level, xfs_mount_t *mp, char *fmt, va_list ap)
@@ -208,7 +163,7 @@ xfs_fs_vcmn_err(int level, xfs_mount_t *mp, char *fmt, va_list ap)
                newfmt = kmem_alloc(len, KM_SLEEP);
                sprintf(newfmt, "Filesystem \"%s\": %s", mp->m_fsname, fmt);
                icmn_err(level, newfmt, ap);
-               kmem_free(newfmt, len);
+               kmem_free(newfmt);
        } else {
                icmn_err(level, fmt, ap);
        }
@@ -263,37 +218,6 @@ xfs_error_report(
        }
 }
 
-STATIC void
-xfs_hex_dump(void *p, int length)
-{
-       __uint8_t *uip = (__uint8_t*)p;
-       int     i;
-       char    sbuf[128], *s;
-
-       s = sbuf;
-       *s = '\0';
-       for (i=0; i<length; i++, uip++) {
-               if ((i % 16) == 0) {
-                       if (*s != '\0')
-                               cmn_err(CE_ALERT, "%s\n", sbuf);
-                       s = sbuf;
-                       sprintf(s, "0x%x: ", i);
-                       while( *s != '\0')
-                               s++;
-               }
-               sprintf(s, "%02x ", *uip);
-
-               /*
-                * the kernel sprintf is a void; user sprintf returns
-                * the sprintf'ed string's length.  Find the new end-
-                * of-string
-                */
-               while( *s != '\0')
-                       s++;
-       }
-       cmn_err(CE_ALERT, "%s\n", sbuf);
-}
-
 void
 xfs_corruption_error(
        char            *tag,