#ifndef _LIBCFS_BITMAP_H_
#define _LIBCFS_BITMAP_H_
-#if !defined(__linux__) || !defined(__KERNEL__)
+#ifndef __KERNEL__
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, 8 * sizeof(long))
#define DECLARE_BITMAP(name, bits) \
unsigned long name[BITS_TO_LONGS(bits)]
-#endif
+#endif /* !__KERNEL__ */
typedef struct {
unsigned int size;
#ifndef LIBCFS_ERR_H_
#define LIBCFS_ERR_H_
-#if defined(__linux__) && defined(__KERNEL__)
+#ifdef __KERNEL__
# include <linux/err.h>
#else /* __KERNEL__ */
#ifndef __LIBCFS_LIBCFS_H__
#define __LIBCFS_LIBCFS_H__
-#if !__GNUC__
-#define __attribute__(x)
-#endif
-
#include <libcfs/types.h>
-#if !defined(__KERNEL__)
-#include <libcfs/posix/libcfs.h>
-#elif defined(__linux__)
-#include <libcfs/linux/libcfs.h>
-#else
-#error Unsupported operating system.
-#endif
+#ifdef __KERNEL__
+# include <libcfs/linux/libcfs.h>
+#else /* __KERNEL__ */
+# include <libcfs/posix/libcfs.h>
+#endif /* !__KERNEL__ */
#include "curproc.h"
#ifndef HAVE_LIBCFS_CPT
-#if !defined(__linux__) || !defined(__KERNEL__)
+#ifndef __KERNEL__
typedef struct nodemask { DECLARE_BITMAP(bits, 1); } nodemask_t;
typedef struct cpumask { DECLARE_BITMAP(bits, 1); } cpumask_t;
{
set_bit(node, dstp->bits);
}
-#endif
+#endif /* __KERNEL__ */
struct cfs_cpt_table {
/* # of CPU partitions */
goto label; \
} while (0)
-#if defined(__GNUC__)
long libcfs_log_return(struct libcfs_debug_msg_data *, long rc);
#if BITS_PER_LONG > 32
} while (0)
#endif /* BITS_PER_LONG > 32 */
-#else
-# error "Unkown compiler"
-#endif /* __GNUC__ */
#define ENTRY \
ENTRY_NESTING; \
* we'll need to move the functions to archi specific headers.
*/
-#if (defined __linux__ && defined __KERNEL__)
-#include <linux/hash.h>
-#else
+#ifdef __KERNEL__
+# include <linux/hash.h>
+#else /* __KERNEL__ */
/* Fast hashing routine for a long.
(C) 2002 William Lee Irwin III, IBM */
-#if BITS_PER_LONG == 32
+# if BITS_PER_LONG == 32
/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
-#define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_32
-#elif BITS_PER_LONG == 64
+# define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_32
+# elif BITS_PER_LONG == 64
/* 2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
-#define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_64
-#else
-#error Define CFS_GOLDEN_RATIO_PRIME for your wordsize.
-#endif
+# define CFS_GOLDEN_RATIO_PRIME CFS_GOLDEN_RATIO_PRIME_64
+# else
+# error Define CFS_GOLDEN_RATIO_PRIME for your wordsize.
+# endif /* BITS_PER_LONG == 64 */
static inline unsigned long hash_long(unsigned long val, unsigned int bits)
{
unsigned long hash = val;
-#if BITS_PER_LONG == 64
+# if BITS_PER_LONG == 64
/* Sigh, gcc can't optimise this alone like it does for 32 bits. */
unsigned long n = hash;
n <<= 18;
hash += n;
n <<= 2;
hash += n;
-#else
+# else /* BITS_PER_LONG == 64 */
/* On some cpus multiply is faster, on others gcc will do shifts */
hash *= CFS_GOLDEN_RATIO_PRIME;
-#endif
+# endif /* BITS_PER_LONG != 64 */
/* High bits are more random, so use them. */
return hash >> (BITS_PER_LONG - bits);
}
-#if 0
-static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
-{
- return hash_long((unsigned long)ptr, bits);
-}
-#endif
-
-/* !(__linux__ && __KERNEL__) */
-#endif
+#endif /* !__KERNEL__ */
/** disable debug */
#define CFS_HASH_DEBUG_NONE 0
* build go below this comment. Actual compiler/compiler version
* specific implementations come from the above header files
*/
-#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
-#else
-#define likely(x) (!!(x))
-#define unlikely(x) (!!(x))
-#endif
/* !__KERNEL__ */
#endif
#ifndef __LIBCFS_LIST_H__
#define __LIBCFS_LIST_H__
-#if defined (__linux__) && defined(__KERNEL__)
-
-#include <linux/list.h>
-
-#else /* !defined (__linux__) || !defined(__KERNEL__) */
+#ifdef __KERNEL__
+# include <linux/list.h>
+#else /* __KERNEL__ */
/*
* Simple doubly linked list implementation.
/* @} */
-#endif /* __linux__ && __KERNEL__ */
+#endif /* __KERNEL__ */
#ifndef list_for_each_prev
/**
#include <libcfs/user-tcpip.h>
#include <libcfs/user-bitops.h>
-# define do_gettimeofday(tv) gettimeofday(tv, NULL);
+#define do_gettimeofday(tv) gettimeofday(tv, NULL);
typedef unsigned long long cfs_cycles_t;
/* this goes in posix-fs.h */
#include <sys/mount.h>
-#ifdef __linux__
#include <mntent.h>
-#endif
#define fget(x) NULL
#define fput(f) do {} while (0)
-#ifdef __linux__
/* Userpace byte flipping */
-# include <endian.h>
-# include <byteswap.h>
-# define __swab16(x) bswap_16(x)
-# define __swab32(x) bswap_32(x)
-# define __swab64(x) bswap_64(x)
-# define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
-# define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
-# define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define le16_to_cpu(x) (x)
-# define cpu_to_le16(x) (x)
-# define le32_to_cpu(x) (x)
-# define cpu_to_le32(x) (x)
-# define le64_to_cpu(x) (x)
-# define cpu_to_le64(x) (x)
-
-# define be16_to_cpu(x) bswap_16(x)
-# define cpu_to_be16(x) bswap_16(x)
-# define be32_to_cpu(x) bswap_32(x)
-# define cpu_to_be32(x) bswap_32(x)
-# define be64_to_cpu(x) (__u64)bswap_64(x)
-# define cpu_to_be64(x) (__u64)bswap_64(x)
-# else
-# if __BYTE_ORDER == __BIG_ENDIAN
-# define le16_to_cpu(x) bswap_16(x)
-# define cpu_to_le16(x) bswap_16(x)
-# define le32_to_cpu(x) bswap_32(x)
-# define cpu_to_le32(x) bswap_32(x)
-# define le64_to_cpu(x) (__u64)bswap_64(x)
-# define cpu_to_le64(x) (__u64)bswap_64(x)
-
-# define be16_to_cpu(x) (x)
-# define cpu_to_be16(x) (x)
-# define be32_to_cpu(x) (x)
-# define cpu_to_be32(x) (x)
-# define be64_to_cpu(x) (x)
-# define cpu_to_be64(x) (x)
-
-# else
-# error "Unknown byte order"
-# endif /* __BIG_ENDIAN */
-# endif /* __LITTLE_ENDIAN */
-#endif
-
-# ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */
-# define THREAD_SIZE 8192
-# else
-# endif
+#include <endian.h>
+#include <byteswap.h>
+#define __swab16(x) bswap_16(x)
+#define __swab32(x) bswap_32(x)
+#define __swab64(x) bswap_64(x)
+#define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
+#define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
+#define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define le16_to_cpu(x) (x)
+# define cpu_to_le16(x) (x)
+# define le32_to_cpu(x) (x)
+# define cpu_to_le32(x) (x)
+# define le64_to_cpu(x) (x)
+# define cpu_to_le64(x) (x)
+
+# define be16_to_cpu(x) bswap_16(x)
+# define cpu_to_be16(x) bswap_16(x)
+# define be32_to_cpu(x) bswap_32(x)
+# define cpu_to_be32(x) bswap_32(x)
+# define be64_to_cpu(x) ((__u64)bswap_64(x))
+# define cpu_to_be64(x) ((__u64)bswap_64(x))
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define le16_to_cpu(x) bswap_16(x)
+# define cpu_to_le16(x) bswap_16(x)
+# define le32_to_cpu(x) bswap_32(x)
+# define cpu_to_le32(x) bswap_32(x)
+# define le64_to_cpu(x) ((__u64)bswap_64(x))
+# define cpu_to_le64(x) ((__u64)bswap_64(x))
+
+# define be16_to_cpu(x) (x)
+# define cpu_to_be16(x) (x)
+# define be32_to_cpu(x) (x)
+# define cpu_to_be32(x) (x)
+# define be64_to_cpu(x) (x)
+# define cpu_to_be64(x) (x)
+#else /* __BYTE_ORDER == __BIG_ENDIAN */
+# error "Unknown byte order"
+#endif /* __BYTE_ORDER != __BIG_ENDIAN */
+
+#ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */
+# define THREAD_SIZE 8192
+#endif /* THREAD_SIZE */
#define CFS_CHECK_STACK(msgdata, mask, cdls) do {} while(0)
#define CDEBUG_STACK() (0L)
#ifndef __LUSTRE_UTILS_PLATFORM_H
#define __LUSTRE_UTILS_PLATFORM_H
-#ifdef __linux__
#ifdef HAVE_LIBREADLINE
#define READLINE_LIBRARY
#define l_cond_wait(c, s) pthread_cond_wait(c, s)
#endif
-#else /* other platform */
-
-#ifdef HAVE_LIBREADLINE
-#define READLINE_LIBRARY
-#include <readline/readline.h>
-#endif /* HAVE_LIBREADLINE */
-#include <errno.h>
-#include <string.h>
-#if HAVE_LIBPTHREAD
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-
-typedef pthread_mutex_t l_mutex_t;
-typedef pthread_cond_t l_cond_t;
-#define l_mutex_init(s) pthread_mutex_init(s, NULL)
-#define l_mutex_lock(s) pthread_mutex_lock(s)
-#define l_mutex_unlock(s) pthread_mutex_unlock(s)
-#define l_cond_init(c) pthread_cond_init(c, NULL)
-#define l_cond_broadcast(c) pthread_cond_broadcast(c)
-#define l_cond_wait(c, s) pthread_cond_wait(c, s)
-#endif /* HAVE_LIBPTHREAD */
-
-#endif /* __linux__ */
#endif
#include <libcfs/libcfs.h>
#ifdef __KERNEL__
-#if defined(__linux__)
-#include "linux/linux-tracefile.h"
-#else
-#error Unsupported operating system.
-#endif
-#else
-#include "posix/posix-tracefile.h"
-#endif
+# include "linux/linux-tracefile.h"
+#else /* __KERNEL__ */
+# include "posix/posix-tracefile.h"
+#endif /* !__KERNEL__ */
/* trace file lock routines */
#define TRACEFILE_NAME_SIZE 1024
return;
}
-#ifdef __linux__
/*
* In glibc (NOT in Linux, so check above is not right), implement
return NULL;
}
-#else
-
-void cfs_stack_trace_fill(struct cfs_stack_trace *trace)
-{}
-void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no)
-{
- return NULL;
-}
-
-/* __linux__ */
-#endif
void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
{
#ifndef __LNET_API_SUPPORT_H__
#define __LNET_API_SUPPORT_H__
-#if defined(__linux__)
#include <lnet/linux/api-support.h>
-#else
-#error Unsupported Operating System
-#endif
#include <libcfs/libcfs.h>
#include <lnet/types.h>
#ifndef __LNET_LIB_LNET_H__
#define __LNET_LIB_LNET_H__
-#if defined(__linux__)
#include <lnet/linux/lib-lnet.h>
-#else
-#error Unsupported Operating System
-#endif
#include <libcfs/libcfs.h>
#include <lnet/types.h>
#ifndef __LNET_LIB_TYPES_H__
#define __LNET_LIB_TYPES_H__
-#if defined(__linux__)
#include <lnet/linux/lib-types.h>
-#else
-#error Unsupported Operating System
-#endif
#include <libcfs/libcfs.h>
#include <libcfs/list.h>
*
* User application interface file
*/
-#if defined(__linux__)
#include <lnet/linux/lnet.h>
-#else
-#error Unsupported Operating System
-#endif
#include <lnet/types.h>
#include <lnet/api.h>
#define DEBUG_PORTAL_ALLOC
#define DEBUG_SUBSYSTEM S_LND
-#if defined(__linux__)
#include "socklnd_lib-linux.h"
-#else
-#error Unsupported Operating System
-#endif
#include <libcfs/libcfs.h>
#include <lnet/lnet.h>
static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
-#ifdef __linux__
#define DAEMON_CTL_NAME "/proc/sys/lnet/daemon_file"
#define SUBSYS_DEBUG_CTL_NAME "/proc/sys/lnet/subsystem_debug"
return (rc == len ? 0 : 1);
}
-#else
-#error - Unknown sysctl convention.
-#endif
static int do_debug_mask(char *name, int enable)
{
#define DEBUG_SUBSYSTEM S_FLD
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-# include <linux/math64.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-# include <libcfs/list.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
+#include <linux/math64.h>
#include <obd_support.h>
#include <lustre_fld.h>
#include "fld_internal.h"
#define DEBUG_SUBSYSTEM S_FLD
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
#include <obd_support.h>
#include <dt_object.h>
#include <lustre_fid.h>
extern struct lu_fld_hash fld_hash[];
-#ifdef __KERNEL__
#ifdef LPROCFS
extern struct proc_dir_entry *fld_type_proc_dir;
int fld_client_rpc(struct obd_export *exp,
struct lu_seq_range *range, __u32 fld_op,
struct ptlrpc_request **reqp);
-#endif /* __KERNEL__ */
struct fld_cache *fld_cache_init(const char *name,
int cache_size, int cache_threshold);
#define DEBUG_SUBSYSTEM S_FLD
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-# include <linux/math64.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-# include <libcfs/list.h>
-#endif
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
+#include <linux/math64.h>
#include <obd.h>
#include <obd_class.h>
}
EXIT;
}
-#else
+#else /* LPROCFS */
static int fld_client_proc_init(struct lu_client_fld *fld)
{
return 0;
{
return;
}
-#endif
+#endif /* !LPROCFS */
EXPORT_SYMBOL(fld_client_proc_fini);
res.lsr_start = seq;
fld_range_set_type(&res, flags);
-#if defined(__KERNEL__) && defined(HAVE_SERVER_SUPPORT)
+#ifdef HAVE_SERVER_SUPPORT
if (target->ft_srv != NULL) {
LASSERT(env != NULL);
rc = fld_server_lookup(env, target->ft_srv, seq, &res);
} else
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
{
rc = fld_client_rpc(target->ft_exp, &res, FLD_QUERY, NULL);
}
}
EXPORT_SYMBOL(fld_client_flush);
-#ifdef __KERNEL__
struct proc_dir_entry *fld_type_proc_dir;
#ifdef HAVE_SERVER_SUPPORT
fld_server_mod_init();
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
return 0;
}
{
#ifdef HAVE_SERVER_SUPPORT
fld_server_mod_exit();
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) {
lprocfs_remove(&fld_type_proc_dir);
MODULE_LICENSE("GPL");
cfs_module(mdd, LUSTRE_VERSION_STRING, fld_mod_init, fld_mod_exit);
-#endif /* __KERNEL__ */
#define DEBUG_SUBSYSTEM S_FLD
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/module.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/module.h>
#include <dt_object.h>
#include <obd_support.h>
#include <lustre_fld.h>
*/
#include <libcfs/libcfs.h>
#include <lu_object.h>
-
-#ifdef __KERNEL__
-# include <linux/mutex.h>
-# include <linux/radix-tree.h>
-#else
-# include <liblustre.h>
-#endif
+#include <linux/mutex.h>
+#include <linux/radix-tree.h>
struct inode;
#error Do not #include this file directly. #include <lprocfs_status.h> instead
#endif
-#ifdef __KERNEL__
#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) \
CDEBUG(mask, "page %p map %p index %lu flags %lx count %u priv %0lx: "\
fmt, page, page->mapping, page->index, (long)page->flags, \
page_count(page), page_private(page), ## arg)
-#else
-#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) \
- CDEBUG(mask, "page %p index %lu priv %0lx: "\
- fmt, page, page->index, page_private(page), ## arg)
-#endif
#endif
#error Do not #include this file directly. #include <lprocfs_status.h> instead
#endif
-#ifdef __KERNEL__
-# include <linux/proc_fs.h>
-# include <asm/processor.h>
-# include <linux/bit_spinlock.h>
-#endif
+#include <linux/proc_fs.h>
+#include <asm/processor.h>
+#include <linux/bit_spinlock.h>
#endif
#error Do not #include this file directly. #include <lustre_handles.h> instead
#endif
-#ifdef __KERNEL__
#include <asm/types.h>
#include <asm/atomic.h>
#include <linux/list.h>
#include <linux/rcupdate.h> /* for rcu_head{} */
typedef struct rcu_head cfs_rcu_head_t;
-#endif /* ifdef __KERNEL__ */
#endif
#error Do not #include this file directly. #include <lustre_lib.h> instead
#endif
-#ifndef __KERNEL__
-# include <string.h>
-# include <sys/types.h>
-#else
-# include <linux/rwsem.h>
-# include <linux/sched.h>
-# include <linux/signal.h>
-# include <linux/types.h>
-# include <linux/lustre_compat25.h>
-# include <linux/lustre_common.h>
-#endif
+#include <linux/rwsem.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
+#include <linux/types.h>
+#include <linux/lustre_compat25.h>
+#include <linux/lustre_common.h>
#ifndef LP_POISON
#if BITS_PER_LONG > 32
sigmask(SIGTERM) | sigmask(SIGQUIT) | \
sigmask(SIGALRM))
-#ifdef __KERNEL__
/* initialize ost_lvb according to inode */
static inline void inode_init_lvb(struct inode *inode, struct ost_lvb *lvb)
{
lvb->lvb_atime = LTIME_S(inode->i_atime);
lvb->lvb_ctime = LTIME_S(inode->i_ctime);
}
-#else
-/* defined in liblustre/llite_lib.h */
-#endif
#endif /* _LUSTRE_LIB_H */
#error Do not #include this file directly. #include <lustre_lite.h> instead
#endif
-#ifdef __KERNEL__
-
#include <linux/version.h>
-
#include <asm/statfs.h>
-
#include <linux/fs.h>
#include <linux/dcache.h>
#include <linux/proc_fs.h>
-
#include <obd_class.h>
#include <lustre_net.h>
#include <lustre_ha.h>
-
#include <linux/rbtree.h>
#include <linux/lustre_compat25.h>
#include <linux/lustre_common.h>
LPROC_LL_FILE_OPCODES
};
-#else
-#include <lustre/lustre_idl.h>
-#endif /* __KERNEL__ */
-
#endif
#error Do not #include this file directly. #include <lustre_net.h> instead
#endif
-#ifdef __KERNEL__
#include <linux/version.h>
#include <linux/workqueue.h>
-#endif
-
-/* XXX Liang: should be moved to other header instead of here */
-#ifndef WITH_GROUP_INFO
-#define WITH_GROUP_INFO
-#endif
#endif
#error Do not #include this file directly. #include <lustre_quota.h> instead
#endif
-#ifdef __KERNEL__
#include <linux/version.h>
#include <linux/fs.h>
#include <linux/quota.h>
#include <linux/quotaops.h>
-#endif
#endif /* _LUSTRE_QUOTA_H */
#error Do not #include this file directly. #include <lvfs.h> instead
#endif
-#if defined __KERNEL__
#include <linux/lustre_compat25.h>
#include <linux/lustre_common.h>
#include <linux/fs.h>
-#else
-#include <liblustre.h>
-#endif
#define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
#define OBD_CTXT_DEBUG /* development-only debugging */
#define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
#endif
-#ifdef __KERNEL__
/* We need to hold the inode semaphore over the dcache lookup itself, or we
* run the risk of entering the filesystem lookup path concurrently on SMP
return dchild;
}
-#endif
#endif
#include <obd_support.h>
-#ifdef __KERNEL__
-# include <linux/fs.h>
-# include <linux/list.h>
-# include <linux/sched.h> /* for struct task_struct, for current.h */
-# include <linux/proc_fs.h>
-# include <linux/mount.h>
-# include <linux/lustre_intent.h>
-#endif
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/sched.h> /* for struct task_struct, for current.h */
+#include <linux/proc_fs.h>
+#include <linux/mount.h>
+#include <linux/lustre_intent.h>
struct ll_iattr {
struct iattr iattr;
unsigned int ia_attr_flags;
};
-#ifdef __KERNEL__
#define CLIENT_OBD_LIST_LOCK_DEBUG 1
-#endif
typedef struct {
spinlock_t lock;
spin_unlock(&lock->lock);
}
-#else /* ifdef CLIENT_OBD_LIST_LOCK_DEBUG */
+#else /* CLIENT_OBD_LIST_LOCK_DEBUG */
static inline void client_obd_list_lock(client_obd_lock_t *lock)
{
spin_lock(&lock->lock);
spin_unlock(&lock->lock);
}
-#endif /* ifdef CLIENT_OBD_LIST_LOCK_DEBUG */
+#endif /* !CLIENT_OBD_LIST_LOCK_DEBUG */
static inline void client_obd_list_lock_init(client_obd_lock_t *lock)
{
static inline void client_obd_list_lock_done(client_obd_lock_t *lock)
{}
-#if defined(__KERNEL__) && !defined(HAVE_ADLER)
+#ifndef HAVE_ADLER
/* zlib_adler() is an inline function defined in zutil.h */
-#define HAVE_ADLER
-#endif
+# define HAVE_ADLER
+#endif /* !HAVE_ADLER */
#endif /* __LINUX_OBD_H */
#error Do not #include this file directly. #include <obd_class.h> instead
#endif
-#ifndef __KERNEL__
-#include <sys/types.h>
-#include <libcfs/list.h>
-#else
#include <asm/uaccess.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/timer.h>
-#endif
/* obdo.c */
-#ifdef __KERNEL__
void obdo_from_la(struct obdo *dst, const struct lu_attr *la, __u64 valid);
void la_from_obdo(struct lu_attr *la, const struct obdo *dst, obd_flag valid);
void obdo_refresh_inode(struct inode *dst, const struct obdo *src,
obd_flag valid);
#define ll_inode_flags(inode) (inode->i_flags)
-#endif
-
#endif /* __LINUX_OBD_CLASS_H */
#ifndef _LPROCFS_SNMP_H
#define _LPROCFS_SNMP_H
-#if defined(__linux__)
#include <linux/lprocfs_status.h>
-#else
-#error Unsupported operating system.
-#endif
#include <lustre/lustre_idl.h>
#include <libcfs/params_tree.h>
#define lc_sum_irq lc_array_sum[1]
struct lprocfs_percpu {
-#ifndef __GNUC__
- __s64 pad;
-#endif
struct lprocfs_counter lp_cntr[0];
};
# include <stdio.h> /* snprintf() */
#endif
#include <lustre/ll_fiemap.h>
-#if defined(__linux__)
#include <linux/lustre_user.h>
-#else
-#error Unsupported operating system.
-#endif
#define LUSTRE_EOF 0xffffffffffffffffULL
#ifndef _LUSTRE_ACL_H
#define _LUSTRE_ACL_H
-#if defined(__linux__)
#include <linux/lustre_acl.h>
-#endif
#endif
/*
* capability
*/
-#ifdef __KERNEL__
#include <linux/crypto.h>
-#endif
#include <lustre/lustre_idl.h>
#define CAPA_TIMEOUT 1800 /* sec, == 30 min */
void capa_cpy(void *dst, struct obd_capa *ocapa);
static inline struct obd_capa *alloc_capa(int site)
{
-#ifdef __KERNEL__
struct obd_capa *ocapa;
if (unlikely(site != CAPA_SITE_CLIENT && site != CAPA_SITE_SERVER))
INIT_HLIST_NODE(&ocapa->u.tgt.c_hash);
return ocapa;
-#else
- return ERR_PTR(-EOPNOTSUPP);
-#endif
}
static inline struct obd_capa *capa_get(struct obd_capa *ocapa)
#include <lustre_net.h>
#include <obd.h>
-#if defined(__linux__)
#include <linux/lustre_debug.h>
-#else
-#error Unsupported operating system.
-#endif
#define ASSERT_MAX_SIZE_MB 60000ULL
#define ASSERT_PAGE_INDEX(index, OP) \
#ifndef _LUSTRE_DLM_H__
#define _LUSTRE_DLM_H__
-#if defined(__linux__)
#include <linux/lustre_dlm.h>
-#else
-#error Unsupported operating system.
-#endif
#include <lustre_lib.h>
#include <lustre_net.h>
* @{
*/
-#if defined(__linux__)
#include <linux/lustre_handles.h>
-#else
-#error Unsupported operating system.
-#endif
#include <libcfs/libcfs.h>
-#ifndef __KERNEL__
-typedef struct {
- int foo;
-} cfs_rcu_head_t;
-#endif
struct portals_handle_ops {
void (*hop_addref)(void *object);
#include <lustre/lustre_idl.h>
#include <lustre_ver.h>
#include <lustre_cfg.h>
-#if defined(__linux__)
#include <linux/lustre_lib.h>
-#else
-#error Unsupported operating system.
-#endif
/* target.c */
struct ptlrpc_request;
#define LWI_INTR(cb, data) LWI_TIMEOUT_INTR(0, NULL, cb, data)
-#ifdef __KERNEL__
/*
* wait for @condition to become true, but no longer than timeout, specified
remove_wait_queue(&wq, &__wait); \
} while (0)
-#else /* !__KERNEL__ */
-
-#define __l_wait_event(wq, condition, info, ret, l_add_wait) \
-do { \
- long __timeout = info->lwi_timeout; \
- long __now; \
- long __then = 0; \
- int __timed_out = 0; \
- int __interval = obd_timeout; \
- \
- ret = 0; \
- if (condition) \
- break; \
- \
- if (__timeout != 0) \
- __then = time(NULL); \
- \
- if (__timeout && __timeout < __interval) \
- __interval = __timeout; \
- if (info->lwi_interval && info->lwi_interval < __interval) \
- __interval = info->lwi_interval; \
- \
- while (!(condition)) { \
- liblustre_wait_event(__interval); \
- if (condition) \
- break; \
- \
- if (!__timed_out && info->lwi_timeout != 0) { \
- __now = time(NULL); \
- __timeout -= __now - __then; \
- __then = __now; \
- \
- if (__timeout > 0) \
- continue; \
- \
- __timeout = 0; \
- __timed_out = 1; \
- if (info->lwi_on_timeout == NULL || \
- info->lwi_on_timeout(info->lwi_cb_data)) { \
- ret = -ETIMEDOUT; \
- break; \
- } \
- } \
- } \
-} while (0)
-
-#endif /* __KERNEL__ */
#define l_wait_event(wq, condition, info) \
l_wait_event_exclusive_head(wq, condition, &lwi); \
})
-#ifdef __KERNEL__
-#define LIBLUSTRE_CLIENT (0)
-#else
-#define LIBLUSTRE_CLIENT (1)
-#endif
-
/** @} lib */
#endif /* _LUSTRE_LIB_H */
* @{
*/
-#if defined(__linux__)
#include <linux/lustre_lite.h>
-#else
-#error Unsupported operating system.
-#endif
#include <obd_class.h>
#include <lustre_net.h>
if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
params->lrp_policy.l_extent.start = 0;
params->lrp_policy.l_extent.end = OBD_OBJECT_EOF;
- } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
- /*
- * liblustre: OST-side locking for all non-O_APPEND
- * reads/writes.
- */
- params->lrp_lock_mode = LCK_NL;
- params->lrp_brw_flags = OBD_BRW_SRVLOCK;
} else {
/*
* nothing special for the kernel. In the future llite may use
* @{
*/
-#if defined(__linux__)
#include <linux/lustre_log.h>
-#else
-#error Unsupported operating system.
-#endif
#include <obd_class.h>
#include <lustre/lustre_idl.h>
* @{
*/
-#ifdef __KERNEL__
-# include <linux/fs.h>
-# include <linux/dcache.h>
-# ifdef CONFIG_FS_POSIX_ACL
-# include <linux/posix_acl_xattr.h>
-# endif /* CONFIG_FS_POSIX_ACL */
-# include <linux/lustre_intent.h>
-#endif /* __KERNEL__ */
+#include <linux/fs.h>
+#include <linux/dcache.h>
+#ifdef CONFIG_FS_POSIX_ACL
+# include <linux/posix_acl_xattr.h>
+#endif /* CONFIG_FS_POSIX_ACL */
+#include <linux/lustre_intent.h>
#include <lustre_handles.h>
#include <libcfs/libcfs.h>
#include <obd_class.h>
* @{
*/
-#if defined(__linux__)
#include <linux/lustre_net.h>
-#else
-#error Unsupported operating system.
-#endif
-
#include <libcfs/libcfs.h>
-// #include <obd.h>
#include <lnet/lnet.h>
#include <lustre/lustre_idl.h>
#include <lustre_ha.h>
#include <lprocfs_status.h>
#include <lu_object.h>
#include <lustre_req_layout.h>
-
#include <obd_support.h>
#include <lustre_ver.h>
#define OFD_MAX_BRW_SIZE (1 << LNET_MTU_BITS)
/* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */
-#ifdef __KERNEL__
-# if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
-# error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
-# endif
-# if (PTLRPC_MAX_BRW_SIZE != (PTLRPC_MAX_BRW_PAGES * PAGE_CACHE_SIZE))
-# error "PTLRPC_MAX_BRW_SIZE isn't PTLRPC_MAX_BRW_PAGES * PAGE_CACHE_SIZE"
-# endif
-# if (PTLRPC_MAX_BRW_SIZE > LNET_MTU * PTLRPC_BULK_OPS_COUNT)
-# error "PTLRPC_MAX_BRW_SIZE too big"
-# endif
-# if (PTLRPC_MAX_BRW_PAGES > LNET_MAX_IOV * PTLRPC_BULK_OPS_COUNT)
-# error "PTLRPC_MAX_BRW_PAGES too big"
-# endif
-#endif /* __KERNEL__ */
+#if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
+# error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
+#endif
+#if (PTLRPC_MAX_BRW_SIZE != (PTLRPC_MAX_BRW_PAGES * PAGE_CACHE_SIZE))
+# error "PTLRPC_MAX_BRW_SIZE isn't PTLRPC_MAX_BRW_PAGES * PAGE_CACHE_SIZE"
+#endif
+#if (PTLRPC_MAX_BRW_SIZE > LNET_MTU * PTLRPC_BULK_OPS_COUNT)
+# error "PTLRPC_MAX_BRW_SIZE too big"
+#endif
+#if (PTLRPC_MAX_BRW_PAGES > LNET_MAX_IOV * PTLRPC_BULK_OPS_COUNT)
+# error "PTLRPC_MAX_BRW_PAGES too big"
+#endif
#define PTLRPC_NTHRS_INIT 2
/** array of associated MDs */
lnet_handle_md_t bd_mds[PTLRPC_BULK_OPS_COUNT];
-#if defined(__KERNEL__)
/*
* encrypt iov, size is either 0 or bd_iov_count.
*/
lnet_kiov_t *bd_enc_iov;
lnet_kiov_t bd_iov[0];
-#else
- lnet_md_iovec_t bd_iov[0];
-#endif
};
enum {
spinlock_t scp_rep_lock __cfs_cacheline_aligned;
/** all the active replies */
struct list_head scp_rep_active;
-#ifndef __KERNEL__
- /** replies waiting for service */
- struct list_head scp_rep_queue;
-#endif
/** List of free reply_states */
struct list_head scp_rep_idle;
/** waitq to run, when adding stuff to srv_free_rs_list */
* Record the partner index to be processed next.
*/
int pc_cursor;
-#ifndef __KERNEL__
- /**
- * Async rpcs flag to make sure that ptlrpcd_check() is called only
- * once.
- */
- int pc_recurred;
- /**
- * Currently not used.
- */
- void *pc_callback;
- /**
- * User-space async rpcs callback.
- */
- void *pc_wait_callback;
- /**
- * User-space check idle rpcs callback.
- */
- void *pc_idle_callback;
-#endif
};
/* Bits for pc_flags */
struct obd_export *export);
void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay);
-#ifdef __KERNEL__
int ptlrpc_hr_init(void);
void ptlrpc_hr_fini(void);
-#else
-# define ptlrpc_hr_init() (0)
-# define ptlrpc_hr_fini() do {} while(0)
-#endif
/** @} */
enum timeout_event event);
struct ptlrpc_request * ptlrpc_prep_ping(struct obd_import *imp);
int ptlrpc_obd_ping(struct obd_device *obd);
-#ifdef __KERNEL__
void ping_evictor_start(void);
void ping_evictor_stop(void);
-#else
-#define ping_evictor_start() do {} while (0)
-#define ping_evictor_stop() do {} while (0)
-#endif
void ptlrpc_pinger_ir_up(void);
void ptlrpc_pinger_ir_down(void);
/** @} */
/**
* Timer for next token.
*/
-#if defined(__KERNEL__) && defined(__linux__)
struct hrtimer th_timer;
-#endif
/**
* Deadline of the timer.
*/
*
*/
-#if defined(__linux__)
#include <linux/lustre_quota.h>
-#endif
#include <dt_object.h>
#include <lustre_fid.h>
#include <libcfs/libcfs.h>
-#if defined(__linux__)
#include <linux/lvfs.h>
-#else
-#error Unsupported operating system.
-#endif
/* ptlrpc_sec_ctx.c */
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx);
#ifndef __OBD_H
#define __OBD_H
-#ifndef __KERNEL__
-# error "userspace should not include <obd.h>"
-#endif
-#if defined(__linux__)
#include <linux/obd.h>
-#else
-#error Unsupported operating system.
-#endif
#include <lustre/lustre_idl.h>
#include <lustre_lib.h>
#ifndef _OBD_CACHE_H__
#define _OBD_CACHE_H__
-#ifdef __KERNEL__
#endif
-#endif
#ifndef __CLASS_OBD_H
#define __CLASS_OBD_H
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <lustre_import.h>
#include <lustre/lustre_idl.h>
#include <lprocfs_status.h>
-#if defined(__linux__)
#include <linux/obd_class.h>
-#else
-#error Unsupported operating system.
-#endif
#define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay
* and resends for avoid deadlocks */
struct rw_semaphore rsi_sem;
};
-#ifdef __KERNEL__
int server_name2index(const char *svname, __u32 *idx, const char **endptr);
-#else
-# define server_name2index(name, idx, ptr) do {} while (0)
-#endif
#endif /* __LINUX_OBD_CLASS_H */
#include <libcfs/libcfs.h>
#include <lprocfs_status.h>
-#if defined(__linux__)
#include <linux/obd_support.h>
-#else
-#error Unsupported operating system.
-#endif
/* global variables */
extern struct lprocfs_stats *obd_memory;
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
#include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
#include <lustre_dlm.h>
#include <lustre_lib.h>
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#ifndef __KERNEL__
-# include <liblustre.h>
-#else
-# include <libcfs/libcfs.h>
-#endif
+#include <libcfs/libcfs.h>
#include <lustre_dlm.h>
#include <obd_support.h>
#include <obd.h>
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
#include <lustre_dlm.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_lib.h>
#include <libcfs/list.h>
-#else
-#include <liblustre.h>
-#include <obd_class.h>
-#endif
#include "ldlm_internal.h"
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <lustre_dlm.h>
#include <obd_support.h>
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
+#include <libcfs/libcfs.h>
#include <obd.h>
#include <obd_class.h>
#include <lustre_dlm.h>
}
EXPORT_SYMBOL(target_client_add_cb);
-#ifdef __KERNEL__
static void
check_and_start_recovery_timer(struct obd_device *obd,
struct ptlrpc_request *req, int new_client);
-#else
-static inline void
-check_and_start_recovery_timer(struct obd_device *obd,
- struct ptlrpc_request *req, int new_client)
-{
-}
-#endif
int target_handle_connect(struct ptlrpc_request *req)
{
spin_unlock(&req->rq_export->exp_lock);
}
-#ifdef __KERNEL__
static void target_finish_recovery(struct obd_device *obd)
{
ENTRY;
}
EXPORT_SYMBOL(target_recovery_init);
-#endif /* __KERNEL__ */
static int target_process_req_flags(struct obd_device *obd,
struct ptlrpc_request *req)
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-# include <linux/lustre_intent.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/lustre_intent.h>
#include <obd_class.h>
#include "ldlm_internal.h"
static ldlm_processing_policy ldlm_processing_policy_table[] = {
[LDLM_PLAIN] = ldlm_process_plain_lock,
[LDLM_EXTENT] = ldlm_process_extent_lock,
-# ifdef __KERNEL__
[LDLM_FLOCK] = ldlm_process_flock_lock,
-# endif
[LDLM_IBITS] = ldlm_process_inodebits_lock,
};
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <lustre_dlm.h>
#include <obd_class.h>
#include <libcfs/list.h>
int blwi_mem_pressure;
};
-#if defined(HAVE_SERVER_SUPPORT) && defined(__KERNEL__)
+#ifdef HAVE_SERVER_SUPPORT
/**
* Protects both waiting_locks_list and expired_lock_thread.
}
EXPORT_SYMBOL(ldlm_refresh_waiting_lock);
-#else /* !HAVE_SERVER_SUPPORT || !__KERNEL__ */
+#else /* HAVE_SERVER_SUPPORT */
int ldlm_del_waiting_lock(struct ldlm_lock *lock)
{
RETURN(0);
}
-# ifdef HAVE_SERVER_SUPPORT
-static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
-{
- LASSERT(ldlm_is_res_locked(lock) && !ldlm_is_cancel_on_block(lock));
- RETURN(1);
-}
-
-# endif
-#endif /* HAVE_SERVER_SUPPORT && __KERNEL__ */
+#endif /* !HAVE_SERVER_SUPPORT */
#ifdef HAVE_SERVER_SUPPORT
if (obd_dump_on_timeout)
libcfs_debug_dumplog();
-#ifdef __KERNEL__
spin_lock_bh(&waiting_locks_spinlock);
if (__ldlm_del_waiting_lock(lock) == 0)
/* the lock was not in any list, grab an extra ref before adding
&expired_lock_thread.elt_expired_locks);
wake_up(&expired_lock_thread.elt_waitq);
spin_unlock_bh(&waiting_locks_spinlock);
-#else
- class_fail_export(lock->l_export);
-#endif
}
/**
return ptlrpc_reply(req);
}
-#ifdef __KERNEL__
static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi,
ldlm_cancel_flags_t cancel_flags)
{
}
}
-#endif
int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct ldlm_lock *lock)
{
-#ifdef __KERNEL__
return ldlm_bl_to_thread(ns, ld, lock, NULL, 0, LCF_ASYNC);
-#else
- return -ENOSYS;
-#endif
}
int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct list_head *cancels, int count,
ldlm_cancel_flags_t cancel_flags)
{
-#ifdef __KERNEL__
return ldlm_bl_to_thread(ns, ld, NULL, cancels, count, cancel_flags);
-#else
- return -ENOSYS;
-#endif
}
/* Setinfo coming from Server (eg MDT) to Client (eg MDC)! */
EXPORT_SYMBOL(ldlm_revoke_export_locks);
#endif /* HAVE_SERVER_SUPPORT */
-#ifdef __KERNEL__
static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
{
struct ldlm_bl_work_item *blwi = NULL;
RETURN(0);
}
-#endif
static int ldlm_setup(void);
static int ldlm_cleanup(void);
{
static struct ptlrpc_service_conf conf;
struct ldlm_bl_pool *blp = NULL;
-#ifdef __KERNEL__
-# ifdef HAVE_SERVER_SUPPORT
+#ifdef HAVE_SERVER_SUPPORT
struct task_struct *task;
-# endif
+#endif /* HAVE_SERVER_SUPPORT */
int i;
-#endif
int rc = 0;
ENTRY;
rc = ldlm_proc_setup();
if (rc != 0)
GOTO(out, rc);
-#endif
+#endif /* LPROCFS */
memset(&conf, 0, sizeof(conf));
conf = (typeof(conf)) {
ldlm_state->ldlm_cancel_service = NULL;
GOTO(out, rc);
}
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
OBD_ALLOC(blp, sizeof(*blp));
if (blp == NULL)
atomic_set(&blp->blp_num_threads, 0);
atomic_set(&blp->blp_busy_threads, 0);
-#ifdef __KERNEL__
if (ldlm_num_threads == 0) {
blp->blp_min_threads = LDLM_NTHRS_INIT;
blp->blp_max_threads = LDLM_NTHRS_MAX;
GOTO(out, rc);
}
-# ifdef HAVE_SERVER_SUPPORT
+#ifdef HAVE_SERVER_SUPPORT
INIT_LIST_HEAD(&expired_lock_thread.elt_expired_locks);
expired_lock_thread.elt_state = ELT_STOPPED;
init_waitqueue_head(&expired_lock_thread.elt_waitq);
wait_event(expired_lock_thread.elt_waitq,
expired_lock_thread.elt_state == ELT_READY);
-# endif /* HAVE_SERVER_SUPPORT */
+#endif /* HAVE_SERVER_SUPPORT */
rc = ldlm_pools_init();
if (rc) {
CERROR("Failed to initialize LDLM pools: %d\n", rc);
GOTO(out, rc);
}
-#endif
RETURN(0);
out:
RETURN(-EBUSY);
}
-#ifdef __KERNEL__
ldlm_pools_fini();
if (ldlm_state->ldlm_bl_pool != NULL) {
OBD_FREE(blp, sizeof(*blp));
}
-#endif /* __KERNEL__ */
if (ldlm_state->ldlm_cb_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
-# ifdef HAVE_SERVER_SUPPORT
+#ifdef HAVE_SERVER_SUPPORT
if (ldlm_state->ldlm_cancel_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
-# endif
+#endif
-#ifdef __KERNEL__
ldlm_proc_cleanup();
-# ifdef HAVE_SERVER_SUPPORT
+#ifdef HAVE_SERVER_SUPPORT
if (expired_lock_thread.elt_state != ELT_STOPPED) {
expired_lock_thread.elt_state = ELT_TERMINATE;
wake_up(&expired_lock_thread.elt_waitq);
wait_event(expired_lock_thread.elt_waitq,
expired_lock_thread.elt_state == ELT_STOPPED);
}
-# endif
-#endif /* __KERNEL__ */
+#endif
OBD_FREE(ldlm_state, sizeof(*ldlm_state));
ldlm_state = NULL;
if (ldlm_refcount)
CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount);
kmem_cache_destroy(ldlm_resource_slab);
-#ifdef __KERNEL__
/* ldlm_lock_put() use RCU to call ldlm_lock_free, so need call
* synchronize_rcu() to wait a grace period elapsed, so that
* ldlm_lock_free() get a chance to be called. */
synchronize_rcu();
-#endif
kmem_cache_destroy(ldlm_lock_slab);
kmem_cache_destroy(ldlm_interval_slab);
}
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
#include <lustre_dlm.h>
#include <obd_support.h>
#include <lustre_lib.h>
-#else
-#include <liblustre.h>
-#endif
#include "ldlm_internal.h"
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
-# include <lustre_dlm.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <lustre_dlm.h>
#include <cl_object.h>
-
#include <obd_class.h>
#include <obd_support.h>
#include "ldlm_internal.h"
*/
#define LDLM_POOL_SLV_SHIFT (10)
-#ifdef __KERNEL__
extern struct proc_dir_entry *ldlm_ns_proc_dir;
-#endif
static inline __u64 dru(__u64 val, __u32 shift, int round_up)
{
unused = ns->ns_nr_unused;
spin_unlock(&ns->ns_lock);
-#ifdef __KERNEL__
if (nr == 0)
return (unused / 100) * sysctl_vfs_cache_pressure;
else
return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK);
-#else
- return unused - (nr ? ldlm_cancel_lru(ns, nr, LCF_ASYNC,
- LDLM_CANCEL_SHRINK) : 0);
-#endif
}
struct ldlm_pool_ops ldlm_srv_pool_ops = {
}
EXPORT_SYMBOL(ldlm_pool_setup);
-#ifdef __KERNEL__
static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
{
int granted, grant_rate, cancel_rate, grant_step;
pl->pl_proc_dir = NULL;
}
}
-#else /* !__KERNEL__*/
-#define ldlm_pool_proc_init(pl) (0)
-#define ldlm_pool_proc_fini(pl) while (0) {}
-#endif
int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
int idx, ldlm_side_t client)
}
EXPORT_SYMBOL(ldlm_pool_get_lvf);
-#ifdef __KERNEL__
static unsigned int ldlm_pool_granted(struct ldlm_pool *pl)
{
return atomic_read(&pl->pl_granted);
ldlm_pools_thread_stop();
}
EXPORT_SYMBOL(ldlm_pools_fini);
-#endif /* __KERNEL__ */
#else /* !HAVE_LRU_RESIZE_SUPPORT */
int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#ifndef __KERNEL__
-#include <signal.h>
-#include <liblustre.h>
-#endif
#include <lustre_dlm.h>
#include <obd_class.h>
LDLM_DEBUG(lock,"client-side enqueue, new policy data");
}
- if ((*flags) & LDLM_FL_AST_SENT ||
- /* Cancel extent locks as soon as possible on a liblustre client,
- * because it cannot handle asynchronous ASTs robustly (see
- * bug 7311). */
- (LIBLUSTRE_CLIENT && type == LDLM_EXTENT)) {
+ if ((*flags) & LDLM_FL_AST_SENT) {
lock_res_and_lock(lock);
lock->l_flags |= LDLM_FL_CBPENDING | LDLM_FL_BL_AST;
unlock_res_and_lock(lock);
ptlrpc_request_set_replen(req);
}
- /*
- * Liblustre client doesn't get extent locks, except for O_APPEND case
- * where [0, OBD_OBJECT_EOF] lock is taken, or truncate, where
- * [i_size, OBD_OBJECT_EOF] lock is taken.
- */
- LASSERT(ergo(LIBLUSTRE_CLIENT, einfo->ei_type != LDLM_EXTENT ||
- policy->l_extent.end == OBD_OBJECT_EOF));
-
if (async) {
LASSERT(reqp != NULL);
RETURN(0);
int count, rc;
ENTRY;
-#ifndef __KERNEL__
- cancel_flags &= ~LCF_ASYNC; /* force to be sync in user space */
-#endif
/* Just prepare the list of locks, do not actually cancel them yet.
* Locks are cancelled later in a separate thread. */
count = ldlm_prepare_lru_list(ns, &cancels, nr, 0, flags);
*/
#define DEBUG_SUBSYSTEM S_LDLM
-#ifdef __KERNEL__
-# include <lustre_dlm.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <lustre_dlm.h>
#include <lustre_fid.h>
#include <obd_class.h>
#include "ldlm_internal.h"
static inline unsigned long hash_x_index(__u64 hash, int hash64)
{
-#ifdef __KERNEL__
if (BITS_PER_LONG == 32 && hash64)
hash >>= 32;
-#endif
/* save hash 0 with hash 1 */
return ~0UL - (hash + !hash);
}
*/
#define DEBUG_SUBSYSTEM S_MDC
-#ifndef __KERNEL__
-# include <fcntl.h>
-# include <liblustre.h>
-#endif
#include <lustre_net.h>
#include <lustre/lustre_idl.h>
#include <obd_class.h>
#include <lclient.h>
#include "mdc_internal.h"
-#ifndef __KERNEL__
-/* some liblustre hackings here */
-#ifndef O_DIRECTORY
-#define O_DIRECTORY 0
-#endif
-#endif
static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
{
if (op_data->op_bias & MDS_CREATE_VOLATILE)
cr_flags |= MDS_OPEN_VOLATILE;
}
-#ifndef __KERNEL__
- /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
- rec->cr_fid2 = op_data->op_fid2;
-#endif
}
if (lmm) {
#define DEBUG_SUBSYSTEM S_MDC
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/lustre_intent.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <linux/module.h>
+#include <linux/lustre_intent.h>
#include <obd.h>
#include <obd_class.h>
#include <lustre_dlm.h>
LASSERT(lock != NULL);
lock_res_and_lock(lock);
-#ifdef __KERNEL__
if (lock->l_resource->lr_lvb_inode &&
lock->l_resource->lr_lvb_inode != data) {
struct inode *old_inode = lock->l_resource->lr_lvb_inode;
old_inode->i_state,
new_inode, new_inode->i_ino, new_inode->i_generation);
}
-#endif
lock->l_resource->lr_lvb_inode = new_inode;
if (bits)
*bits = lock->l_policy_data.l_inodebits.bits;
#define DEBUG_SUBSYSTEM S_MDC
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/kernel.h>
-#else
-# include <liblustre.h>
-#endif
+#include <linux/module.h>
+#include <linux/kernel.h>
#include <obd_class.h>
#include "mdc_internal.h"
#define DEBUG_SUBSYSTEM S_MDC
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/pagemap.h>
-# include <linux/miscdevice.h>
-# include <linux/init.h>
-# include <linux/utsname.h>
-#else
-# include <liblustre.h>
-#endif
+#include <linux/module.h>
+#include <linux/pagemap.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <linux/utsname.h>
#include <lustre_acl.h>
#include <lustre_ioctl.h>
RETURN(0);
}
-#ifdef __KERNEL__
static void mdc_release_page(struct page *page, int remove)
{
if (remove) {
goto out_unlock;
}
-#else /* __KERNEL__ */
-
-static struct page
-*mdc_read_page_remote(struct obd_export *exp, const struct lmv_oinfo *lmo,
- const __u64 hash, struct obd_capa *oc)
-{
- struct ptlrpc_request *req = NULL;
- struct page *page;
- int rc;
-
- OBD_PAGE_ALLOC(page, 0);
- if (page == NULL)
- return ERR_PTR(-ENOMEM);
-
- rc = mdc_getpage(exp, &lmo->lmo_fid, hash, oc, &page, 1, &req);
- if (req != NULL)
- ptlrpc_req_finished(req);
-
- if (unlikely(rc)) {
- OBD_PAGE_FREE(page);
- return ERR_PTR(rc);
- }
- return page;
-}
-
-
-static int mdc_read_page(struct obd_export *exp, struct md_op_data *op_data,
- struct md_callback *cb_op, __u64 hash_offset,
- struct page **ppage)
-{
- struct page *page;
- struct lmv_oinfo *lmo;
- int rc = 0;
-
- /* No local cache for liblustre, always read entry remotely */
- lmo = &op_data->op_mea1->lsm_md_oinfo[op_data->op_stripe_offset];
- page = mdc_read_page_remote(exp, lmo, hash_offset,
- op_data->op_capa1);
- if (IS_ERR(page))
- return PTR_ERR(page);
-
- *ppage = page;
-
- return rc;
-}
-
-#endif
static int mdc_statfs(const struct lu_env *env,
struct obd_export *exp, struct obd_statfs *osfs,
LUSTRE_MDC_NAME, NULL);
}
-#ifdef __KERNEL__
static void /*__exit*/ mdc_exit(void)
{
class_unregister_type(LUSTRE_MDC_NAME);
module_init(mdc_init);
module_exit(mdc_exit);
-#endif
#ifndef _MDT_INTERNAL_H
#define _MDT_INTERNAL_H
-#if defined(__KERNEL__)
#include <libcfs/lucache.h>
#include <lustre_net.h>
int mds_mod_init(void);
void mds_mod_exit(void);
-#endif /* __KERNEL__ */
#endif /* _MDT_H */
LUSTRE_MGC_NAME, NULL);
}
-#ifdef __KERNEL__
static void /*__exit*/ mgc_exit(void)
{
class_unregister_type(LUSTRE_MGC_NAME);
module_init(mgc_init);
module_exit(mgc_exit);
-#endif
#define DEBUG_SUBSYSTEM S_MGS
#define D_MGS D_CONFIG
-#ifdef __KERNEL__
#include <linux/pagemap.h>
-#endif
#include <obd.h>
#include <obd_class.h>
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/version.h>
#include <linux/fs.h>
#include <asm/unistd.h>
#include <obd_class.h>
#include <lustre_debug.h>
#include <lustre/lustre_idl.h>
-#else
-#include <liblustre.h>
-#endif
#include <libcfs/list.h>
#include <lustre_capa.h>
struct kmem_cache *capa_cachep;
-#ifdef __KERNEL__
/* lock for capa hash/capa_list/fo_capa_keys */
DEFINE_SPINLOCK(capa_lock);
static struct capa_hmac_alg capa_hmac_algs[] = {
DEF_CAPA_HMAC_ALG("sha1", SHA1, 20, 20),
};
-#endif
/* capa count */
int capa_count[CAPA_SITE_MAX] = { 0, };
}
EXPORT_SYMBOL(init_capa_hash);
-#ifdef __KERNEL__
static inline int capa_on_server(struct obd_capa *ocapa)
{
return ocapa->c_site == CAPA_SITE_SERVER;
return rc;
}
EXPORT_SYMBOL(capa_decrypt_id);
-#endif
void capa_cpy(void *capa, struct obd_capa *ocapa)
{
#define DEBUG_SUBSYSTEM S_CLASS
+#include <linux/sched.h>
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_fid.h>
}
EXPORT_SYMBOL(cl_req_attr_set);
-/* XXX complete(), init_completion(), and wait_for_completion(), until they are
- * implemented in libcfs. */
-#ifdef __KERNEL__
-# include <linux/sched.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-#endif
-
/**
* Initialize synchronous io wait anchor, for transfer of \a nrpages pages.
*/
/* wait until cl_sync_io_note() has done wakeup */
while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) {
-#ifdef __KERNEL__
cpu_relax();
-#endif
}
POISON(anchor, 0x5a, sizeof *anchor);
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-# include <liblustre.h>
-#else
-# include <asm/atomic.h>
-#endif
+#include <asm/atomic.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_ioctl.h>
#include "llog_internal.h"
-#ifndef __KERNEL__
-/* liblustre workaround */
-atomic_t libcfs_kmemory = {0};
-#endif
struct obd_device *obd_devs[MAX_OBD_DEVICES];
EXPORT_SYMBOL(obd_devs);
__u64 obd_max_pages = 0;
__u64 obd_max_alloc = 0;
-#ifndef __KERNEL__
-__u64 obd_alloc;
-__u64 obd_pages;
-#endif
+
static DEFINE_SPINLOCK(obd_updatemax_lock);
/* The following are visible and mutable through /proc/sys/lustre/. */
RETURN(err);
} /* class_handle_ioctl */
-#ifdef __KERNEL__
extern struct miscdevice obd_psdev;
-#else
-struct miscdevice obd_psdev;
-#endif
#define OBD_INIT_CHECK
#ifdef OBD_INIT_CHECK
extern int class_procfs_init(void);
extern int class_procfs_clean(void);
-#ifdef __KERNEL__
static int __init init_obdclass(void)
-#else
-int init_obdclass(void)
-#endif
{
int i, err;
-#ifdef __KERNEL__
int lustre_register_fs(void);
for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
INIT_LIST_HEAD(&capa_list[i]);
-#endif
LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n");
err = obd_init_caches();
if (err)
return err;
-#ifdef __KERNEL__
err = class_procfs_init();
if (err)
return err;
-#endif
err = lu_global_init();
if (err)
if (err != 0)
return err;
-#if defined(__KERNEL__) && defined(HAVE_SERVER_SUPPORT)
+#ifdef HAVE_SERVER_SUPPORT
err = dt_global_init();
if (err != 0)
return err;
err = lu_ucred_global_init();
if (err != 0)
return err;
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
err = llog_info_init();
if (err)
return err;
-#ifdef __KERNEL__
err = lustre_register_fs();
-#endif
return err;
}
return ret;
}
EXPORT_SYMBOL(obd_pages_max);
-#endif
+#endif /* LPROCFS */
/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this
* ifdef to the end of the file to cover module and versioning goo.*/
-#ifdef __KERNEL__
static void cleanup_obdclass(void)
{
int lustre_unregister_fs(void);
#ifdef HAVE_SERVER_SUPPORT
lu_ucred_global_fini();
dt_global_fini();
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
cl_global_fini();
lu_capainfo_fini();
lu_global_fini();
MODULE_LICENSE("GPL");
cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass);
-#endif
#define DEBUG_SUBSYSTEM D_OTHER
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <lustre_debug.h>
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lprocfs_status.h>
}
EXPORT_SYMBOL(obd_zombie_barrier);
-#ifdef __KERNEL__
/**
* destroy zombie export/import thread.
RETURN(0);
}
-#else /* ! KERNEL */
-
-static atomic_t zombie_recur = ATOMIC_INIT(0);
-static void *obd_zombie_impexp_work_cb;
-static void *obd_zombie_impexp_idle_cb;
-
-int obd_zombie_impexp_kill(void *arg)
-{
- int rc = 0;
-
- if (atomic_inc_return(&zombie_recur) == 1) {
- obd_zombie_impexp_cull();
- rc = 1;
- }
- atomic_dec(&zombie_recur);
- return rc;
-}
-
-#endif
/**
* start destroy zombie import/export thread
*/
int obd_zombie_impexp_init(void)
{
-#ifdef __KERNEL__
struct task_struct *task;
-#endif
INIT_LIST_HEAD(&obd_zombie_imports);
init_waitqueue_head(&obd_zombie_waitq);
obd_zombie_pid = 0;
-#ifdef __KERNEL__
task = kthread_run(obd_zombie_impexp_thread, NULL, "obd_zombid");
if (IS_ERR(task))
RETURN(PTR_ERR(task));
wait_for_completion(&obd_zombie_start);
-#else
-
- obd_zombie_impexp_work_cb =
- liblustre_register_wait_callback("obd_zombi_impexp_kill",
- &obd_zombie_impexp_kill, NULL);
-
- obd_zombie_impexp_idle_cb =
- liblustre_register_idle_callback("obd_zombi_impexp_check",
- &obd_zombie_impexp_check, NULL);
-#endif
RETURN(0);
}
/**
{
set_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags);
obd_zombie_impexp_notify();
-#ifdef __KERNEL__
wait_for_completion(&obd_zombie_stop);
-#else
- liblustre_deregister_wait_callback(obd_zombie_impexp_work_cb);
- liblustre_deregister_idle_callback(obd_zombie_impexp_idle_cb);
-#endif
}
/***** Kernel-userspace comm helpers *******/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <asm/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/seq_file.h>
-#else
-# include <liblustre.h>
-#endif
#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <lustre_ioctl.h>
#include <lustre_ver.h>
#include <lustre/lustre_build_version.h>
-#ifdef __KERNEL__
int proc_version;
.fops = &obd_psdev_fops,
};
-#endif
#ifdef LPROCFS
static int obd_proc_version_seq_show(struct seq_file *m, void *v)
#define lprocfs_base NULL
#endif /* LPROCFS */
-#ifdef __KERNEL__
static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos)
{
if (*pos >= class_devno_max())
.llseek = seq_lseek,
.release = seq_release,
};
-#endif
int class_procfs_init(void)
{
-#ifdef __KERNEL__
int rc;
ENTRY;
&obd_device_list_fops, NULL);
if (rc)
CERROR("error adding /proc/fs/lustre/devices file\n");
-#else
- ENTRY;
-#endif
RETURN(0);
}
-#ifdef __KERNEL__
int class_procfs_clean(void)
{
ENTRY;
}
RETURN(0);
}
-#endif
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
return 0;
}
-#ifdef __KERNEL__
static int llog_process_thread_daemonize(void *arg)
{
struct llog_process_info *lpi = arg;
complete(&lpi->lpi_completion);
return rc;
}
-#endif
int llog_process_or_fork(const struct lu_env *env,
struct llog_handle *loghandle,
lpi->lpi_cbdata = data;
lpi->lpi_catdata = catdata;
-#ifdef __KERNEL__
if (fork) {
struct task_struct *task;
lpi->lpi_env = env;
llog_process_thread(lpi);
}
-#else
- lpi->lpi_env = env;
- llog_process_thread(lpi);
-#endif
rc = lpi->lpi_rc;
-#ifdef __KERNEL__
out_lpi:
-#endif
OBD_FREE_PTR(lpi);
RETURN(rc);
}
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <lustre_log.h>
*
* Author: Andreas Dilger <andreas.dilger@intel.com>
*/
-#ifdef __KERNEL__
#include <linux/module.h>
-#else
-#include <liblustre.h>
-#endif
#include <lustre_lib.h>
#include <lprocfs_status.h>
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lprocfs_status.h>
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lprocfs_status.h>
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lprocfs_status.h>
#define DEBUG_SUBSYSTEM S_CLASS
#include <libcfs/libcfs.h>
-
-#ifdef __KERNEL__
-# include <linux/module.h>
-#endif
-
-/* hash_long() */
-#include <libcfs/libcfs_hash.h>
+#include <linux/module.h>
+#include <libcfs/libcfs_hash.h> /* hash_long() */
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_disk.h>
}
}
-#ifdef __KERNEL__
static unsigned long lu_cache_shrink_count(struct shrinker *sk,
struct shrink_control *sc)
}
}
EXPORT_SYMBOL(lu_context_keys_dump);
-#endif /* __KERNEL__ */
/**
* Initialization of global lu_* data.
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <obd.h>
#include <obd_class.h>
#include <obd_support.h>
}
EXPORT_SYMBOL(lu_ref_del_at);
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
static void *lu_ref_seq_start(struct seq_file *seq, loff_t *pos)
{
.release = lu_ref_seq_release
};
-#endif
+#endif /* LPROCFS */
int lu_ref_global_init(void)
{
spin_lock_init(&lu_ref_refs_guard);
result = lu_kmem_init(lu_ref_caches);
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
if (result == 0) {
result = lprocfs_seq_create(proc_lustre_root, "lu_refs",
0444, &lu_ref_dump_fops, NULL);
if (result)
lu_kmem_fini(lu_ref_caches);
}
-#endif
+#endif /* LPROCFS */
return result;
}
void lu_ref_global_fini(void)
{
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
lprocfs_remove_proc_entry("lu_refs", proc_lustre_root);
-#endif
+#endif /* LPROCFS */
lu_kmem_fini(lu_ref_caches);
}
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <lustre_handles.h>
#include <lustre_lib.h>
-#ifndef __KERNEL__
-# define list_add_rcu list_add
-# define list_del_rcu list_del
-# define list_for_each_rcu list_for_each
-# define list_for_each_safe_rcu list_for_each_safe
-# define list_for_each_entry_rcu list_for_each_entry
-# define rcu_read_lock() spin_lock(&bucket->lock)
-# define rcu_read_unlock() spin_unlock(&bucket->lock)
-#endif /* !__KERNEL__ */
static __u64 handle_base;
#define HANDLE_INCR 7
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_support.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
#include <obd_class.h>
#include <linux/string.h>
#include <lustre_disk.h>
-#else
-#include <liblustre.h>
-#include <string.h>
-#include <obd_class.h>
-#include <obd.h>
-#endif
#include <lustre_ioctl.h>
#include <lustre_log.h>
#include <lprocfs_status.h>
int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
struct lustre_cfg *lcfg, void *data)
{
-#ifdef __KERNEL__
struct lprocfs_vars *var;
char *key, *sval;
int i, keylen, vallen;
if (!rc && skip)
rc = skip;
RETURN(rc);
-#else
- CDEBUG(D_CONFIG, "liblustre can't process params.\n");
- /* Don't throw config error */
- RETURN(0);
-#endif
}
EXPORT_SYMBOL(class_process_proc_param);
-#endif
+#endif /* !HAVE_ONLY_PROCFS_SEQ */
int class_process_proc_seq_param(char *prefix, struct lprocfs_seq_vars *lvars,
struct lustre_cfg *lcfg, void *data)
{
-#ifdef __KERNEL__
struct lprocfs_seq_vars *var;
struct file fakefile;
struct seq_file fake_seqfile;
if (!rc && skip)
rc = skip;
RETURN(rc);
-#else
- CDEBUG(D_CONFIG, "liblustre can't process params.\n");
- /* Don't throw config error */
- RETURN(0);
-#endif
}
EXPORT_SYMBOL(class_process_proc_seq_param);
-#ifdef __KERNEL__
extern int lustre_check_exclusion(struct super_block *sb, char *svname);
-#else
-#define lustre_check_exclusion(a,b) 0
-#endif
/*
* Supplemental functions for config logs, it allocates lustre_cfg
}
}
-#if defined(HAVE_SERVER_SUPPORT) && defined(__KERNEL__)
+#ifdef HAVE_SERVER_SUPPORT
/* newer MDS replaces LOV/OSC with LOD/OSP */
{
char *typename = lustre_cfg_string(lcfg, 1);
strcpy(typename, LUSTRE_OSP_NAME);
}
}
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
if (clli->cfg_flags & CFG_F_EXCLUDE) {
CDEBUG(D_CONFIG, "cmd: %x marked EXCLUDED\n",
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-#include "../liblustre/llite_lib.h"
-#else
#include <obd_class.h>
#include <lustre/lustre_idl.h>
-#endif
void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent)
{
void obdo_cpy_md(struct obdo *dst, const struct obdo *src, obd_flag valid)
{
-#ifdef __KERNEL__
CDEBUG(D_INODE, "src obdo "DOSTID" valid "LPX64", dst obdo "DOSTID"\n",
POSTID(&src->o_oi), src->o_valid, POSTID(&dst->o_oi));
-#endif
if (valid & OBD_MD_FLATIME)
dst->o_atime = src->o_atime;
if (valid & OBD_MD_FLMTIME)
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <lustre_export.h>
#include <lustre_net.h>
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-# include <liblustre.h>
-#else
-# include <libcfs/libcfs.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <obd_class.h>
-
static inline __u32 consume(int nob, __u8 **ptr)
{
__u32 value;
*/
#define DEBUG_SUBSYSTEM S_ECHO
-#ifdef __KERNEL__
#include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_support.h>
lu_kmem_fini(echo_caches);
}
-#ifdef __KERNEL__
static int __init obdecho_init(void)
{
int rc;
MODULE_LICENSE("GPL");
cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit);
-#endif /* __KERNEL__ */
/** @} echo_client */
/* block size to use for data verification */
#define OBD_ECHO_BLOCK_SIZE (4<<10)
-#ifdef __KERNEL__
-# ifdef HAVE_SERVER_SUPPORT
+#ifdef HAVE_SERVER_SUPPORT
extern struct obd_ops echo_obd_ops;
int echo_persistent_pages_init(void);
void echo_persistent_pages_fini(void);
-# endif
-#else /* ! __KERNEL__ */
-/* Kludge here, define some functions and macros needed by liblustre -jay */
-
-#define READ 0
-#define WRITE 1
-
-#endif /* ifdef __KERNEL__ */
+#endif /* HAVE_SERVER_SUPPORT */
#endif
#ifndef OSC_CL_INTERNAL_H
#define OSC_CL_INTERNAL_H
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <obd.h>
/* osc_build_res_name() */
#include <cl_object.h>
return 0;
}
-#if defined(__KERNEL__)
/**
* Checks that there are no pages being written in the extent being truncated.
*/
CL_PAGE_DEBUG(D_ERROR, env, page, "exists " LPU64 "/%s.\n",
start, current->comm);
-#ifdef __linux__
if (PageLocked(page->cp_vmpage))
CDEBUG(D_CACHE, "page %p index %lu locked for %d.\n",
ops, osc_index(ops), oap->oap_cmd & OBD_BRW_RWMASK);
-#endif
return CLP_GANG_OKAY;
}
start + partial, CL_PAGE_EOF,
trunc_check_cb, (void *)&size);
}
-#else /* __KERNEL__ */
-static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
- struct osc_io *oio, __u64 size)
-{
- return;
-}
-#endif
static int osc_io_setattr_start(const struct lu_env *env,
const struct cl_io_slice *slice)
#define DEBUG_SUBSYSTEM S_OSC
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
+#include <libcfs/libcfs.h>
/* fid_build_reg_res_name() */
#include <lustre_fid.h>
struct cl_page *page = ops->ops_cl.cpl_page;
if (cl_page_is_vmlocked(env, page)
-#if defined(__KERNEL__)
|| PageDirty(page->cp_vmpage) || PageWriteback(page->cp_vmpage)
-#endif
) {
(*(unsigned long *)cbdata)++;
return CLP_GANG_ABORT;
*
* Code originally extracted from quota directory
*/
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd.h>
#include "osc_internal.h"
#include <libcfs/libcfs.h>
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <lustre_dlm.h>
#include <lustre_net.h>
ergo(i == page_count - 1, poff == 0)),
"i: %d/%d pg: %p off: "LPU64", count: %u\n",
i, page_count, pg, pg->off, pg->count);
-#ifdef __linux__
LASSERTF(i == 0 || pg->off > pg_prev->off,
"i %d p_c %u pg %p [pri %lu ind %lu] off "LPU64
" prev_pg %p [pri %lu ind %lu] off "LPU64"\n",
pg->pg, page_private(pg->pg), pg->pg->index, pg->off,
pg_prev->pg, page_private(pg_prev->pg),
pg_prev->pg->index, pg_prev->off);
-#else
- LASSERTF(i == 0 || pg->off > pg_prev->off,
- "i %d p_c %u\n", i, page_count);
-#endif
LASSERT((pga[0]->flag & OBD_BRW_SRVLOCK) ==
(pg->flag & OBD_BRW_SRVLOCK));
RETURN(rc);
}
-#ifdef __KERNEL__
static void /*__exit*/ osc_exit(void)
{
class_unregister_type(LUSTRE_OSC_NAME);
MODULE_LICENSE("GPL");
cfs_module(osc, LUSTRE_VERSION_STRING, osc_init, osc_exit);
-#endif
* in that lockspace
*
*/
-#ifdef __KERNEL__
#include <linux/module.h>
#include <linux/slab.h>
spin_unlock(&dl->dl_list_lock);
return result;
}
-#endif
DX_FMT_NAME_LEN = 16,
};
-#ifdef __KERNEL__
/*
* Debugging.
*/
/* __KERNEL__ */
-#endif
/*
* User level API. Copy exists in lustre/lustre/tests/iam_ut.c
#ifndef _OSD_INTERNAL_H
#define _OSD_INTERNAL_H
-#if defined(__KERNEL__)
/* struct mutex */
#include <linux/mutex.h>
void osd_fini_iobuf(struct osd_device *d, struct osd_iobuf *iobuf);
-#endif /* __KERNEL__ */
#endif /* _OSD_INTERNAL_H */
#ifndef _OSD_OI_H
#define _OSD_OI_H
-#if defined(__KERNEL__)
/* struct rw_semaphore */
#include <linux/rwsem.h>
int fid_is_on_ost(struct osd_thread_info *info, struct osd_device *osd,
const struct lu_fid *fid, enum oi_check_flags flags);
-#endif /* __KERNEL__ */
#endif /* _OSD_OI_H */
/** Implementation of client-side PortalRPC interfaces */
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <errno.h>
-#include <signal.h>
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
* unlinked before returning a req to the pool.
*/
for (;;) {
-#ifdef __KERNEL__
/* The wq argument is ignored by user-space wait_event macros */
wait_queue_head_t *wq = (request->rq_set != NULL) ?
&request->rq_set->set_waitq :
&request->rq_reply_waitq;
-#endif
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
-#else
-#include <liblustre.h>
-#endif
#include "ptlrpc_internal.h"
[EKEYREJECTED] = LUSTRE_EKEYREJECTED,
[EOWNERDEAD] = LUSTRE_EOWNERDEAD,
[ENOTRECOVERABLE] = LUSTRE_ENOTRECOVERABLE,
-#ifdef __KERNEL__
[ERESTARTSYS] = LUSTRE_ERESTARTSYS,
[ERESTARTNOINTR] = LUSTRE_ERESTARTNOINTR,
[ERESTARTNOHAND] = LUSTRE_ERESTARTNOHAND,
[EJUKEBOX] = LUSTRE_EJUKEBOX,
[EIOCBQUEUED] = LUSTRE_EIOCBQUEUED,
[EIOCBRETRY] = LUSTRE_EIOCBRETRY
-#endif
};
static int lustre_errno_ntoh_mapping[] = {
[LUSTRE_EKEYREJECTED] = EKEYREJECTED,
[LUSTRE_EOWNERDEAD] = EOWNERDEAD,
[LUSTRE_ENOTRECOVERABLE] = ENOTRECOVERABLE,
-#ifdef __KERNEL__
[LUSTRE_ERESTARTSYS] = ERESTARTSYS,
[LUSTRE_ERESTARTNOINTR] = ERESTARTNOINTR,
[LUSTRE_ERESTARTNOHAND] = ERESTARTNOHAND,
[LUSTRE_EJUKEBOX] = EJUKEBOX,
[LUSTRE_EIOCBQUEUED] = EIOCBQUEUED,
[LUSTRE_EIOCBRETRY] = EIOCBRETRY
-#endif
};
unsigned int lustre_errno_hton(unsigned int h)
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#else
-# include <libcfs/libcfs.h>
-# ifdef __mips64__
-# include <linux/kernel.h>
-# endif
-#endif
-
+#include <libcfs/libcfs.h>
+#include <linux/kernel.h>
#include <obd_class.h>
#include <lustre_net.h>
#include <lustre_sec.h>
{
lnet_pid_t pid;
-#ifndef __KERNEL__
- pid = getpid();
-#else
pid = LUSTRE_SRV_LNET_PID;
-#endif
return pid;
}
/* CAVEAT EMPTOR: how we process portals events is _radically_
* different depending on... */
-#ifdef __KERNEL__
/* kernel LNet calls our master callback when there are new event,
* because we are guaranteed to get every event via callback,
* so we just set EQ size to 0 to avoid overhread of serializing
* enqueue/dequeue operations in LNet. */
rc = LNetEQAlloc(0, ptlrpc_master_callback, &ptlrpc_eq_h);
-#else
- /* liblustre calls the master callback when it removes events from the
- * event queue. The event queue has to be big enough not to drop
- * anything */
- rc = LNetEQAlloc(10240, LNET_EQ_HANDLER_NONE, &ptlrpc_eq_h);
-#endif
if (rc == 0)
return 0;
return rc;
}
-#ifndef __KERNEL__
-struct list_head liblustre_wait_callbacks;
-struct list_head liblustre_idle_callbacks;
-void *liblustre_services_callback;
-
-void *
-liblustre_register_waitidle_callback(struct list_head *callback_list,
- const char *name,
- int (*fn)(void *arg), void *arg)
-{
- struct liblustre_wait_callback *llwc;
-
- OBD_ALLOC(llwc, sizeof(*llwc));
- LASSERT (llwc != NULL);
-
- llwc->llwc_name = name;
- llwc->llwc_fn = fn;
- llwc->llwc_arg = arg;
- list_add_tail(&llwc->llwc_list, callback_list);
-
- return (llwc);
-}
-
-void
-liblustre_deregister_waitidle_callback (void *opaque)
-{
- struct liblustre_wait_callback *llwc = opaque;
-
- list_del(&llwc->llwc_list);
- OBD_FREE(llwc, sizeof(*llwc));
-}
-
-void *
-liblustre_register_wait_callback (const char *name,
- int (*fn)(void *arg), void *arg)
-{
- return liblustre_register_waitidle_callback(&liblustre_wait_callbacks,
- name, fn, arg);
-}
-
-void
-liblustre_deregister_wait_callback (void *opaque)
-{
- liblustre_deregister_waitidle_callback(opaque);
-}
-
-void *
-liblustre_register_idle_callback (const char *name,
- int (*fn)(void *arg), void *arg)
-{
- return liblustre_register_waitidle_callback(&liblustre_idle_callbacks,
- name, fn, arg);
-}
-
-void
-liblustre_deregister_idle_callback (void *opaque)
-{
- liblustre_deregister_waitidle_callback(opaque);
-}
-
-int
-liblustre_check_events (int timeout)
-{
- lnet_event_t ev;
- int rc;
- int i;
- ENTRY;
-
- rc = LNetEQPoll(&ptlrpc_eq_h, 1, timeout * 1000, &ev, &i);
- if (rc == 0)
- RETURN(0);
-
- LASSERT (rc == -EOVERFLOW || rc == 1);
-
- /* liblustre: no asynch callback so we can't afford to miss any
- * events... */
- if (rc == -EOVERFLOW) {
- CERROR ("Dropped an event!!!\n");
- abort();
- }
-
- ptlrpc_master_callback (&ev);
- RETURN(1);
-}
-
-int liblustre_waiting = 0;
-
-int
-liblustre_wait_event (int timeout)
-{
- struct list_head *tmp;
- struct liblustre_wait_callback *llwc;
- int found_something = 0;
-
- /* single threaded recursion check... */
- liblustre_waiting = 1;
-
- for (;;) {
- /* Deal with all pending events */
- while (liblustre_check_events(0))
- found_something = 1;
-
- /* Give all registered callbacks a bite at the cherry */
- list_for_each(tmp, &liblustre_wait_callbacks) {
- llwc = list_entry(tmp,
- struct liblustre_wait_callback,
- llwc_list);
-
- if (llwc->llwc_fn(llwc->llwc_arg))
- found_something = 1;
- }
-
- if (found_something || timeout == 0)
- break;
-
- /* Nothing so far, but I'm allowed to block... */
- found_something = liblustre_check_events(timeout);
- if (!found_something) /* still nothing */
- break; /* I timed out */
- }
-
- liblustre_waiting = 0;
-
- return found_something;
-}
-
-void
-liblustre_wait_idle(void)
-{
- static int recursed = 0;
- struct list_head *tmp;
- struct liblustre_wait_callback *llwc;
- int idle = 0;
-
- LASSERT(!recursed);
- recursed = 1;
-
- do {
- liblustre_wait_event(0);
-
- idle = 1;
-
- list_for_each(tmp, &liblustre_idle_callbacks) {
- llwc = list_entry(tmp, struct liblustre_wait_callback,
- llwc_list);
- if (!llwc->llwc_fn(llwc->llwc_arg)) {
- idle = 0;
- break;
- }
- }
-
- } while (!idle);
-
- recursed = 0;
-}
-
-#endif /* __KERNEL__ */
int ptlrpc_init_portals(void)
{
CERROR("network initialisation failed\n");
return rc;
}
-#ifndef __KERNEL__
- INIT_LIST_HEAD(&liblustre_wait_callbacks);
- INIT_LIST_HEAD(&liblustre_idle_callbacks);
-
- liblustre_services_callback =
- liblustre_register_wait_callback("liblustre_check_services",
- &liblustre_check_services,
- NULL);
- init_completion_module(liblustre_wait_event);
-#endif
rc = ptlrpcd_addref();
if (rc == 0)
return 0;
CERROR("rpcd initialisation failed\n");
-#ifndef __KERNEL__
- liblustre_deregister_wait_callback(liblustre_services_callback);
-#endif
ptlrpc_ni_fini();
return rc;
}
void ptlrpc_exit_portals(void)
{
-#ifndef __KERNEL__
- liblustre_deregister_wait_callback(liblustre_services_callback);
-#endif
ptlrpcd_decref();
ptlrpc_ni_fini();
}
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/mutex.h>
#include <linux/crypto.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/key-type.h>
#include <linux/mutex.h>
#include <asm/atomic.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/crypto.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/crypto.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/atomic.h>
struct rpc_clnt; /* for rpc_pipefs */
#include <linux/sunrpc/rpc_pipe_fs.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/crypto.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/hash.h>
#include <linux/mutex.h>
#include <linux/sunrpc/cache.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/dcache.h>
#include <linux/fs.h>
#include <linux/mutex.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/mutex.h>
#include <asm/atomic.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <lustre_ha.h>
request->rq_timeout = INITIAL_CONNECT_TIMEOUT;
lustre_msg_set_timeout(request->rq_reqmsg, request->rq_timeout);
-#ifndef __KERNEL__
- lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT);
-#endif
lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER);
request->rq_no_resend = request->rq_no_delay = 1;
static void ptlrpc_maybe_ping_import_soon(struct obd_import *imp)
{
-#ifdef __KERNEL__
int force_verify;
spin_lock(&imp->imp_lock);
if (force_verify)
ptlrpc_pinger_wake_up();
-#else
- /* liblustre has no pinger thread, so we wakeup pinger anyway */
- ptlrpc_pinger_wake_up();
-#endif
}
static int ptlrpc_busy_reconnect(int rc)
of macro arguments */
const char *older = "older than client. "
"Consider upgrading server";
-#ifdef __KERNEL__
const char *newer = "newer than client. "
"Consider recompiling application";
-#else
- const char *newer = "newer than client. "
- "Consider upgrading client";
-#endif
LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) "
"is much %s (%s)\n",
RETURN(0);
}
-#ifdef __KERNEL__
/**
* In kernel code all import invalidation happens in its own
* separate thread, so that whatever application happened to encounter
class_import_put(imp);
RETURN(0);
}
-#endif
/**
* This is the state machine for client-side recovery on import.
imp->imp_vbr_failed = 0;
spin_unlock(&imp->imp_lock);
-#ifdef __KERNEL__
{
struct task_struct *task;
/* bug 17802: XXX client_disconnect_export vs connect request
}
RETURN(rc);
}
-#else
- ptlrpc_invalidate_import(imp);
-
- IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
-#endif
}
if (imp->imp_state == LUSTRE_IMP_REPLAY) {
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
#include <linux/module.h>
-#else
-# include <liblustre.h>
-#endif
/* LUSTRE_VERSION_CODE */
#include <lustre_ver.h>
#define DEBUG_SUBSYSTEM S_LOG
-#ifdef __KERNEL__
#include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
#define DEBUG_SUBSYSTEM S_LOG
-#ifdef __KERNEL__
#include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
-
#include <obd_class.h>
#include <lu_target.h>
#include <lustre_log.h>
#include <lustre_net.h>
-#if defined(__KERNEL__) && defined(LUSTRE_LOG_SERVER)
static int llog_origin_close(const struct lu_env *env, struct llog_handle *lgh)
{
if (lgh->lgh_hdr != NULL && lgh->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
RETURN(0);
}
EXPORT_SYMBOL(llog_origin_handle_close);
-
-#else /* !__KERNEL__ */
-int llog_origin_handle_open(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-
-int llog_origin_handle_destroy(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-
-int llog_origin_handle_next_block(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-int llog_origin_handle_prev_block(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-int llog_origin_handle_read_header(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-int llog_origin_handle_close(struct ptlrpc_request *req)
-{
- LBUG();
- return 0;
-}
-#endif
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <lustre_net.h>
#include <lustre_lib.h>
RETURN(0);
for (;;) {
-#ifdef __KERNEL__
/* The wq argument is ignored by user-space wait_event macros */
wait_queue_head_t *wq = (req->rq_set != NULL) ?
&req->rq_set->set_waitq :
&req->rq_reply_waitq;
-#endif
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
/* ptlrpc/nrs_fifo.c */
extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo;
-#if defined HAVE_SERVER_SUPPORT && defined(__KERNEL__)
+#ifdef HAVE_SERVER_SUPPORT
/* ptlrpc/nrs_crr.c */
extern struct ptlrpc_nrs_pol_conf nrs_conf_crrn;
/* ptlrpc/nrs_orr.c */
extern struct ptlrpc_nrs_pol_conf nrs_conf_orr;
extern struct ptlrpc_nrs_pol_conf nrs_conf_trr;
extern struct ptlrpc_nrs_pol_conf nrs_conf_tbf;
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
/**
* Adds all policies that ship with the ptlrpc module, to NRS core's list of
if (rc != 0)
GOTO(fail, rc);
-#if defined HAVE_SERVER_SUPPORT && defined(__KERNEL__)
+#ifdef HAVE_SERVER_SUPPORT
rc = ptlrpc_nrs_policy_register(&nrs_conf_crrn);
if (rc != 0)
GOTO(fail, rc);
rc = ptlrpc_nrs_policy_register(&nrs_conf_tbf);
if (rc != 0)
GOTO(fail, rc);
-#endif
+#endif /* HAVE_SERVER_SUPPORT */
RETURN(rc);
fail:
#ifdef HAVE_SERVER_SUPPORT
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include <libcfs/libcfs.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include <libcfs/libcfs.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <libcfs/libcfs.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <errno.h>
-#include <signal.h>
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include "ptlrpc_internal.h"
-#ifdef __KERNEL__
void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc,
int mdidx)
desc->bd_iov_count++;
}
-#else /* !__KERNEL__ */
-
-void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc,
- int mdidx)
-{
- LASSERT(mdidx < desc->bd_md_max_brw);
- LASSERT(desc->bd_iov_count > mdidx * LNET_MAX_IOV);
- LASSERT(!(md->options & (LNET_MD_IOVEC | LNET_MD_KIOV | LNET_MD_PHYS)));
-
- if (desc->bd_iov_count == 1) {
- md->start = desc->bd_iov[0].iov_base;
- md->length = desc->bd_iov[0].iov_len;
- return;
- }
-
- md->options |= LNET_MD_IOVEC;
- md->start = &desc->bd_iov[mdidx * LNET_MAX_IOV];
- md->length = min(LNET_MAX_IOV, desc->bd_iov_count - mdidx *
- LNET_MAX_IOV);
-}
-
-static int can_merge_iovs(lnet_md_iovec_t *existing, lnet_md_iovec_t *candidate)
-{
- if (existing->iov_base + existing->iov_len == candidate->iov_base)
- return 1;
-#if 0
- /* Enable this section to provide earlier evidence of fragmented bulk */
- CERROR("Can't merge iovs %p for %x, %p for %x\n",
- existing->iov_base, existing->iov_len,
- candidate->iov_base, candidate->iov_len);
-#endif
- return 0;
-}
-
-void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page,
- int pageoffset, int len)
-{
- lnet_md_iovec_t *iov = &desc->bd_iov[desc->bd_iov_count];
-
- iov->iov_base = page->addr + pageoffset;
- iov->iov_len = len;
-
- if (desc->bd_iov_count > 0 && can_merge_iovs(iov - 1, iov)) {
- (iov - 1)->iov_len += len;
- } else {
- desc->bd_iov_count++;
- }
-}
-
-#endif /* !__KERNEL__ */
* Portal-RPC reconnection and replay operations, for use in recovery.
*/
-#ifndef __KERNEL__
-#include <liblustre.h>
-#else
#define DEBUG_SUBSYSTEM S_RPC
-#endif
#include <obd_support.h>
#include <obd_class.h>
cfs_time_current());
}
-#ifdef __KERNEL__
static bool ir_up;
wake_up(&pet_waitq);
}
EXPORT_SYMBOL(ping_evictor_stop);
-#else /* !__KERNEL__ */
-
-/* XXX
- * the current implementation of pinger in liblustre is not optimized
- */
-
-#ifdef ENABLE_PINGER
-static struct pinger_data {
- int pd_recursion;
- cfs_time_t pd_this_ping; /* jiffies */
- cfs_time_t pd_next_ping; /* jiffies */
- struct ptlrpc_request_set *pd_set;
-} pinger_args;
-
-static int pinger_check_rpcs(void *arg)
-{
- cfs_time_t curtime = cfs_time_current();
- struct ptlrpc_request *req;
- struct ptlrpc_request_set *set;
- struct list_head *iter;
- struct obd_import *imp;
- struct pinger_data *pd = &pinger_args;
- int rc;
-
- /* prevent recursion */
- if (pd->pd_recursion++) {
- CDEBUG(D_HA, "pinger: recursion! quit\n");
- LASSERT(pd->pd_set);
- pd->pd_recursion--;
- return 0;
- }
-
- /* have we reached ping point? */
- if (!pd->pd_set && cfs_time_before(curtime, pd->pd_next_ping)) {
- pd->pd_recursion--;
- return 0;
- }
-
- /* if we have rpc_set already, continue processing it */
- if (pd->pd_set) {
- LASSERT(pd->pd_this_ping);
- set = pd->pd_set;
- goto do_check_set;
- }
-
- pd->pd_this_ping = curtime;
- pd->pd_set = ptlrpc_prep_set();
- if (pd->pd_set == NULL)
- goto out;
- set = pd->pd_set;
-
- /* add rpcs into set */
- mutex_lock(&pinger_mutex);
- list_for_each(iter, &pinger_imports) {
- struct obd_import *imp = list_entry(iter, struct obd_import,
- imp_pinger_chain);
- int generation, level;
-
- if (cfs_time_aftereq(pd->pd_this_ping,
- imp->imp_next_ping - 5 * CFS_TICK)) {
- /* Add a ping. */
- spin_lock(&imp->imp_lock);
- generation = imp->imp_generation;
- level = imp->imp_state;
- spin_unlock(&imp->imp_lock);
-
- if (level != LUSTRE_IMP_FULL) {
- CDEBUG(D_HA,
- "not pinging %s (in recovery)\n",
- obd2cli_tgt(imp->imp_obd));
- continue;
- }
-
- req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING,
- LUSTRE_OBD_VERSION,
- OBD_PING);
- if (req == NULL) {
- CERROR("OOM trying to ping %s->%s\n",
- imp->imp_obd->obd_uuid.uuid,
- obd2cli_tgt(imp->imp_obd));
- break;
- }
-
- req->rq_no_resend = 1;
- ptlrpc_request_set_replen(req);
- req->rq_send_state = LUSTRE_IMP_FULL;
- ptlrpc_rqphase_move(req, RQ_PHASE_RPC);
- req->rq_import_generation = generation;
- ptlrpc_set_add_req(set, req);
- } else {
- CDEBUG(D_INFO, "don't need to ping %s ("CFS_TIME_T
- " > "CFS_TIME_T")\n", obd2cli_tgt(imp->imp_obd),
- imp->imp_next_ping, pd->pd_this_ping);
- }
- }
- pd->pd_this_ping = curtime;
- mutex_unlock(&pinger_mutex);
-
- /* Might be empty, that's OK. */
- if (atomic_read(&set->set_remaining) == 0)
- CDEBUG(D_RPCTRACE, "nothing to ping\n");
-
- list_for_each(iter, &set->set_requests) {
- struct ptlrpc_request *req =
- list_entry(iter, struct ptlrpc_request,
- rq_set_chain);
- DEBUG_REQ(D_RPCTRACE, req, "pinging %s->%s",
- req->rq_import->imp_obd->obd_uuid.uuid,
- obd2cli_tgt(req->rq_import->imp_obd));
- (void)ptl_send_rpc(req, 0);
- }
-
-do_check_set:
- rc = ptlrpc_check_set(NULL, set);
-
- /* not finished, and we are not expired, simply return */
- if (!rc && cfs_time_before(curtime, cfs_time_add(pd->pd_this_ping,
- cfs_time_seconds(PING_INTERVAL)))) {
- CDEBUG(D_RPCTRACE, "not finished, but also not expired\n");
- pd->pd_recursion--;
- return 0;
- }
-
- /* Expire all the requests that didn't come back. */
- mutex_lock(&pinger_mutex);
- list_for_each(iter, &set->set_requests) {
- req = list_entry(iter, struct ptlrpc_request,
- rq_set_chain);
-
- if (req->rq_phase == RQ_PHASE_COMPLETE)
- continue;
-
- CDEBUG(D_RPCTRACE, "Pinger initiate expire request(%p)\n",
- req);
-
- /* This will also unregister reply. */
- ptlrpc_expire_one_request(req, 0);
-
- /* We're done with this req, let's finally move it to complete
- * phase and take care of inflights. */
- ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);
- imp = req->rq_import;
- spin_lock(&imp->imp_lock);
- if (!list_empty(&req->rq_list)) {
- list_del_init(&req->rq_list);
- atomic_dec(&imp->imp_inflight);
- }
- spin_unlock(&imp->imp_lock);
- atomic_dec(&set->set_remaining);
- }
- mutex_unlock(&pinger_mutex);
-
- ptlrpc_set_destroy(set);
- pd->pd_set = NULL;
-
-out:
- pd->pd_next_ping = cfs_time_add(pd->pd_this_ping,
- cfs_time_seconds(PING_INTERVAL));
- pd->pd_this_ping = 0; /* XXX for debug */
-
- CDEBUG(D_INFO, "finished a round ping\n");
- pd->pd_recursion--;
- return 0;
-}
-
-static void *pinger_callback = NULL;
-#endif /* ENABLE_PINGER */
-
-int ptlrpc_start_pinger(void)
-{
-#ifdef ENABLE_PINGER
- memset(&pinger_args, 0, sizeof(pinger_args));
- pinger_callback = liblustre_register_wait_callback("pinger_check_rpcs",
- &pinger_check_rpcs,
- &pinger_args);
-#endif
- return 0;
-}
-
-int ptlrpc_stop_pinger(void)
-{
-#ifdef ENABLE_PINGER
- if (pinger_callback)
- liblustre_deregister_wait_callback(pinger_callback);
-#endif
- return 0;
-}
-
-void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
-{
-#ifdef ENABLE_PINGER
- mutex_lock(&pinger_mutex);
- ptlrpc_update_next_ping(imp, 0);
- if (pinger_args.pd_set == NULL &&
- cfs_time_before(imp->imp_next_ping, pinger_args.pd_next_ping)) {
- CDEBUG(D_HA, "set next ping to "CFS_TIME_T"(cur "CFS_TIME_T")\n",
- imp->imp_next_ping, cfs_time_current());
- pinger_args.pd_next_ping = imp->imp_next_ping;
- }
- mutex_unlock(&pinger_mutex);
-#endif
-}
-
-void ptlrpc_pinger_commit_expected(struct obd_import *imp)
-{
-#ifdef ENABLE_PINGER
- mutex_lock(&pinger_mutex);
- ptlrpc_update_next_ping(imp, 1);
- if (pinger_args.pd_set == NULL &&
- cfs_time_before(imp->imp_next_ping, pinger_args.pd_next_ping)) {
- CDEBUG(D_HA,"set next ping to "CFS_TIME_T"(cur "CFS_TIME_T")\n",
- imp->imp_next_ping, cfs_time_current());
- pinger_args.pd_next_ping = imp->imp_next_ping;
- }
- mutex_unlock(&pinger_mutex);
-#endif
-}
-
-int ptlrpc_add_timeout_client(int time, enum timeout_event event,
- timeout_cb_t cb, void *data,
- struct list_head *obd_list)
-{
- return 0;
-}
-
-int ptlrpc_del_timeout_client(struct list_head *obd_list,
- enum timeout_event event)
-{
- return 0;
-}
-
-int ptlrpc_pinger_add_import(struct obd_import *imp)
-{
- ENTRY;
-
- if (!list_empty(&imp->imp_pinger_chain))
- RETURN(-EALREADY);
-
- CDEBUG(D_HA, "adding pingable import %s->%s\n",
- imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
- ptlrpc_pinger_sending_on_import(imp);
-
- mutex_lock(&pinger_mutex);
- list_add_tail(&imp->imp_pinger_chain, &pinger_imports);
- class_import_get(imp);
- mutex_unlock(&pinger_mutex);
-
- RETURN(0);
-}
-
-int ptlrpc_pinger_del_import(struct obd_import *imp)
-{
- ENTRY;
-
- if (list_empty(&imp->imp_pinger_chain))
- RETURN(-ENOENT);
-
- mutex_lock(&pinger_mutex);
- list_del_init(&imp->imp_pinger_chain);
- CDEBUG(D_HA, "removing pingable import %s->%s\n",
- imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
- class_import_put(imp);
- mutex_unlock(&pinger_mutex);
- RETURN(0);
-}
-
-void ptlrpc_pinger_wake_up()
-{
-#ifdef ENABLE_PINGER
- /* XXX force pinger to run, if needed */
- struct obd_import *imp;
- ENTRY;
- list_for_each_entry(imp, &pinger_imports, imp_pinger_chain) {
- CDEBUG(D_RPCTRACE, "checking import %s->%s\n",
- imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
-#ifdef ENABLE_LIBLUSTRE_RECOVERY
- if (imp->imp_state == LUSTRE_IMP_DISCON &&
- !imp_is_deactive(imp))
-#else
- /*XXX only recover for the initial connection */
- if (!lustre_handle_is_used(&imp->imp_remote_handle) &&
- imp->imp_state == LUSTRE_IMP_DISCON &&
- !imp_is_deactive(imp))
-#endif
- ptlrpc_initiate_recovery(imp);
- else if (imp->imp_state != LUSTRE_IMP_FULL)
- CDEBUG(D_HA, "Refused to recover import %s->%s "
- "state %d, deactive %d\n",
- imp->imp_obd->obd_uuid.uuid,
- obd2cli_tgt(imp->imp_obd), imp->imp_state,
- imp_is_deactive(imp));
- }
- EXIT;
-#endif
-}
-#endif /* !__KERNEL__ */
void ptlrpc_pinger_commit_expected(struct obd_import *imp);
void ptlrpc_pinger_wake_up(void);
void ptlrpc_ping_import_soon(struct obd_import *imp);
-#ifdef __KERNEL__
int ping_evictor_wake(struct obd_export *exp);
-#else
-#define ping_evictor_wake(exp) 1
-#endif
/* sec_null.c */
int sptlrpc_null_init(void);
return (rc == -ENOTCONN || rc == -ENODEV);
}
-#if defined HAVE_SERVER_SUPPORT && defined(__KERNEL__)
+#ifdef HAVE_SERVER_SUPPORT
int tgt_mod_init(void);
void tgt_mod_exit(void);
-#else
+#else /* HAVE_SERVER_SUPPORT */
static inline int tgt_mod_init(void)
{
return 0;
{
return;
}
-#endif
+#endif /* !HAVE_SERVER_SUPPORT */
static inline void ptlrpc_reqset_put(struct ptlrpc_request_set *set)
{
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
return rc;
}
-#ifdef __KERNEL__
static void __exit ptlrpc_exit(void)
{
ptlrpc_nrs_fini();
MODULE_LICENSE("GPL");
cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
-#endif
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else /* __KERNEL__ */
-# include <liblustre.h>
-# include <ctype.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <lustre_net.h>
-# include <lustre_lib.h>
-
+#include <lustre_lib.h>
#include <lustre_ha.h>
#include <obd_class.h> /* for obd_zombie */
#include <obd_support.h> /* for OBD_FAIL_CHECK */
struct ptlrpcd_ctl pd_threads[0];
};
-#ifdef __KERNEL__
static int max_ptlrpcds;
CFS_MODULE_PARM(max_ptlrpcds, "i", int, 0644,
"Max ptlrpcd thread count to be started.");
static int ptlrpcd_bind_policy = PDB_POLICY_PAIR;
CFS_MODULE_PARM(ptlrpcd_bind_policy, "i", int, 0644,
"Ptlrpcd threads binding mode.");
-#endif
static struct ptlrpcd *ptlrpcds;
struct mutex ptlrpcd_mutex;
if (req != NULL && req->rq_send_state != LUSTRE_IMP_FULL)
return &ptlrpcds->pd_thread_rcv;
-#ifdef __KERNEL__
switch (policy) {
case PDL_POLICY_SAME:
idx = smp_processor_id() % ptlrpcds->pd_nthreads;
ptlrpcds->pd_index = idx;
break;
}
-#endif /* __KERNEL__ */
return &ptlrpcds->pd_threads[idx];
}
void ptlrpcd_add_rqset(struct ptlrpc_request_set *set)
{
struct list_head *tmp, *pos;
-#ifdef __KERNEL__
struct ptlrpcd_ctl *pc;
struct ptlrpc_request_set *new;
int count, i;
pc = ptlrpcd_select_pc(NULL, PDL_POLICY_LOCAL, -1);
new = pc->pc_set;
-#endif
list_for_each_safe(pos, tmp, &set->set_requests) {
struct ptlrpc_request *req =
rq_set_chain);
LASSERT(req->rq_phase == RQ_PHASE_NEW);
-#ifdef __KERNEL__
req->rq_set = new;
req->rq_queued_time = cfs_time_current();
-#else
- list_del_init(&req->rq_set_chain);
- req->rq_set = NULL;
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
- atomic_dec(&set->set_remaining);
-#endif
}
-#ifdef __KERNEL__
spin_lock(&new->set_new_req_lock);
list_splice_init(&set->set_requests, &new->set_new_requests);
i = atomic_read(&set->set_remaining);
for (i = 0; i < pc->pc_npartners; i++)
wake_up(&pc->pc_partners[i]->pc_set->set_waitq);
}
-#endif
}
EXPORT_SYMBOL(ptlrpcd_add_rqset);
-#ifdef __KERNEL__
/**
* Return transferred RPCs count.
*/
spin_unlock(&src->set_new_req_lock);
return rc;
}
-#endif
/**
* Requests that are added to the ptlrpcd queue are sent via
*/
rc = atomic_read(&set->set_new_count);
-#ifdef __KERNEL__
/* If we have nothing to do, check whether we can take some
* work from our partner threads. */
if (rc == 0 && pc->pc_npartners > 0) {
ptlrpc_reqset_put(ps);
} while (rc == 0 && pc->pc_cursor != first);
}
-#endif
}
RETURN(rc);
}
-#ifdef __KERNEL__
/**
* Main ptlrpcd thread.
* ptlrpc's code paths like to execute in process context, so we have this
RETURN(rc);
}
-#else /* !__KERNEL__ */
-
-/**
- * In liblustre we do not have separate threads, so this function
- * is called from time to time all across common code to see
- * if something needs to be processed on ptlrpcd set.
- */
-int ptlrpcd_check_async_rpcs(void *arg)
-{
- struct ptlrpcd_ctl *pc = arg;
- int rc = 0;
-
- /*
- * Single threaded!!
- */
- pc->pc_recurred++;
-
- if (pc->pc_recurred == 1) {
- rc = lu_env_refill(&pc->pc_env);
- if (rc == 0) {
- lu_context_enter(&pc->pc_env.le_ctx);
- rc = ptlrpcd_check(&pc->pc_env, pc);
- if (!rc)
- ptlrpc_expired_set(pc->pc_set);
- /*
- * XXX: send replay requests.
- */
- if (test_bit(LIOD_RECOVERY, &pc->pc_flags))
- rc = ptlrpcd_check(&pc->pc_env, pc);
- lu_context_exit(&pc->pc_env.le_ctx);
- }
- }
-
- pc->pc_recurred--;
- return rc;
-}
-
-int ptlrpcd_idle(void *arg)
-{
- struct ptlrpcd_ctl *pc = arg;
-
- return (atomic_read(&pc->pc_set->set_new_count) == 0 &&
- atomic_read(&pc->pc_set->set_remaining) == 0);
-}
-
-#endif
int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
{
if (pc->pc_set == NULL)
GOTO(out, rc = -ENOMEM);
-#ifndef __KERNEL__
- pc->pc_wait_callback =
- liblustre_register_wait_callback("ptlrpcd_check_async_rpcs",
- &ptlrpcd_check_async_rpcs, pc);
- pc->pc_idle_callback =
- liblustre_register_idle_callback("ptlrpcd_check_idle_rpcs",
- &ptlrpcd_idle, pc);
- RETURN(0);
-#else
/*
* So far only "client" ptlrpcd uses an environment. In the future,
* ptlrpcd thread (or a thread-set) has to be given an argument,
ptlrpc_set_destroy(set);
}
clear_bit(LIOD_BIND, &pc->pc_flags);
-#endif
out:
clear_bit(LIOD_START, &pc->pc_flags);
RETURN(rc);
goto out;
}
-#ifdef __KERNEL__
wait_for_completion(&pc->pc_finishing);
-#else
- liblustre_deregister_wait_callback(pc->pc_wait_callback);
- liblustre_deregister_idle_callback(pc->pc_idle_callback);
-#endif
lu_context_fini(&pc->pc_env.le_ctx);
spin_lock(&pc->pc_lock);
clear_bit(LIOD_BIND, &pc->pc_flags);
out:
-#ifdef __KERNEL__
if (pc->pc_npartners > 0) {
LASSERT(pc->pc_partners != NULL);
pc->pc_partners = NULL;
}
pc->pc_npartners = 0;
-#endif
EXIT;
}
int size, i = -1, j, rc = 0;
ENTRY;
-#ifdef __KERNEL__
if (max_ptlrpcds > 0 && max_ptlrpcds < nthreads)
nthreads = max_ptlrpcds;
if (nthreads < 2)
ptlrpcd_bind_policy = PDB_POLICY_PAIR;
else if (nthreads % 2 != 0 && ptlrpcd_bind_policy == PDB_POLICY_PAIR)
nthreads &= ~1; /* make sure it is even */
-#else
- nthreads = 1;
-#endif
size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
OBD_ALLOC(ptlrpcds, size);
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <lustre_ha.h>
#include <lustre_net.h>
#define DEBUG_SUBSYSTEM S_SEC
#include <libcfs/libcfs.h>
-#ifndef __KERNEL__
-#include <liblustre.h>
-#include <libcfs/list.h>
-#else
#include <linux/crypto.h>
#include <linux/key.h>
-#endif
#include <obd.h>
#include <obd_class.h>
{
int ngroups;
-#ifdef __KERNEL__
ngroups = current_ngroups;
if (ngroups > LUSTRE_MAX_GROUPS)
ngroups = LUSTRE_MAX_GROUPS;
-#else
- ngroups = 0;
-#endif
return sptlrpc_user_desc_size(ngroups);
}
EXPORT_SYMBOL(sptlrpc_current_user_desc_size);
pud->pud_cap = cfs_curproc_cap_pack();
pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;
-#ifdef __KERNEL__
task_lock(current);
if (pud->pud_ngroups > current_ngroups)
pud->pud_ngroups = current_ngroups;
memcpy(pud->pud_groups, current_cred()->group_info->blocks[0],
pud->pud_ngroups * sizeof(__u32));
task_unlock(current);
-#endif
return 0;
}
* bulk encryption page pools *
****************************************/
-#ifdef __KERNEL__
#define PTRS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *))
#define PAGES_PER_POOL (PTRS_PER_PAGE)
}
}
-#else /* !__KERNEL__ */
-
-int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc)
-{
- return 0;
-}
-
-void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
-{
-}
-
-int sptlrpc_enc_pool_init(void)
-{
- return 0;
-}
-
-void sptlrpc_enc_pool_fini(void)
-{
-}
-#endif
static int cfs_hash_alg_id[] = {
[BULK_HASH_ALG_NULL] = CFS_HASH_ALG_NULL,
hashsize = cfs_crypto_hash_digestsize(cfs_hash_alg_id[alg]);
for (i = 0; i < desc->bd_iov_count; i++) {
-#ifdef __KERNEL__
cfs_crypto_hash_update_page(hdesc, desc->bd_iov[i].kiov_page,
desc->bd_iov[i].kiov_offset & ~CFS_PAGE_MASK,
desc->bd_iov[i].kiov_len);
-#else
- cfs_crypto_hash_update(hdesc, desc->bd_iov[i].iov_base,
- desc->bd_iov[i].iov_len);
-#endif
}
if (hashsize > buflen) {
#define DEBUG_SUBSYSTEM S_SEC
#include <libcfs/libcfs.h>
-#ifndef __KERNEL__
-#include <liblustre.h>
-#include <libcfs/list.h>
-#else
#include <linux/crypto.h>
#include <linux/key.h>
-#endif
#include <obd.h>
#include <obd_class.h>
}
EXPORT_SYMBOL(sptlrpc_conf_client_adapt);
-#ifdef __KERNEL__
static void rule2string(struct sptlrpc_rule *r, char *buf, int buflen)
{
RETURN(rc);
}
-#endif /* __KRENEL__ */
/**
* called by target devices, extract sptlrpc rules which applies to
GOTO(out, rc);
}
-#ifdef __KERNEL__
if (conf->sc_updated == 0) {
/*
* always read from local copy. here another option is
else
CDEBUG(D_SEC, "unchanged, skip updating local copy\n");
}
-#endif
/* extract rule set for this target */
conf_tgt = sptlrpc_conf_get_tgt(conf, obd->obd_name, 0);
*
* GPL HEADER END
*/
-#ifdef __KERNEL__
#define DEBUG_SUBSYSTEM S_FILTER
dput(dchild_old);
RETURN(err);
}
-#endif /* __KERNEL__ */
#define DEBUG_SUBSYSTEM S_SEC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#else
#include <libcfs/libcfs.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#define SEC_GC_INTERVAL (30 * 60)
-#ifdef __KERNEL__
static struct mutex sec_gc_mutex;
static spinlock_t sec_gc_list_lock;
thread_is_stopped(&sec_gc_thread), &lwi);
}
-#else /* !__KERNEL__ */
-
-void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec)
-{
-}
-void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
-{
-}
-int sptlrpc_gc_init(void)
-{
- return 0;
-}
-void sptlrpc_gc_fini(void)
-{
-}
-
-#endif /* __KERNEL__ */
#define DEBUG_SUBSYSTEM S_SEC
#include <libcfs/libcfs.h>
-#ifndef __KERNEL__
-#include <liblustre.h>
-#include <libcfs/list.h>
-#else
#include <linux/crypto.h>
-#endif
#include <obd.h>
#include <obd_class.h>
#include "ptlrpc_internal.h"
-#ifdef __KERNEL__
struct proc_dir_entry *sptlrpc_proc_root = NULL;
EXPORT_SYMBOL(sptlrpc_proc_root);
}
}
-#else /* !__KERNEL__ */
-
-int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
-{
- return 0;
-}
-
-int sptlrpc_lproc_init(void)
-{
- return 0;
-}
-
-void sptlrpc_lproc_fini(void)
-{
-}
-
-#endif
#define DEBUG_SUBSYSTEM S_SEC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_cksum.h>
#define DEBUG_SUBSYSTEM S_SEC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_cksum.h>
return 0;
}
-#ifdef __KERNEL__
static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
{
char *ptr;
return;
}
}
-#else
-static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
-{
- unsigned int i;
-
- for (i = 0; i < desc->bd_iov_count; i++) {
- if (desc->bd_iov[i].iov_len == 0)
- continue;
-
- ((char *)desc->bd_iov[i].iov_base)[i] ^= 0x1;
- return;
- }
-}
-#endif /* __KERNEL__ */
/****************************************
* cli_ctx apis *
struct ptlrpc_bulk_sec_desc *bsdv;
struct plain_bulk_token *tokenv;
int rc;
-#ifdef __KERNEL__
int i, nob;
-#endif
LASSERT(req->rq_pack_bulk);
LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS);
return 0;
}
-#ifdef __KERNEL__
/* fix the actual data size */
for (i = 0, nob = 0; i < desc->bd_iov_count; i++) {
if (desc->bd_iov[i].kiov_len + nob > desc->bd_nob_transferred) {
}
nob += desc->bd_iov[i].kiov_len;
}
-#endif
rc = plain_verify_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg,
tokenv);
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
}
EXPORT_SYMBOL(ptlrpc_save_lock);
-#ifdef __KERNEL__
struct ptlrpc_hr_partition;
#define DECLARE_RS_BATCH(b) struct rs_batch b
-#else /* __KERNEL__ */
-
-#define rs_batch_init(b) do{}while(0)
-#define rs_batch_fini(b) do{}while(0)
-#define rs_batch_add(b, r) ptlrpc_schedule_difficult_reply(r)
-#define DECLARE_RS_BATCH(b)
-
-#endif /* __KERNEL__ */
/**
* Put reply state into a queue for processing because we received
*/
void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs)
{
-#ifdef __KERNEL__
struct ptlrpc_hr_thread *hrt;
ENTRY;
wake_up(&hrt->hrt_waitq);
EXIT;
-#else
- list_add_tail(&rs->rs_list, &rs->rs_svcpt->scp_rep_queue);
-#endif
}
void
ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
struct ptlrpc_service_conf *conf)
{
-#ifdef __KERNEL__
struct ptlrpc_service_thr_conf *tc = &conf->psc_thr;
unsigned init;
unsigned total;
svc->srv_name, nthrs * svc->srv_ncpts,
tc->tc_nthrs_max);
}
-#endif
}
/**
/* reply states */
spin_lock_init(&svcpt->scp_rep_lock);
INIT_LIST_HEAD(&svcpt->scp_rep_active);
-#ifndef __KERNEL__
- INIT_LIST_HEAD(&svcpt->scp_rep_queue);
-#endif
INIT_LIST_HEAD(&svcpt->scp_rep_idle);
init_waitqueue_head(&svcpt->scp_rep_waitq);
atomic_set(&svcpt->scp_nreps_difficult, 0);
CDEBUG(D_NET, "%s: Started, listening on portal %d\n",
service->srv_name, service->srv_req_portal);
-#ifdef __KERNEL__
rc = ptlrpc_start_threads(service);
if (rc != 0) {
CERROR("Failed to start threads for service %s: %d\n",
service->srv_name, rc);
GOTO(failed, rc);
}
-#endif
RETURN(service);
failed:
bool force)
{
int running = svcpt->scp_nthrs_running;
-#ifndef __KERNEL__
- if (1) /* always allow to handle normal request for liblustre */
- return true;
-#endif
if (unlikely(svcpt->scp_service->srv_req_portal == MDS_REQUEST_PORTAL &&
CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) {
/* leave just 1 thread for normal RPCs */
ENTRY;
spin_lock(&svcpt->scp_req_lock);
-#ifndef __KERNEL__
- /* !@%$# liblustre only has 1 thread */
- if (atomic_read(&svcpt->scp_nreps_difficult) != 0) {
- spin_unlock(&svcpt->scp_req_lock);
- RETURN(NULL);
- }
-#endif
if (ptlrpc_server_high_pending(svcpt, force)) {
req = ptlrpc_nrs_req_get_nolock(svcpt, true, force);
RETURN(1);
}
-#ifndef __KERNEL__
-
-/**
- * Check whether given service has a reply available for processing
- * and process it.
- *
- * \param svc a ptlrpc service
- * \retval 0 no replies processed
- * \retval 1 one reply processed
- */
-static int
-ptlrpc_server_handle_reply(struct ptlrpc_service_part *svcpt)
-{
- struct ptlrpc_reply_state *rs = NULL;
- ENTRY;
-
- spin_lock(&svcpt->scp_rep_lock);
- if (!list_empty(&svcpt->scp_rep_queue)) {
- rs = list_entry(svcpt->scp_rep_queue.prev,
- struct ptlrpc_reply_state,
- rs_list);
- list_del_init(&rs->rs_list);
- }
- spin_unlock(&svcpt->scp_rep_lock);
- if (rs != NULL)
- ptlrpc_handle_rs(rs);
- RETURN(rs != NULL);
-}
-
-/* FIXME make use of timeout later */
-int
-liblustre_check_services (void *arg)
-{
- int did_something = 0;
- int rc;
- struct list_head *tmp, *nxt;
- ENTRY;
-
- /* I'm relying on being single threaded, not to have to lock
- * ptlrpc_all_services etc */
- list_for_each_safe(tmp, nxt, &ptlrpc_all_services) {
- struct ptlrpc_service *svc =
- list_entry(tmp, struct ptlrpc_service, srv_list);
- struct ptlrpc_service_part *svcpt;
-
- LASSERT(svc->srv_ncpts == 1);
- svcpt = svc->srv_parts[0];
-
- if (svcpt->scp_nthrs_running != 0) /* I've recursed */
- continue;
-
- /* service threads can block for bulk, so this limits us
- * (arbitrarily) to recursing 1 stack frame per service.
- * Note that the problem with recursion is that we have to
- * unwind completely before our caller can resume. */
-
- svcpt->scp_nthrs_running++;
-
- do {
- rc = ptlrpc_server_handle_req_in(svcpt, NULL);
- rc |= ptlrpc_server_handle_reply(svcpt);
- rc |= ptlrpc_at_check_timed(svcpt);
- rc |= ptlrpc_server_handle_request(svcpt, NULL);
- rc |= (ptlrpc_server_post_idle_rqbds(svcpt) > 0);
- did_something |= rc;
- } while (rc);
-
- svcpt->scp_nthrs_running--;
- }
-
- RETURN(did_something);
-}
-#define ptlrpc_stop_all_threads(s) do {} while (0)
-
-#else /* __KERNEL__ */
static void
ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt)
struct ptlrpc_service_part *svcpt = thread->t_svcpt;
struct ptlrpc_service *svc = svcpt->scp_service;
struct ptlrpc_reply_state *rs;
-#ifdef WITH_GROUP_INFO
struct group_info *ginfo = NULL;
-#endif
struct lu_env *env;
int counter = 0, rc = 0;
ENTRY;
svc->srv_name, thread->t_name, svcpt->scp_cpt);
}
-#ifdef WITH_GROUP_INFO
ginfo = groups_alloc(0);
if (!ginfo) {
rc = -ENOMEM;
set_current_groups(ginfo);
put_group_info(ginfo);
-#endif
if (svc->srv_ops.so_thr_init != NULL) {
rc = svc->srv_ops.so_thr_init(thread);
ptlrpc_hr.hr_partitions = NULL;
}
-#endif /* __KERNEL__ */
/**
* Wait until all already scheduled replies are processed.
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
-#ifdef __KERNEL__
-# ifdef CONFIG_FS_POSIX_ACL
-# include <linux/fs.h>
-# include <linux/posix_acl_xattr.h>
-# endif
-#endif
+#ifdef CONFIG_FS_POSIX_ACL
+# include <linux/fs.h>
+# include <linux/posix_acl_xattr.h>
+#endif /* CONFIG_FS_POSIX_ACL */
#include <obd_support.h>
#include <obd_class.h>
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifndef __KERNEL__
-# include <liblustre.h>
-#endif
-#ifdef __KERNEL__
-# ifdef CONFIG_FS_POSIX_ACL
-# include <linux/fs.h>
-# include <linux/posix_acl_xattr.h>
-# endif
-#endif
+#ifdef CONFIG_FS_POSIX_ACL
+# include <linux/fs.h>
+# include <linux/posix_acl_xattr.h>
+#endif /* CONFIG_FS_POSIX_ACL */
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
#include <lustre/lustre_lfsck_user.h>
#include <lustre_disk.h>
-
void lustre_assert_wire_constants(void)
{
/* Wire protocol assertions generated by 'wirecheck'
* (make -C lustre/utils newwiretest)
- * running on Linux t 2.6.32-358.18.1.el6.lustre.x86_64 #1 SMP Mon Sep 2 15:21:03 CDT 2013 x8
- * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) */
+ * running on Linux t 2.6.32-431.5.1.el6.lustre.x86_64 #1 SMP Wed Feb 12 11:01:08 CST 2014 x8
+ * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) */
/* Constants... */
# include <linux/fiemap.h>
#endif
-#ifdef __linux__
-# ifndef FS_IOC_FIEMAP
-# define FS_IOC_FIEMAP (_IOWR('f', 11, struct fiemap))
-# endif
+#ifndef FS_IOC_FIEMAP
+# define FS_IOC_FIEMAP (_IOWR('f', 11, struct fiemap))
#endif
#define ONEMB 1048576
#include <limits.h>
#include <ctype.h>
-#ifdef __linux__
/* libcfs.h is not really needed here, but on SLES10/PPC, fs.h includes idr.h
* which requires BITS_PER_LONG to be defined */
#include <libcfs/libcfs.h>
#include <linux/fs.h> /* for BLKGETSIZE64 */
#endif
#include <linux/version.h>
-#endif
#include <lustre_disk.h>
#include <lustre_param.h>
#include <lnet/lnetctl.h>
{
/* Wire protocol assertions generated by 'wirecheck'
* (make -C lustre/utils newwiretest)
- * running on Linux t 2.6.32-358.18.1.el6.lustre.x86_64 #1 SMP Mon Sep 2 15:21:03 CDT 2013 x8
- * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) */
+ * running on Linux t 2.6.32-431.5.1.el6.lustre.x86_64 #1 SMP Wed Feb 12 11:01:08 CST 2014 x8
+ * with gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) */
/* Constants... */
*/
#include <sys/types.h>
-#if defined (__linux__)
#include <sys/vfs.h>
-#endif
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
*/
#include <sys/types.h>
-#if defined (__linux__)
#include <sys/vfs.h>
-#endif
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>