Whamcloud - gitweb
LU-812 kernel: AUTOCONF_INCLUDED removed
[fs/lustre-release.git] / lustre / include / linux / obd_support.h
index 4707963..4fdb4e5 100644 (file)
-#ifndef _OBD_SUPPORT
-#define _OBD_SUPPORT
 /*
- * Copyright (C) 2001  Cluster File Systems, Inc.
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- * This code is issued under the GNU General Public License.
- * See the file COPYING in this distribution
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
  */
-
-#include <linux/autoconf.h>
-#include <linux/slab.h>
-#include <linux/kp30.h>
-
-#define obd_unlock_page(page)                                           \
-do {                                                                    \
-        if (PageLocked(page)) {                                         \
-                UnlockPage(page);                                       \
-        } else {                                                        \
-                printk("file %s, line %d: expecting locked page\n",     \
-                       __FILE__, __LINE__);                             \
-        }                                                               \
-} while(0)
-
 /*
- * Debug code
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
  */
-/* global variables */
-extern int obd_debug_level;
-extern int obd_print_entry;
-extern int obd_inodes;
-extern int obd_pages;
-extern long obd_memory;
-
-#define EXT2_OBD_DEBUG
-
-#ifdef EXT2_OBD_DEBUG
-#define CMD(cmd) (( cmd == READ ) ? "read" : "write")
-
-/* Inode common information printed out (used by obdfs and ext2obd inodes) */
-#define ICDEBUG(inode) {                                                \
-        CDEBUG(D_INFO, "ino %ld, atm %ld, mtm %ld, ctm %ld, size %Ld, " \
-               "blocks %ld\n", inode->i_ino, inode->i_atime,            \
-               inode->i_mtime, inode->i_ctime, inode->i_size,           \
-               inode->i_blocks);                                        \
-        CDEBUG(D_INFO, "mode %o, uid %d, gid %d, nlnk %d, count %d\n",  \
-               inode->i_mode, inode->i_uid, inode->i_gid,               \
-               inode->i_nlink, atomic_read(&inode->i_count));           \
-}
-
-/* Ext2 inode information */
-#define EXDEBUG(inode) {                                                \
-        ICDEBUG(inode);                                                 \
-        CDEBUG(D_INFO, "ext2 blocks: %d %d %d %d %d %d %d %d\n",        \
-               inode->u.ext2_i.i_data[0], inode->u.ext2_i.i_data[1],    \
-               inode->u.ext2_i.i_data[2], inode->u.ext2_i.i_data[3],    \
-               inode->u.ext2_i.i_data[4], inode->u.ext2_i.i_data[5],    \
-               inode->u.ext2_i.i_data[6], inode->u.ext2_i.i_data[7]);   \
-}
-
-/* OBDFS inode information */
-#define OIDEBUG(inode) {                                                \
-        ICDEBUG(inode);                                                 \
-        CDEBUG(D_INFO,"oinfo: flags 0x%08x\n", obdfs_i2info(inode)->oi_flags);\
-        /* obdfs_print_plist(inode); */                                 \
-}
-
-#define ODEBUG(obdo) {                                                  \
-        CDEBUG(D_INFO, "id %ld, atm %ld, mtm %ld, ctm %ld, "            \
-               "size %ld, blocks %ld\n",                                \
-               (long)(obdo)->o_id, (long)(obdo)->o_atime,               \
-               (long)(obdo)->o_mtime, (long)(obdo)->o_ctime,            \
-               (long)(obdo)->o_size, (long)(obdo)->o_blocks);           \
-        CDEBUG(D_INFO, " mode %o, uid %d, gid %d, flg 0x%0x, "          \
-               "obdflg 0x%0x, nlnk %d, valid 0x%0x\n",                  \
-               (obdo)->o_mode, (obdo)->o_uid, (obdo)->o_gid, (obdo)->o_flags,\
-               (obdo)->o_obdflags, (obdo)->o_nlink, (obdo)->o_valid);   \
-}
-
-#define PDEBUG(page,msg) {                                              \
-        if (page){                                                      \
-                char *uptodate = (Page_Uptodate(page)) ? "upto" : "outof";\
-                char *locked = (PageLocked(page)) ? "" : "un";          \
-                char *buffer = page->buffers ? "buffer" : "";           \
-                int count = page_count(page);                           \
-                long index = page->index;                               \
-                CDEBUG(D_CACHE, "%s: ** off %ld, %sdate, %slocked, flag %ld,"\
-                       " cnt %d page 0x%p pages %ld virt %lx %s**\n",   \
-                       msg, index, uptodate, locked, page->flags, count,\
-                       page, page->mapping ? page->mapping->nrpages : -1,\
-                       page->virtual, buffer);                          \
-        } else                                                          \
-                CDEBUG(D_CACHE, "** %s: no page\n", msg);               \
-}
-
-#if 0
-#define iget(sb, ino) obd_iget(sb, ino)
-#define iput(sb, ino) obd_iput(sb, ino)
 
