1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef _LINUX_OBD_SUPPORT
24 #define _LINUX_OBD_SUPPORT
27 #error Do not #include this file directly. #include <obd_support.h> instead
31 #ifndef AUTOCONF_INCLUDED
32 #include <linux/config.h>
34 #include <linux/autoconf.h>
35 #include <linux/slab.h>
36 #include <linux/highmem.h>
38 #include <libcfs/kp30.h>
39 #include <linux/lustre_compat25.h>
41 /* Prefer the kernel's version, if it exports it, because it might be
42 * optimized for this CPU. */
43 #if defined(__KERNEL__) && (defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE))
44 # include <linux/crc32.h>
46 /* crc32_le lifted from the Linux kernel, which had the following to say:
48 * This code is in the public domain; copyright abandoned.
49 * Liability for non-performance of this code is limited to the amount
50 * you paid for it. Since it is distributed for free, your refund will
51 * be very very small. If it breaks, you get to keep both pieces.
53 #define CRCPOLY_LE 0xedb88320
55 * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
56 * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
57 * other uses, or the previous crc32 value if computing incrementally.
58 * @p - pointer to buffer over which CRC is run
59 * @len - length of buffer @p
61 static inline __u32 crc32_le(__u32 crc, unsigned char const *p, size_t len)
66 for (i = 0; i < 8; i++)
67 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
74 # include <linux/types.h>
75 # include <linux/blkdev.h>
78 static inline void OBD_FAIL_WRITE(int id, struct super_block *sb)
80 if (OBD_FAIL_CHECK(id)) {
82 BDEVNAME_DECLARE_STORAGE(tmp);
83 CERROR("obd_fail_loc=%x, fail write operation on %s\n",
84 id, ll_bdevname(sb, tmp));
86 /* TODO-CMD: fix getting jdev */
87 __lvfs_set_rdonly(lvfs_sbdev(sb), (lvfs_sbdev_type)0);
88 /* We set FAIL_ONCE because we never "un-fail" a device */
89 obd_fail_loc |= OBD_FAILED | OBD_FAIL_ONCE;
93 #define OBD_SLEEP_ON(wq, state) wait_event_interruptible(wq, state)
96 #else /* !__KERNEL__ */
97 # define LTIME_S(time) (time)
100 # define ERR_PTR(a) ((void *)(a))
102 #endif /* __KERNEL__ */