-static inline struct inode *obd_iget(struct super_block *sb, unsigned long ino)
-{
-        struct inode *inode;
-        
-        if ((inode = iget(sb, ino)) == NULL)
-                CDEBUG(D_INODE, "NULL in iget for %ld\n", ino);
-        else
-                obd_inodes++;
-        return inode;
-}
+#ifndef _LINUX_OBD_SUPPORT
+#define _LINUX_OBD_SUPPORT
 
-static inline void obd_iput(struct inode *inode)
-{
-        if (inode == NULL)
-                CDEBUG(D_INODE, "NULL in iput\n");
-        else
-                obd_inodes--;
-}
+#ifndef _OBD_SUPPORT
+#error Do not #include this file directly. #include <obd_support.h> instead
 #endif
 
-#else /* EXT2_OBD_DEBUG */
-
-#define CDEBUG(mask, format, a...) {}
-#define ENTRY {}
-#define EXIT {}
-#define ODEBUG(obdo) {}
-#define EXDEBUG(inode) {}
-#define OIDEBUG(inode) {}
-#define PDEBUG(page, cmd) {}
-
-#endif /* EXT2_OBD_DEBUG */
-
-#define OBD_ALLOC(ptr, size)                                    \
-do {                                                            \
-        (ptr) = kmalloc((unsigned long)(size), GFP_KERNEL);     \
-        obd_memory += (size);                                   \
-        CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n",   \
-               (long)(size), (int)(ptr), obd_memory);           \
-        if (ptr == NULL) {                                      \
-                CERROR("kernel malloc failed at %s:%d\n",       \
-                       __FILE__, __LINE__);                     \
-        } else {                                                \
-                memset((ptr), 0, (size));                       \
-        }                                                       \
-} while (0)
-
-#define OBD_FREE(ptr, size)                                  \
-do {                                                         \
-        kfree((ptr));                                        \
-        obd_memory -= (size);                                \
-        CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",    \
-               (int)(size), (int)(ptr), obd_memory);         \
-} while (0)
+#ifdef __KERNEL__
+#include <asm/cpufeature.h>
+#include <asm/processor.h>
+#include <linux/seq_file.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/highmem.h>
+#include <linux/swap.h>
+#endif
+#include <libcfs/libcfs.h>
+#include <linux/lustre_compat25.h>
+#include <lustre/lustre_idl.h>
+
+
+#ifdef __KERNEL__
+# include <linux/types.h>
+# include <linux/blkdev.h>
+# include <lvfs.h>
+#else /* !__KERNEL__ */
+# define LTIME_S(time) (time)
+/* for obd_class.h */
+# ifndef ERR_PTR
+#  define ERR_PTR(a) ((void *)(a))
+# endif
+#endif  /* __KERNEL__ */
 
 #endif