Whamcloud - gitweb
LU-6245 libcfs: remove prim wrappers for libcfs 74/13874/8
authorJames Simmons <uja.ornl@gmail.com>
Fri, 10 Apr 2015 14:09:57 +0000 (10:09 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 28 Apr 2015 05:17:01 +0000 (05:17 +0000)
The libcfs layer contains wrappers to handle primitive
management for both kernel space and user land. Since
libcfs is no longer built for user land we can remove
the wrappers. For linux-prim.h we kept only what is
needed to deal with different kernel versions. Also
we separated out libcfs_string.h to util/string.h so
we can remove the wrappers no longer needed.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I0bad836f20ef29bf2ed17f1f4e5e1234d193868e
Reviewed-on: http://review.whamcloud.com/13874
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
117 files changed:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/linux/Makefile.am
libcfs/include/libcfs/linux/libcfs.h
libcfs/include/libcfs/linux/linux-prim.h [deleted file]
libcfs/include/libcfs/user-prim.h [deleted file]
libcfs/libcfs/debug.c
libcfs/libcfs/fail.c
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/module.c
libcfs/libcfs/prng.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/watchdog.c
libcfs/libcfs/workitem.c
lnet/include/lnet/lib-types.h
lnet/klnds/gnilnd/gnilnd.c
lnet/klnds/gnilnd/gnilnd_stack.c
lnet/klnds/gnilnd/gnilnd_sysctl.c
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/acceptor.c
lnet/lnet/api-ni.c
lnet/lnet/lib-eq.c
lnet/lnet/module.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/selftest/conrpc.c
lnet/selftest/module.c
lnet/selftest/rpc.c
lnet/selftest/selftest.h
lustre/autoconf/lustre-core.m4
lustre/fid/fid_request.c
lustre/fld/fld_request.c
lustre/include/lustre_cfg.h
lustre/include/lustre_lib.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_pool.c
lustre/ldlm/ldlm_resource.c
lustre/lfsck/lfsck_lib.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/lcommon_cl.c
lustre/llite/llite_capa.c
lustre/llite/llite_lib.c
lustre/llite/lloop.c
lustre/llite/lproc_llite.c
lustre/llite/namei.c
lustre/llite/remote_perm.c
lustre/llite/statahead.c
lustre/llite/vvp_object.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_device.c
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_idmap.c
lustre/mdt/mdt_lib.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_nids.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/idmap.c
lustre/obdclass/llog.c
lustre/obdclass/lu_object.c
lustre/obdclass/obdo.c
lustre/obdclass/upcall_cache.c
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_io.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_scrub.c
lustre/osd-zfs/osd_handler.c
lustre/osp/osp_dev.c
lustre/osp/osp_precreate.c
lustre/osp/osp_sync.c
lustre/ptlrpc/client.c
lustre/ptlrpc/gss/gss_svc_upcall.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpc_module.c
lustre/ptlrpc/ptlrpcd.c
lustre/ptlrpc/sec.c
lustre/ptlrpc/sec_bulk.c
lustre/ptlrpc/sec_gc.c
lustre/ptlrpc/service.c
lustre/quota/lquota_entry.c
lustre/quota/lquota_lib.c
lustre/quota/qmt_lock.c
lustre/quota/qsd_lib.c
lustre/quota/qsd_reint.c
lustre/quota/qsd_writeback.c
lustre/target/tgt_handler.c
lustre/tests/it_test.c
lustre/utils/gss/gssd.c
lustre/utils/gss/lgss_keyring.c
lustre/utils/l_getidentity.c
lustre/utils/lfs.c
lustre/utils/lhsmtool_posix.c
lustre/utils/libiam.c
lustre/utils/liblustreapi_json.c
lustre/utils/lustre_cfg.c
lustre/utils/lustre_rsync.c
lustre/utils/mount_lustre.c
lustre/utils/mount_utils.c
lustre/utils/obd.c
lustre/utils/req-layout.c

index b6a796b..8b11794 100644 (file)
@@ -121,25 +121,6 @@ ctl_table_ctl_name, [
 ]) # LIBCFS_SYSCTL_CTLNAME
 
 #
-# LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
-#
-# 2.6.34 adds __add_wait_queue_exclusive
-#
-AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE], [
-LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
-__add_wait_queue_exclusive, [
-       #include <linux/wait.h>
-],[
-       wait_queue_head_t queue;
-       wait_queue_t      wait;
-       __add_wait_queue_exclusive(&queue, &wait);
-],[
-       AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
-               [__add_wait_queue_exclusive exists])
-])
-]) # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
-
-#
 # LC_SK_SLEEP
 #
 # 2.6.35 kernel has sk_sleep function
@@ -315,8 +296,6 @@ LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
 LC_SHRINKER_WANT_SHRINK_PTR
 # 2.6.33
 LIBCFS_SYSCTL_CTLNAME
-# 2.6.34
-LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
 # 2.6.35
 LC_SK_SLEEP
 # 2.6.39
index cfab062..ac5d2a0 100644 (file)
@@ -29,5 +29,4 @@ EXTRA_DIST = \
        types.h \
        user-bitops.h \
        user-crypto.h \
-       user-prim.h \
        user-time.h
index 55c0eaa..70be5ca 100644 (file)
@@ -63,7 +63,6 @@
 # include <sys/time.h>
 # include <sys/types.h>
 # include <libcfs/user-time.h>
-# include <libcfs/user-prim.h>
 # include <libcfs/user-bitops.h>
 #endif /* __KERNEL__ */
 
@@ -127,10 +126,6 @@ static inline int __is_po2(unsigned long long val)
 
 #ifdef __KERNEL__
 
-#ifndef cfs_for_each_possible_cpu
-#  error cfs_for_each_possible_cpu is not supported by kernel!
-#endif
-
 /* libcfs watchdogs */
 struct lc_watchdog;
 
@@ -201,7 +196,6 @@ sigset_t cfs_block_allsigs(void);
 sigset_t cfs_block_sigs(unsigned long sigs);
 sigset_t cfs_block_sigsinv(unsigned long sigs);
 void cfs_restore_sigs(sigset_t);
-int cfs_signal_pending(void);
 void cfs_clear_sigpending(void);
 
 int convert_server_error(__u64 ecode);
@@ -254,9 +248,9 @@ void cfs_get_random_bytes(void *buf, int size);
 #include <libcfs/libcfs_workitem.h>
 #ifdef __KERNEL__
 # include <libcfs/libcfs_hash.h>
+# include <libcfs/libcfs_heap.h>
+# include <libcfs/libcfs_fail.h>
 #endif /* __KERNEL__ */
-#include <libcfs/libcfs_heap.h>
-#include <libcfs/libcfs_fail.h>
 
 /* container_of depends on "likely" which is defined in libcfs_private.h */
 static inline void *__container_of(const void *ptr, unsigned long shift)
@@ -270,6 +264,4 @@ static inline void *__container_of(const void *ptr, unsigned long shift)
 #define container_of0(ptr, type, member)                               \
        ((type *)__container_of((ptr), offsetof(type, member)))
 
-#define _LIBCFS_H
-
-#endif /* _LIBCFS_H */
+#endif /* _LIBCFS_LIBCFS_H_ */
index d885f97..b1aa817 100644 (file)
@@ -1,2 +1,2 @@
-EXTRA_DIST = kp30.h libcfs.h linux-fs.h linux-mem.h    \
-       linux-prim.h linux-time.h linux-cpu.h linux-crypto.h
+EXTRA_DIST = kp30.h libcfs.h linux-fs.h linux-mem.h linux-time.h linux-cpu.h \
+            linux-crypto.h
index b154471..162f86b 100644 (file)
@@ -50,7 +50,6 @@
 #include <libcfs/linux/linux-cpu.h>
 #include <libcfs/linux/linux-time.h>
 #include <libcfs/linux/linux-mem.h>
-#include <libcfs/linux/linux-prim.h>
 #include <libcfs/linux/linux-fs.h>
 #include <libcfs/linux/kp30.h>
 
diff --git a/libcfs/include/libcfs/linux/linux-prim.h b/libcfs/include/libcfs/linux/linux-prim.h
deleted file mode 100644 (file)
index cb679ca..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-prim.h
- *
- * Basic library routines.
- */
-
-#ifndef __LIBCFS_LINUX_CFS_PRIM_H__
-#define __LIBCFS_LINUX_CFS_PRIM_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifndef __KERNEL__
-#error This include is only for kernel use.
-#endif
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <linux/proc_fs.h>
-#include <linux/mm.h>
-#include <linux/timer.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#ifdef HAVE_LINUX_RANDOM_H
-#include <linux/random.h>
-#endif
-#ifdef HAVE_UIDGID_HEADER
-#include <linux/uidgid.h>
-#endif
-#include <linux/user_namespace.h>
-#include <linux/miscdevice.h>
-#include <asm/div64.h>
-
-#include <libcfs/linux/linux-time.h>
-
-
-/*
- * CPU
- */
-#ifdef for_each_possible_cpu
-#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
-#elif defined(for_each_cpu)
-#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu)
-#endif
-
-#ifndef NR_CPUS
-#define NR_CPUS                                1
-#endif
-
-/*
- * Wait Queue
- */
-
-
-#define CFS_DECL_WAITQ(wq)             DECLARE_WAIT_QUEUE_HEAD(wq)
-
-#define LIBCFS_WQITQ_MACROS           1
-#define init_waitqueue_entry_current(w)          init_waitqueue_entry(w, current)
-#define waitq_wait(w, s)          schedule()
-#define waitq_timedwait(w, s, t)  schedule_timeout(t)
-
-#ifndef HAVE___ADD_WAIT_QUEUE_EXCLUSIVE
-static inline void __add_wait_queue_exclusive(wait_queue_head_t *q,
-                                             wait_queue_t *wait)
-{
-       wait->flags |= WQ_FLAG_EXCLUSIVE;
-       __add_wait_queue(q, wait);
-}
-#endif /* HAVE___ADD_WAIT_QUEUE_EXCLUSIVE */
-
-/**
- * wait_queue_t of Linux (version < 2.6.34) is a FIFO list for exclusively
- * waiting threads, which is not always desirable because all threads will
- * be waken up again and again, even user only needs a few of them to be
- * active most time. This is not good for performance because cache can
- * be polluted by different threads.
- *
- * LIFO list can resolve this problem because we always wakeup the most
- * recent active thread by default.
- *
- * NB: please don't call non-exclusive & exclusive wait on the same
- * waitq if add_wait_queue_exclusive_head is used.
- */
-#define add_wait_queue_exclusive_head(waitq, link)                     \
-{                                                                      \
-       unsigned long flags;                                            \
-                                                                       \
-       spin_lock_irqsave(&((waitq)->lock), flags);                     \
-       __add_wait_queue_exclusive(waitq, link);                        \
-       spin_unlock_irqrestore(&((waitq)->lock), flags);                \
-}
-
-#define schedule_timeout_and_set_state(state, timeout)                 \
-{                                                                      \
-       set_current_state(state);                                       \
-       schedule_timeout(timeout);                                      \
-}
-
-/* deschedule for a bit... */
-#define cfs_pause(ticks)                                               \
-{                                                                      \
-       set_current_state(TASK_UNINTERRUPTIBLE);                        \
-       schedule_timeout(ticks);                                        \
-}
-
-#define DECL_JOURNAL_DATA           void *journal_info
-#define PUSH_JOURNAL                do {    \
-        journal_info = current->journal_info;   \
-        current->journal_info = NULL;           \
-        } while(0)
-#define POP_JOURNAL                 do {    \
-        current->journal_info = journal_info;   \
-        } while(0)
-
-/* Module interfaces */
-#define cfs_module(name, version, init, fini) \
-        module_init(init);                    \
-        module_exit(fini)
-
-#endif
diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h
deleted file mode 100644 (file)
index 1752694..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, 2014, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/user-prim.h
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_USER_PRIM_H__
-#define __LIBCFS_USER_PRIM_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-/* Implementations of portable APIs for liblustre */
-
-/*
- * liblustre is single-threaded, so most "synchronization" APIs are trivial.
- */
-
-#ifndef EXPORT_SYMBOL
-# define EXPORT_SYMBOL(s)
-#endif
-
-/*
- * Just present a single processor until will add thread support.
- */
-#ifndef smp_processor_id
-# define smp_processor_id() 0
-#endif
-#ifndef num_online_cpus
-# define num_online_cpus() 1
-#endif
-#ifndef num_possible_cpus
-# define num_possible_cpus() 1
-#endif
-#ifndef get_cpu
-# define get_cpu() 0
-#endif
-#ifndef put_cpu
-# define put_cpu() do {} while (0)
-#endif
-#ifndef NR_CPUS
-# define NR_CPUS 1
-#endif
-#ifndef for_each_possible_cpu
-# define for_each_possible_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++)
-#endif
-
-/*
- * Wait Queue.
- */
-
-typedef struct cfs_waitlink {
-       struct list_head sleeping;
-       void *process;
-} wait_queue_t;
-
-typedef struct cfs_waitq {
-       struct list_head sleepers;
-} wait_queue_head_t;
-
-#define CFS_DECL_WAITQ(wq) wait_queue_head_t wq
-void init_waitqueue_head(struct cfs_waitq *waitq);
-void init_waitqueue_entry_current(struct cfs_waitlink *link);
-void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void add_wait_queue_exclusive(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void add_wait_queue_exclusive_head(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void remove_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-int waitqueue_active(struct cfs_waitq *waitq);
-void wake_up(struct cfs_waitq *waitq);
-void wake_up_nr(struct cfs_waitq *waitq, int nr);
-void wake_up_all(struct cfs_waitq *waitq);
-void waitq_wait(struct cfs_waitlink *link, long state);
-int64_t waitq_timedwait(struct cfs_waitlink *link, long state, int64_t timeout);
-void schedule_timeout_and_set_state(long state, int64_t timeout);
-void cfs_pause(cfs_duration_t d);
-int need_resched(void);
-void cond_resched(void);
-
-/*
- * Task states
- */
-#define TASK_INTERRUPTIBLE  (0)
-#define TASK_UNINTERRUPTIBLE          (1)
-#define TASK_RUNNING        (2)
-
-static inline void schedule(void)                      {}
-static inline void schedule_timeout(int64_t t) {}
-static inline void set_current_state(int state)
-{
-}
-
-/*
- * Lproc
- */
-typedef int (read_proc_t)(char *page, char **start, off_t off,
-                               int count, int *eof, void *data);
-
-struct file; /* forward ref */
-typedef int (write_proc_t)(struct file *file, const char *buffer,
-                               unsigned long count, void *data);
-
-/*
- * Signal
- */
-
-/*
- * Timer
- */
-
-struct timer_list {
-       struct list_head tl_list;
-       void (*function)(ulong_ptr_t unused);
-       ulong_ptr_t data;
-       long expires;
-};
-
-
-#define in_interrupt()    (0)
-
-struct miscdevice{
-};
-
-static inline int misc_register(struct miscdevice *foo)
-{
-       return 0;
-}
-
-static inline int misc_deregister(struct miscdevice *foo)
-{
-       return 0;
-}
-
-#define cfs_recalc_sigpending(l)        do {} while (0)
-
-#define DAEMON_FLAGS                0
-
-#define L1_CACHE_ALIGN(x)              (x)
-
-#ifdef HAVE_LIBPTHREAD
-typedef int (*cfs_thread_t)(void *);
-void *kthread_run(cfs_thread_t func, void *arg, const char namefmt[], ...);
-#else
-/* Fine, crash, but stop giving me compile warnings */
-#define kthread_run(f, a, n, ...) LBUG()
-#endif
-
-uid_t current_uid(void);
-gid_t current_gid(void);
-uid_t current_fsuid(void);
-gid_t current_fsgid(void);
-
-#ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcpy(char *tgt, const char *src, size_t tgt_len);
-#endif
-
-#ifndef HAVE_STRLCAT /* not in glibc for RHEL 5.x, remove when obsolete */
-size_t strlcat(char *tgt, const char *src, size_t tgt_len);
-#endif
-
-#define LIBCFS_REALLOC(ptr, size) realloc(ptr, size)
-
-#define cfs_online_cpus() sysconf(_SC_NPROCESSORS_ONLN)
-
-// static inline void local_irq_save(unsigned long flag) {return;}
-// static inline void local_irq_restore(unsigned long flag) {return;}
-
-enum {
-        CFS_STACK_TRACE_DEPTH = 16
-};
-
-struct cfs_stack_trace {
-        void *frame[CFS_STACK_TRACE_DEPTH];
-};
-
-/*
- * arithmetic
- */
-#ifndef do_div /* gcc only, platform-specific will override */
-#define do_div(a,b)                     \
-        ({                              \
-                unsigned long remainder;\
-                remainder = (a) % (b);  \
-                (a) = (a) / (b);        \
-                (remainder);            \
-        })
-#endif
-
-/*
- * Groups
- */
-struct group_info{ };
-
-#ifndef min
-# define min(x,y) ((x)<(y) ? (x) : (y))
-#endif
-
-#ifndef max
-# define max(x,y) ((x)>(y) ? (x) : (y))
-#endif
-
-#define get_random_bytes(val, size)     (*val) = 0
-
-#endif /* __LIBCFS_USER_PRIM_H__ */
index 7b01e6f..c166aac 100644 (file)
@@ -41,6 +41,7 @@
 
 # define DEBUG_SUBSYSTEM S_LNET
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include "tracefile.h"
 
@@ -231,9 +232,10 @@ void libcfs_debug_dumplog_internal(void *arg)
 {
        static time_t last_dump_time;
        time_t current_time;
-       DECL_JOURNAL_DATA;
+       void *journal_info;
 
-       PUSH_JOURNAL;
+       journal_info = current->journal_info;
+       current->journal_info = NULL;
 
        current_time = cfs_time_current_sec();
 
@@ -248,7 +250,7 @@ void libcfs_debug_dumplog_internal(void *arg)
                cfs_tracefile_dump_all_pages(debug_file_name);
                libcfs_run_debug_log_upcall(debug_file_name);
        }
-       POP_JOURNAL;
+       current->journal_info = journal_info;
 }
 
 static int libcfs_debug_dumplog_thread(void *arg)
@@ -267,7 +269,7 @@ void libcfs_debug_dumplog(void)
        /* we're being careful to ensure that the kernel thread is
         * able to set our state to running as it exits before we
         * get to schedule() */
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
        set_current_state(TASK_INTERRUPTIBLE);
        add_wait_queue(&debug_ctlwq, &wait);
 
@@ -278,7 +280,7 @@ void libcfs_debug_dumplog(void)
                printk(KERN_ERR "LustreError: cannot start log dump thread:"
                       " %ld\n", PTR_ERR(dumper));
        else
-               waitq_wait(&wait, TASK_INTERRUPTIBLE);
+               schedule();
 
        /* be sure to teardown if cfs_create_thread() failed */
        remove_wait_queue(&debug_ctlwq, &wait);
index 01bd133..a5542c7 100644 (file)
@@ -130,8 +130,8 @@ int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
        if (ret && likely(ms > 0)) {
                CERROR("cfs_fail_timeout id %x sleeping for %dms\n",
                       id, ms);
-               schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                                                  cfs_time_seconds(ms) / 1000);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(ms) / 1000);
                set_current_state(TASK_RUNNING);
                CERROR("cfs_fail_timeout id %x awake\n", id);
        }
index 0a617df..072f679 100644 (file)
@@ -98,6 +98,7 @@ void cfs_enter_debugger(void)
         /* nothing */
 #endif
 }
+EXPORT_SYMBOL(cfs_enter_debugger);
 
 sigset_t
 cfs_block_allsigs(void)
@@ -112,6 +113,7 @@ cfs_block_allsigs(void)
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
        return old;
 }
+EXPORT_SYMBOL(cfs_block_allsigs);
 
 sigset_t cfs_block_sigs(unsigned long sigs)
 {
@@ -125,6 +127,7 @@ sigset_t cfs_block_sigs(unsigned long sigs)
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
        return old;
 }
+EXPORT_SYMBOL(cfs_block_sigs);
 
 /* Block all signals except for the @sigs */
 sigset_t cfs_block_sigsinv(unsigned long sigs)
@@ -139,6 +142,7 @@ sigset_t cfs_block_sigsinv(unsigned long sigs)
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
        return old;
 }
+EXPORT_SYMBOL(cfs_block_sigsinv);
 
 void
 cfs_restore_sigs(sigset_t old)
@@ -150,12 +154,7 @@ cfs_restore_sigs(sigset_t old)
        recalc_sigpending();
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
 }
-
-int
-cfs_signal_pending(void)
-{
-       return signal_pending(current);
-}
+EXPORT_SYMBOL(cfs_restore_sigs);
 
 void
 cfs_clear_sigpending(void)
@@ -166,11 +165,4 @@ cfs_clear_sigpending(void)
        clear_tsk_thread_flag(current, TIF_SIGPENDING);
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
 }
-
-EXPORT_SYMBOL(cfs_enter_debugger);
-EXPORT_SYMBOL(cfs_block_allsigs);
-EXPORT_SYMBOL(cfs_block_sigs);
-EXPORT_SYMBOL(cfs_block_sigsinv);
-EXPORT_SYMBOL(cfs_restore_sigs);
-EXPORT_SYMBOL(cfs_signal_pending);
 EXPORT_SYMBOL(cfs_clear_sigpending);
index a00679c..449b885 100644 (file)
@@ -118,7 +118,7 @@ kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
        while (ldu->ldu_memhog_pages < npages &&
               count1 < PAGE_CACHE_SIZE/sizeof(struct page *)) {
 
-               if (cfs_signal_pending())
+               if (signal_pending(current))
                        return -EINTR;
 
                *level1p = alloc_page(flags);
@@ -133,7 +133,7 @@ kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
                while (ldu->ldu_memhog_pages < npages &&
                       count2 < PAGE_CACHE_SIZE/sizeof(struct page *)) {
 
-                       if (cfs_signal_pending())
+                       if (signal_pending(current))
                                return -EINTR;
 
                        *level2p = alloc_page(flags);
@@ -310,10 +310,6 @@ struct cfs_psdev_ops libcfs_psdev_ops = {
         libcfs_ioctl
 };
 
-MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Portals v3.1");
-MODULE_LICENSE("GPL");
-
 static int init_libcfs_module(void)
 {
        int rc;
@@ -410,4 +406,10 @@ static void exit_libcfs_module(void)
                       rc);
 }
 
-cfs_module(libcfs, "1.0.0", init_libcfs_module, exit_libcfs_module);
+MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
+MODULE_DESCRIPTION("Libcfs v3.1");
+MODULE_VERSION("1.0.0");
+MODULE_LICENSE("GPL");
+
+module_init(init_libcfs_module);
+module_exit(exit_libcfs_module);
index 1daf29d..8945c4c 100644 (file)
@@ -39,6 +39,7 @@
  * algorithm recommended by Marsaglia
 */
 
+#include <linux/random.h>
 #include <libcfs/libcfs.h>
 
 /*
index 4f6571d..2daf3da 100644 (file)
@@ -44,6 +44,7 @@
 #define LUSTRE_TRACEFILE_PRIVATE
 #include "tracefile.h"
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 
 /* XXX move things up to the top, comment */
@@ -1049,11 +1050,10 @@ end_loop:
                                break;
                        }
                }
-               init_waitqueue_entry_current(&__wait);
+               init_waitqueue_entry(&__wait, current);
                add_wait_queue(&tctl->tctl_waitq, &__wait);
                set_current_state(TASK_INTERRUPTIBLE);
-               waitq_timedwait(&__wait, TASK_INTERRUPTIBLE,
-                               cfs_time_seconds(1));
+               schedule_timeout(cfs_time_seconds(1));
                remove_wait_queue(&tctl->tctl_waitq, &__wait);
         }
        complete(&tctl->tctl_stop);
index fdb9a8c..7f760bb 100644 (file)
@@ -40,6 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include "tracefile.h"
 
index 017f29f..d93c3e9 100644 (file)
@@ -41,6 +41,7 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 
 #define CFS_WS_NAME_LEN         16
@@ -408,7 +409,8 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
                               sched->ws_name);
 
                        spin_unlock(&cfs_wi_data.wi_glock);
-                       cfs_pause(cfs_time_seconds(1) / 20);
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1) / 20);
                        spin_lock(&cfs_wi_data.wi_glock);
                }
        }
@@ -541,7 +543,8 @@ cfs_wi_shutdown (void)
 
                while (sched->ws_nthreads != 0) {
                        spin_unlock(&cfs_wi_data.wi_glock);
-                       cfs_pause(cfs_time_seconds(1) / 20);
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1) / 20);
                        spin_lock(&cfs_wi_data.wi_glock);
                }
                spin_unlock(&cfs_wi_data.wi_glock);
index 4c0c98b..5e5f346 100644 (file)
@@ -46,6 +46,7 @@
 # error This include is only for kernel use.
 #endif
 
+#include <linux/kthread.h>
 #include <linux/uio.h>
 #include <linux/types.h>
 #include <net/sock.h>
index 8abc633..8970f4b 100644 (file)
@@ -1544,7 +1544,8 @@ kgnilnd_del_conn_or_peer(kgn_net_t *net, lnet_nid_t nid, int command,
               atomic_read(&kgnilnd_data.kgn_npending_detach)  ||
               atomic_read(&kgnilnd_data.kgn_npending_unlink)) {
 
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
                i++;
 
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, "Waiting on %d peers %d closes %d detaches\n",
@@ -2467,7 +2468,8 @@ kgnilnd_base_shutdown(void)
 
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
                        "Waiting for conns to be cleaned up %d\n",atomic_read(&kgnilnd_data.kgn_nconns));
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
        }
        /* Peer state all cleaned up BEFORE setting shutdown, so threads don't
         * have to worry about shutdown races.  NB connections may be created
@@ -2486,7 +2488,8 @@ kgnilnd_base_shutdown(void)
                i++;
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
                       "Waiting for ruhroh thread to terminate\n");
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
        }
 
        /* Flag threads to terminate */
@@ -2518,7 +2521,8 @@ kgnilnd_base_shutdown(void)
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */
                       "Waiting for %d threads to terminate\n",
                       atomic_read(&kgnilnd_data.kgn_nthreads));
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
        }
 
        LASSERTF(atomic_read(&kgnilnd_data.kgn_npeers) == 0,
@@ -2764,7 +2768,8 @@ kgnilnd_shutdown(lnet_ni_t *ni)
                                "Waiting for %d references to clear on net %d\n",
                                atomic_read(&net->gnn_refcount),
                                net->gnn_netnum);
-                       cfs_pause(cfs_time_seconds(1));
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1));
                }
 
                /* release ref from kgnilnd_startup */
index 819280b..1da0fbe 100644 (file)
@@ -133,7 +133,8 @@ kgnilnd_quiesce_wait(char *reason)
                                 atomic_read(&kgnilnd_data.kgn_nthreads) -
                                 atomic_read(&kgnilnd_data.kgn_nquiesce));
                        CFS_RACE(CFS_FAIL_GNI_QUIESCE_RACE);
-                       cfs_pause(cfs_time_seconds(1 * i));
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1 * i));
 
                        LASSERTF(quiesce_deadline > jiffies,
                                 "couldn't quiesce threads in %lu seconds, falling over now\n",
@@ -158,7 +159,8 @@ kgnilnd_quiesce_wait(char *reason)
                                 "%s: Waiting for %d threads to wake up\n",
                                  reason,
                                  atomic_read(&kgnilnd_data.kgn_nquiesce));
-                       cfs_pause(cfs_time_seconds(1 * i));
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1 * i));
                }
 
                CDEBUG(D_INFO, "%s: All threads awake!\n", reason);
@@ -417,7 +419,8 @@ kgnilnd_ruhroh_thread(void *arg)
                                i++;
                                CDEBUG(D_INFO, "Waiting for hardware quiesce "
                                               "flag to clear\n");
-                               cfs_pause(cfs_time_seconds(1 * i));
+                               set_current_state(TASK_UNINTERRUPTIBLE);
+                               schedule_timeout(cfs_time_seconds(1 * i));
 
                                /* If we got a quiesce event with bump info, DO THE BUMP!. */
                                if (kgnilnd_data.kgn_bump_info_rdy) {
index 39613d4..aae29d5 100644 (file)
@@ -131,7 +131,8 @@ proc_trigger_stack_reset(struct ctl_table *table, int write,
                i++;
                LCONSOLE((((i) & (-i)) == i) ? D_WARNING : D_NET,
                                "Waiting for stack reset request to clear\n");
-               cfs_pause(cfs_time_seconds(1 * i));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1 * i));
        }
 
        RETURN(rc);
index 8f321a3..32c455b 100644 (file)
@@ -2836,12 +2836,14 @@ kiblnd_base_shutdown(void)
 
                i = 2;
                while (atomic_read(&kiblnd_data.kib_nthreads) != 0) {
-                        i++;
-                        CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */
-                               "Waiting for %d threads to terminate\n",
+                       i++;
+                       /* power of 2? */
+                       CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
+                              "Waiting for %d threads to terminate\n",
                               atomic_read(&kiblnd_data.kib_nthreads));
-                        cfs_pause(cfs_time_seconds(1));
-                }
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1));
+               }
 
                 /* fall through */
 
@@ -2893,16 +2895,18 @@ kiblnd_shutdown (lnet_ni_t *ni)
                 /* nuke all existing peers within this net */
                 kiblnd_del_peer(ni, LNET_NID_ANY);
 
-                /* Wait for all peer state to clean up */
-                i = 2;
+               /* Wait for all peer state to clean up */
+               i = 2;
                while (atomic_read(&net->ibn_npeers) != 0) {
-                        i++;
-                        CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* 2**n? */
-                               "%s: waiting for %d peers to disconnect\n",
-                               libcfs_nid2str(ni->ni_nid),
+                       i++;
+                       /* power of 2? */
+                       CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
+                              "%s: waiting for %d peers to disconnect\n",
+                              libcfs_nid2str(ni->ni_nid),
                               atomic_read(&net->ibn_npeers));
-                        cfs_pause(cfs_time_seconds(1));
-                }
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1));
+               }
 
                kiblnd_net_fini_pools(net);
 
index e57d59e..4d9e3d1 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/kthread.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/stat.h>
index 41a4ca5..0c946c4 100644 (file)
@@ -3158,9 +3158,9 @@ kiblnd_connd (void *arg)
        int                peer_index = 0;
        unsigned long      deadline = jiffies;
 
-       cfs_block_allsigs ();
+       cfs_block_allsigs();
 
-       init_waitqueue_entry_current (&wait);
+       init_waitqueue_entry(&wait, current);
        kiblnd_data.kib_connd = current;
 
        spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);
@@ -3241,7 +3241,7 @@ kiblnd_connd (void *arg)
                add_wait_queue(&kiblnd_data.kib_connd_waitq, &wait);
                spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);
 
-               waitq_timedwait(&wait, TASK_INTERRUPTIBLE, timeout);
+               schedule_timeout(timeout);
 
                set_current_state(TASK_RUNNING);
                remove_wait_queue(&kiblnd_data.kib_connd_waitq, &wait);
@@ -3357,7 +3357,7 @@ kiblnd_scheduler(void *arg)
 
        cfs_block_allsigs();
 
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
 
        sched = kiblnd_data.kib_scheds[KIB_THREAD_CPT(id)];
 
@@ -3456,7 +3456,7 @@ kiblnd_scheduler(void *arg)
                add_wait_queue_exclusive(&sched->ibs_waitq, &wait);
                spin_unlock_irqrestore(&sched->ibs_lock, flags);
 
-               waitq_wait(&wait, TASK_INTERRUPTIBLE);
+               schedule();
                busy_loops = 0;
 
                remove_wait_queue(&sched->ibs_waitq, &wait);
@@ -3474,16 +3474,16 @@ int
 kiblnd_failover_thread(void *arg)
 {
        rwlock_t                *glock = &kiblnd_data.kib_global_lock;
-       kib_dev_t         *dev;
-       wait_queue_t     wait;
-       unsigned long      flags;
-       int                rc;
+       kib_dev_t               *dev;
+       wait_queue_t            wait;
+       unsigned long           flags;
+       int                     rc;
 
-       LASSERT (*kiblnd_tunables.kib_dev_failover != 0);
+       LASSERT(*kiblnd_tunables.kib_dev_failover != 0);
 
-       cfs_block_allsigs ();
+       cfs_block_allsigs();
 
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
        write_lock_irqsave(glock, flags);
 
         while (!kiblnd_data.kib_shutdown) {
index a4e2fb0..816f836 100644 (file)
@@ -2330,17 +2330,19 @@ ksocknal_base_shutdown(void)
                        }
                }
 
-                i = 4;
+               i = 4;
                read_lock(&ksocknal_data.ksnd_global_lock);
-                while (ksocknal_data.ksnd_nthreads != 0) {
-                        i++;
-                        CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */
-                               "waiting for %d threads to terminate\n",
-                                ksocknal_data.ksnd_nthreads);
+               while (ksocknal_data.ksnd_nthreads != 0) {
+                       i++;
+                       /* power of 2? */
+                       CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
+                               "waiting for %d threads to terminate\n",
+                               ksocknal_data.ksnd_nthreads);
                        read_unlock(&ksocknal_data.ksnd_global_lock);
-                        cfs_pause(cfs_time_seconds(1));
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1));
                        read_lock(&ksocknal_data.ksnd_global_lock);
-                }
+               }
                read_unlock(&ksocknal_data.ksnd_global_lock);
 
                 ksocknal_free_buffers();
@@ -2585,7 +2587,8 @@ ksocknal_shutdown (lnet_ni_t *ni)
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */
                       "waiting for %d peers to disconnect\n",
                       net->ksnn_npeers);
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
 
                ksocknal_debug_peerhash(ni);
 
@@ -2901,6 +2904,8 @@ ksocknal_module_init (void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Kernel TCP Socket LND v3.0.0");
+MODULE_VERSION("3.0.0");
 MODULE_LICENSE("GPL");
 
-cfs_module(ksocknal, "3.0.0", ksocknal_module_init, ksocknal_module_fini);
+module_init(ksocknal_module_init);
+module_exit(ksocknal_module_fini);
index 3ced60f..3d76507 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/if.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kthread.h>
 #include <linux/kmod.h>
 #include <linux/list.h>
 #include <linux/mm.h>
index d1538fc..cbb2ca1 100644 (file)
@@ -183,16 +183,17 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
 }
 
 static int
-ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
+ksocknal_transmit(ksock_conn_t *conn, ksock_tx_t *tx)
 {
-        int      rc;
-        int      bufnob;
+       int     rc;
+       int     bufnob;
 
-        if (ksocknal_data.ksnd_stall_tx != 0) {
-                cfs_pause(cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
-        }
+       if (ksocknal_data.ksnd_stall_tx != 0) {
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
+       }
 
-        LASSERT (tx->tx_resid != 0);
+       LASSERT(tx->tx_resid != 0);
 
         rc = ksocknal_connsock_addref(conn);
         if (rc != 0) {
@@ -345,9 +346,10 @@ ksocknal_receive (ksock_conn_t *conn)
         int     rc;
         ENTRY;
 
-        if (ksocknal_data.ksnd_stall_rx != 0) {
-                cfs_pause(cfs_time_seconds (ksocknal_data.ksnd_stall_rx));
-        }
+       if (ksocknal_data.ksnd_stall_rx != 0) {
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_rx));
+       }
 
         rc = ksocknal_connsock_addref(conn);
         if (rc != 0) {
@@ -2137,9 +2139,9 @@ ksocknal_connd (void *arg)
        int                nloops = 0;
        int                cons_retry = 0;
 
-       cfs_block_allsigs ();
+       cfs_block_allsigs();
 
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
 
        spin_lock_bh(connd_lock);
 
@@ -2228,7 +2230,7 @@ ksocknal_connd (void *arg)
                spin_unlock_bh(connd_lock);
 
                nloops = 0;
-               waitq_timedwait(&wait, TASK_INTERRUPTIBLE, timeout);
+               schedule_timeout(timeout);
 
                set_current_state(TASK_RUNNING);
                remove_wait_queue(&ksocknal_data.ksnd_connd_waitq, &wait);
@@ -2529,7 +2531,7 @@ int ksocknal_reaper(void *arg)
         cfs_block_allsigs ();
 
        INIT_LIST_HEAD(&enomem_conns);
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
 
        spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
 
@@ -2636,7 +2638,7 @@ int ksocknal_reaper(void *arg)
                if (!ksocknal_data.ksnd_shuttingdown &&
                    list_empty(&ksocknal_data.ksnd_deathrow_conns) &&
                    list_empty(&ksocknal_data.ksnd_zombie_conns))
-                       waitq_timedwait(&wait, TASK_INTERRUPTIBLE, timeout);
+                       schedule_timeout(timeout);
 
                set_current_state(TASK_RUNNING);
                remove_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
index 6c0115c..a0c0783 100644 (file)
@@ -382,13 +382,14 @@ lnet_acceptor(void *arg)
         while (!lnet_acceptor_state.pta_shutdown) {
 
                rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
-                if (rc != 0) {
-                        if (rc != -EAGAIN) {
-                                CWARN("Accept error %d: pausing...\n", rc);
-                                cfs_pause(cfs_time_seconds(1));
-                        }
-                        continue;
-                }
+               if (rc != 0) {
+                       if (rc != -EAGAIN) {
+                               CWARN("Accept error %d: pausing...\n", rc);
+                               set_current_state(TASK_UNINTERRUPTIBLE);
+                               schedule_timeout(cfs_time_seconds(1));
+                       }
+                       continue;
+               }
 
                /* maybe we're waken up with lnet_sock_abort_accept() */
                if (lnet_acceptor_state.pta_shutdown) {
index 6658c06..a039a2e 100644 (file)
@@ -987,7 +987,8 @@ lnet_ping_md_unlink(lnet_ping_info_t *pinfo, lnet_handle_md_t *md_handle)
        /* NB md could be busy; this just starts the unlink */
        while (pinfo->pi_features != LNET_PING_FEAT_INVAL) {
                CDEBUG(D_NET, "Still waiting for ping MD to unlink\n");
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
        }
 
        cfs_restore_sigs(blocked);
@@ -1125,7 +1126,8 @@ lnet_clear_zombies_nis_locked(void)
                                       "Waiting for zombie LNI %s\n",
                                       libcfs_nid2str(ni->ni_nid));
                        }
-                       cfs_pause(cfs_time_seconds(1));
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(cfs_time_seconds(1));
                        lnet_net_lock(LNET_LOCK_EX);
                        continue;
                }
index c85fe45..d5cc380 100644 (file)
@@ -327,27 +327,25 @@ __must_hold(&the_lnet.ln_eq_wait_lock)
 {
        int             tms = *timeout_ms;
        int             wait;
-       wait_queue_t  wl;
+       wait_queue_t    wl;
        cfs_time_t      now;
 
        if (tms == 0)
                return -1; /* don't want to wait and no new event */
 
-       init_waitqueue_entry_current(&wl);
+       init_waitqueue_entry(&wl, current);
        set_current_state(TASK_INTERRUPTIBLE);
        add_wait_queue(&the_lnet.ln_eq_waitq, &wl);
 
        lnet_eq_wait_unlock();
 
        if (tms < 0) {
-               waitq_wait(&wl, TASK_INTERRUPTIBLE);
-
+               schedule();
        } else {
                struct timeval tv;
 
                now = cfs_time_current();
-               waitq_timedwait(&wl, TASK_INTERRUPTIBLE,
-                                   cfs_time_seconds(tms) / 1000);
+               schedule_timeout(cfs_time_seconds(tms) / 1000);
                cfs_duration_usec(cfs_time_sub(cfs_time_current(), now), &tv);
                tms -= (int)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
                if (tms < 0) /* no more wait but may have new event */
index a8f39b3..f3ccfa8 100644 (file)
@@ -211,7 +211,9 @@ lnet_module_exit(void)
 }
 
 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Portals v3.1");
+MODULE_DESCRIPTION("LNet v3.1");
+MODULE_VERSION("1.0.0");
 MODULE_LICENSE("GPL");
 
-cfs_module(lnet, "1.0.0", lnet_module_init, lnet_module_exit);
+module_init(lnet_module_init);
+module_exit(lnet_module_exit);
index 6521fbc..1f2f1fa 100644 (file)
@@ -138,7 +138,8 @@ lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable,
                               "Waiting for %d zombies on peer table\n",
                               ptable->pt_zombies);
                }
-               cfs_pause(cfs_time_seconds(1) >> 1);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1) >> 1);
                lnet_net_lock(cpt_locked);
        }
 }
index b53545b..52b0cd3 100644 (file)
@@ -817,8 +817,9 @@ lnet_wait_known_routerstate(void)
                if (all_known)
                         return;
 
-                cfs_pause(cfs_time_seconds(1));
-        }
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
+       }
 }
 
 void
@@ -1194,7 +1195,8 @@ lnet_prune_rc_data(int wait_unlink)
                i++;
                CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
                       "Waiting for rc buffers to unlink\n");
-               cfs_pause(cfs_time_seconds(1) / 4);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1) / 4);
 
                lnet_net_lock(LNET_LOCK_EX);
        }
@@ -1275,7 +1277,7 @@ rescan:
 
                lnet_prune_rc_data(0); /* don't wait for UNLINK */
 
-               /* Call cfs_pause() here always adds 1 to load average
+               /* Call schedule_timeout() here always adds 1 to load average
                 * because kernel counts # active tasks as nr_running
                 * + nr_uninterruptible. */
                /* if there are any routes then wakeup every second.  If
index ea56f35..2207fa5 100644 (file)
@@ -1353,7 +1353,8 @@ lstcon_rpc_cleanup_wait(void)
 
                CWARN("Session is shutting down, "
                      "waiting for termination of transactions\n");
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
 
                mutex_lock(&console_session.ses_mutex);
        }
index cdebec9..188006a 100644 (file)
@@ -162,7 +162,8 @@ error:
 
 
 MODULE_DESCRIPTION("LNet Selftest");
+MODULE_VERSION("0.9.0");
 MODULE_LICENSE("GPL");
 
-cfs_module(lnet, "0.9.0", lnet_selftest_init, lnet_selftest_fini);
-
+module_init(lnet_selftest_init);
+module_exit(lnet_selftest_fini);
index 617caa8..0520e06 100644 (file)
@@ -1593,9 +1593,10 @@ srpc_startup (void)
        memset(&srpc_data, 0, sizeof(struct smoketest_rpc));
        spin_lock_init(&srpc_data.rpc_glock);
 
-        /* 1 second pause to avoid timestamp reuse */
-        cfs_pause(cfs_time_seconds(1));
-        srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48;
+       /* 1 second pause to avoid timestamp reuse */
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(cfs_time_seconds(1));
+       srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48;
 
         srpc_data.rpc_state = SRPC_STATE_NONE;
 
index da2f63a..830418c 100644 (file)
@@ -574,8 +574,6 @@ swi_state2str (int state)
 #undef STATE2STR
 }
 
-#define selftest_wait_events() cfs_pause(cfs_time_seconds(1) / 10)
-
 #define lst_wait_until(cond, lock, fmt, ...)                           \
 do {                                                                   \
        int __I = 2;                                                    \
@@ -584,7 +582,8 @@ do {                                                                        \
                       fmt, ## __VA_ARGS__);                            \
                spin_unlock(&(lock));                                   \
                                                                        \
-               selftest_wait_events();                                 \
+               set_current_state(TASK_UNINTERRUPTIBLE);                \
+               schedule_timeout(cfs_time_seconds(1) / 10);             \
                                                                        \
                spin_lock(&(lock));                                     \
        }                                                               \
@@ -597,13 +596,14 @@ srpc_wait_service_shutdown(srpc_service_t *sv)
 
        LASSERT(sv->sv_shuttingdown);
 
-        while (srpc_finish_service(sv) == 0) {
-                i++;
-                CDEBUG (((i & -i) == i) ? D_WARNING : D_NET,
-                        "Waiting for %s service to shutdown...\n",
-                        sv->sv_name);
-                selftest_wait_events();
-        }
+       while (srpc_finish_service(sv) == 0) {
+               i++;
+               CDEBUG(((i & -i) == i) ? D_WARNING : D_NET,
+                      "Waiting for %s service to shutdown...\n",
+                      sv->sv_name);
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1) / 10);
+       }
 }
 
 extern sfw_test_client_ops_t ping_test_client;
index b330964..f597182 100644 (file)
@@ -487,6 +487,25 @@ EXTRA_KCFLAGS=$tmp_flags
 ]) # LC_QUOTA64
 
 #
+# LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
+#
+# 2.6.34 adds __add_wait_queue_exclusive
+#
+AC_DEFUN([LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE], [
+LB_CHECK_COMPILE([if '__add_wait_queue_exclusive' exists],
+__add_wait_queue_exclusive, [
+       #include <linux/wait.h>
+],[
+       wait_queue_head_t queue;
+       wait_queue_t      wait;
+       __add_wait_queue_exclusive(&queue, &wait);
+],[
+       AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
+                 [__add_wait_queue_exclusive exists])
+])
+]) # LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
+
+#
 # LC_FS_STRUCT_RWLOCK
 #
 # 2.6.36 fs_struct.lock use spinlock instead of rwlock.
@@ -1565,6 +1584,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 2.6.34
        LC_HAVE_DQUOT_FS_DISK_QUOTA
        LC_HAVE_DQUOT_SUSPEND
+       LC_HAVE_ADD_WAIT_QUEUE_EXCLUSIVE
 
        # 2.6.35, 3.0.0
        LC_FILE_FSYNC
index ae896fc..d4b2555 100644 (file)
@@ -247,7 +247,7 @@ static int seq_fid_alloc_prep(struct lu_client_seq *seq,
                set_current_state(TASK_UNINTERRUPTIBLE);
                mutex_unlock(&seq->lcs_mutex);
 
-               waitq_wait(link, TASK_UNINTERRUPTIBLE);
+               schedule();
 
                mutex_lock(&seq->lcs_mutex);
                remove_wait_queue(&seq->lcs_waitq, link);
@@ -278,7 +278,7 @@ int seq_client_get_seq(const struct lu_env *env,
 
        LASSERT(seqnr != NULL);
        mutex_lock(&seq->lcs_mutex);
-       init_waitqueue_entry_current(&link);
+       init_waitqueue_entry(&link, current);
 
         while (1) {
                 rc = seq_fid_alloc_prep(seq, &link);
@@ -329,7 +329,7 @@ int seq_client_alloc_fid(const struct lu_env *env,
        LASSERT(seq != NULL);
        LASSERT(fid != NULL);
 
-       init_waitqueue_entry_current(&link);
+       init_waitqueue_entry(&link, current);
        mutex_lock(&seq->lcs_mutex);
 
        if (OBD_FAIL_CHECK(OBD_FAIL_SEQ_EXHAUST))
@@ -393,7 +393,7 @@ void seq_client_flush(struct lu_client_seq *seq)
        wait_queue_t link;
 
        LASSERT(seq != NULL);
-       init_waitqueue_entry_current(&link);
+       init_waitqueue_entry(&link, current);
        mutex_lock(&seq->lcs_mutex);
 
        while (seq->lcs_update) {
@@ -401,7 +401,7 @@ void seq_client_flush(struct lu_client_seq *seq)
                set_current_state(TASK_UNINTERRUPTIBLE);
                mutex_unlock(&seq->lcs_mutex);
 
-               waitq_wait(&link, TASK_UNINTERRUPTIBLE);
+               schedule();
 
                mutex_lock(&seq->lcs_mutex);
                remove_wait_queue(&seq->lcs_waitq, &link);
@@ -599,6 +599,8 @@ static void __exit fid_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre FID Module");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit);
+module_init(fid_mod_init);
+module_exit(fid_mod_exit);
index c8df248..2217475 100644 (file)
@@ -548,6 +548,8 @@ static void __exit fld_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre FLD");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(mdd, LUSTRE_VERSION_STRING, fld_mod_init, fld_mod_exit);
+module_init(fld_mod_init);
+module_exit(fld_mod_exit);
index c558e9b..71c65c3 100644 (file)
@@ -44,6 +44,7 @@
 # include <obd_support.h>
 #else /* !__KERNEL__ */
 # include <malloc.h>
+# include <stdlib.h>
 #endif /* __KERNEL__ */
 
 /** \defgroup cfg cfg
@@ -222,9 +223,14 @@ static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index)
         * of data.  Try to use the padding first though.
         */
        if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
-               size_t last = min((size_t)lcfg->lcfg_buflens[index],
-                              cfs_size_round(lcfg->lcfg_buflens[index]) - 1);
-               char lost = s[last];
+               size_t last = cfs_size_round(lcfg->lcfg_buflens[index]) - 1;
+               char lost;
+
+               /* Use the smaller value */
+               if (last > lcfg->lcfg_buflens[index])
+                       last = lcfg->lcfg_buflens[index];
+
+               lost = s[last];
                s[last] = '\0';
                if (lost != '\0') {
                        CWARN("Truncated buf %d to '%s' (lost '%c'...)\n",
index 3c6b5ae..a343280 100644 (file)
@@ -212,6 +212,40 @@ struct l_wait_info {
         sigmask(SIGQUIT) | sigmask(SIGALRM))
 
 /*
+ * Wait Queue
+ */
+#ifndef HAVE___ADD_WAIT_QUEUE_EXCLUSIVE
+static inline void __add_wait_queue_exclusive(wait_queue_head_t *q,
+                                             wait_queue_t *wait)
+{
+       wait->flags |= WQ_FLAG_EXCLUSIVE;
+       __add_wait_queue(q, wait);
+}
+#endif /* HAVE___ADD_WAIT_QUEUE_EXCLUSIVE */
+
+/**
+ * wait_queue_t of Linux (version < 2.6.34) is a FIFO list for exclusively
+ * waiting threads, which is not always desirable because all threads will
+ * be waken up again and again, even user only needs a few of them to be
+ * active most time. This is not good for performance because cache can
+ * be polluted by different threads.
+ *
+ * LIFO list can resolve this problem because we always wakeup the most
+ * recent active thread by default.
+ *
+ * NB: please don't call non-exclusive & exclusive wait on the same
+ * waitq if add_wait_queue_exclusive_head is used.
+ */
+#define add_wait_queue_exclusive_head(waitq, link)             \
+{                                                              \
+       unsigned long flags;                                    \
+                                                               \
+       spin_lock_irqsave(&((waitq)->lock), flags);             \
+       __add_wait_queue_exclusive(waitq, link);                \
+       spin_unlock_irqrestore(&((waitq)->lock), flags);        \
+}
+
+/*
  * wait for @condition to become true, but no longer than timeout, specified
  * by @info.
  */
@@ -226,7 +260,7 @@ do {                                                                           \
        if (condition)                                                         \
                break;                                                         \
                                                                               \
-       init_waitqueue_entry_current(&__wait);                                 \
+       init_waitqueue_entry(&__wait, current);                                \
        l_add_wait(&wq, &__wait);                                              \
                                                                               \
        /* Block all signals (just the non-fatal ones if no timeout). */       \
@@ -236,27 +270,19 @@ do {                                                                           \
                __blocked = cfs_block_sigsinv(0);                              \
                                                                               \
        for (;;) {                                                             \
-               unsigned       __wstate;                                       \
-                                                                              \
-               __wstate = info->lwi_on_signal != NULL &&                      \
-                          (__timeout == 0 || __allow_intr) ?                  \
-                       TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;             \
-                                                                              \
                set_current_state(TASK_INTERRUPTIBLE);                         \
                                                                               \
                if (condition)                                                 \
                        break;                                                 \
                                                                               \
                if (__timeout == 0) {                                          \
-                       waitq_wait(&__wait, __wstate);                         \
+                       schedule();                                            \
                } else {                                                       \
                        cfs_duration_t interval = info->lwi_interval?          \
                                             min_t(cfs_duration_t,             \
                                                 info->lwi_interval,__timeout):\
                                             __timeout;                        \
-                       cfs_duration_t remaining = waitq_timedwait(&__wait,    \
-                                                  __wstate,                   \
-                                                  interval);                  \
+                       cfs_duration_t remaining = schedule_timeout(interval); \
                        __timeout = cfs_time_sub(__timeout,                    \
                                            cfs_time_sub(interval, remaining));\
                        if (__timeout == 0) {                                  \
@@ -273,7 +299,7 @@ do {                                                                           \
                                                                                \
                 if (condition)                                                 \
                         break;                                                 \
-                if (cfs_signal_pending()) {                                    \
+               if (signal_pending(current)) {                                 \
                         if (info->lwi_on_signal != NULL &&                     \
                             (__timeout == 0 || __allow_intr)) {                \
                                 if (info->lwi_on_signal != LWI_ON_SIGNAL_NOOP) \
@@ -294,12 +320,11 @@ do {                                                                           \
                                                                                \
        cfs_restore_sigs(__blocked);                                           \
                                                                                \
-       set_current_state(TASK_RUNNING);                                       \
+       set_current_state(TASK_RUNNING);                                       \
        remove_wait_queue(&wq, &__wait);                                       \
 } while (0)
 
 
-
 #define l_wait_event(wq, condition, info)                       \
 ({                                                              \
        int                 __ret;                              \
index 38c0b93..b92c1de 100644 (file)
@@ -43,6 +43,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <obd.h>
 #include <obd_class.h>
index 9f541d0..df40380 100644 (file)
@@ -41,6 +41,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <lustre_dlm.h>
 #include <obd_class.h>
@@ -1761,8 +1762,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
        if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_BL_CB_RACE)) {
                int to = cfs_time_seconds(1);
                while (to > 0) {
-                       schedule_timeout_and_set_state(
-                               TASK_INTERRUPTIBLE, to);
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       schedule_timeout(to);
                        if (lock->l_granted_mode == lock->l_req_mode ||
                            ldlm_is_destroyed(lock))
                                break;
index 274be06..ea1971f 100644 (file)
@@ -97,6 +97,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <linux/kthread.h>
 #include <lustre_dlm.h>
 #include <cl_object.h>
 #include <obd_class.h>
index 44023bd..bc430a9 100644 (file)
@@ -721,9 +721,8 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
                         unlock_res(res);
                         LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY");
                        if (lock->l_flags & LDLM_FL_FAIL_LOC) {
-                               schedule_timeout_and_set_state(
-                                       TASK_UNINTERRUPTIBLE,
-                                       cfs_time_seconds(4));
+                               set_current_state(TASK_UNINTERRUPTIBLE);
+                               schedule_timeout(cfs_time_seconds(4));
                                set_current_state(TASK_RUNNING);
                        }
                         if (lock->l_completion_ast)
index 97e3b7d..3905d85 100644 (file)
@@ -30,6 +30,7 @@
 
 #define DEBUG_SUBSYSTEM S_LFSCK
 
+#include <linux/kthread.h>
 #include <libcfs/list.h>
 #include <lu_object.h>
 #include <dt_object.h>
@@ -3590,6 +3591,8 @@ static void __exit lfsck_exit(void)
 
 MODULE_AUTHOR("Intel Corporation <http://www.intel.com/>");
 MODULE_DESCRIPTION("LFSCK");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(lfsck, LUSTRE_VERSION_STRING, lfsck_init, lfsck_exit);
+module_init(lfsck_init);
+module_exit(lfsck_exit);
index 8fb5a7c..d38c9f0 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/mm.h>
 #include <linux/version.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <asm/uaccess.h>
 #include <linux/buffer_head.h>   // for wait_on_buffer
 #include <linux/pagevec.h>
index 65b1ffe..8f77e8c 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/file.h>
 #include <linux/sched.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <lustre/ll_fiemap.h>
 #include <lustre_ioctl.h>
 
index 32a51ea..96ce4f2 100644 (file)
@@ -211,14 +211,14 @@ static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
 
                bkt = lu_site_bkt_from_fid(site, &header->loh_fid);
 
-               init_waitqueue_entry_current(&waiter);
+               init_waitqueue_entry(&waiter, current);
                add_wait_queue(&bkt->lsb_marche_funebre, &waiter);
 
                while (1) {
                        set_current_state(TASK_UNINTERRUPTIBLE);
                        if (atomic_read(&header->loh_ref) == 1)
                                break;
-                       waitq_wait(&waiter, TASK_UNINTERRUPTIBLE);
+                       schedule();
                }
 
                set_current_state(TASK_RUNNING);
index 16a7efa..c96ad8a 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <linux/fs.h>
 #include <linux/version.h>
+#include <linux/kthread.h>
 #include <asm/uaccess.h>
 #include <linux/file.h>
 #include <linux/kmod.h>
index 1497b3a..768c09b 100644 (file)
 #include <linux/types.h>
 #include <linux/version.h>
 #include <linux/mm.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 #include <lustre_ioctl.h>
 #include <lustre_ha.h>
@@ -806,9 +810,10 @@ void ll_kill_super(struct super_block *sb)
                sbi->ll_umounting = 1;
 
                /* wait running statahead threads to quit */
-               while (atomic_read(&sbi->ll_sa_running) > 0)
-                       schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                               msecs_to_jiffies(MSEC_PER_SEC >> 3));
+               while (atomic_read(&sbi->ll_sa_running) > 0) {
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC >> 3));
+               }
        }
 
        EXIT;
index f3bf6de..4d9e49b 100644 (file)
@@ -82,6 +82,7 @@
 #include <linux/module.h>
 
 #include <linux/sched.h>
+#include <linux/kthread.h>
 #include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/stat.h>
index 6034164..c1c7f1a 100644 (file)
 #define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/version.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <lustre_param.h>
 #include <lprocfs_status.h>
 #include <obd_support.h>
index f9839d1..82d1612 100644 (file)
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/security.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
index 25550b4..2789412 100644 (file)
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/version.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 #include <lustre_ha.h>
 #include <lustre_dlm.h>
index c911bdb..6adb7e8 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/kthread.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
index 29bba00..e7e4480 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <libcfs/libcfs.h>
 
 #include <obd.h>
index fb990f8..344424b 100644 (file)
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/mm.h>
index 1480f3b..ddf0e18 100644 (file)
@@ -1601,6 +1601,8 @@ static void /*__exit*/ lov_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(lov, LUSTRE_VERSION_STRING, lov_init, lov_exit);
+module_init(lov_init);
+module_exit(lov_exit);
index 0c8bf7e..c852ab5 100644 (file)
@@ -380,7 +380,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
          * ->lo_sub[] slot in lovsub_object_fini() */
        if (r0->lo_sub[idx] == los) {
                waiter = &lov_env_info(env)->lti_waiter;
-               init_waitqueue_entry_current(waiter);
+               init_waitqueue_entry(waiter, current);
                add_wait_queue(&bkt->lsb_marche_funebre, waiter);
                set_current_state(TASK_UNINTERRUPTIBLE);
                while (1) {
@@ -390,7 +390,7 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
                        spin_lock(&r0->lo_sub_lock);
                        if (r0->lo_sub[idx] == los) {
                                spin_unlock(&r0->lo_sub_lock);
-                               waitq_wait(waiter, TASK_UNINTERRUPTIBLE);
+                               schedule();
                        } else {
                                spin_unlock(&r0->lo_sub_lock);
                                set_current_state(TASK_RUNNING);
index f17c69a..1d146fd 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_MDC
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <lustre_net.h>
 #include <lustre/lustre_idl.h>
 #include <obd_class.h>
index 830536f..b75b550 100644 (file)
 #include <linux/miscdevice.h>
 #include <linux/init.h>
 #include <linux/utsname.h>
+#include <linux/kthread.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 #include <lustre_acl.h>
 #include <lustre_ioctl.h>
index c5ac7e9..560329b 100644 (file)
@@ -43,6 +43,7 @@
 #define DEBUG_SUBSYSTEM S_MDS
 
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <obd_class.h>
 #include <lustre_ioctl.h>
 #include <lustre_mds.h>
@@ -1599,6 +1600,8 @@ static void __exit mdd_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Meta-data Device Prototype ("LUSTRE_MDD_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(mdd, "0.1.0", mdd_mod_init, mdd_mod_exit);
+module_init(mdd_mod_init);
+module_exit(mdd_mod_exit);
index f6bc081..27ff1e3 100644 (file)
@@ -38,6 +38,7 @@
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <linux/kthread.h>
 #include <obd_support.h>
 #include <lustre_net.h>
 #include <lustre_export.h>
index aa702f8..40f4ca3 100644 (file)
@@ -2808,9 +2808,10 @@ static int mdt_tgt_connect(struct tgt_session_info *tsi)
 
        if (OBD_FAIL_CHECK(OBD_FAIL_TGT_DELAY_CONDITIONAL) &&
            cfs_fail_val ==
-           tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id)
-               schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                       msecs_to_jiffies(3 * MSEC_PER_SEC));
+           tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id) {
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(msecs_to_jiffies(3 * MSEC_PER_SEC));
+       }
 
        rc = tgt_connect(tsi);
        if (rc != 0)
@@ -5854,6 +5855,8 @@ static void __exit mdt_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Metadata Target ("LUSTRE_MDT_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(mdt, LUSTRE_VERSION_STRING, mdt_mod_init, mdt_mod_exit);
+module_init(mdt_mod_init);
+module_exit(mdt_mod_exit);
index d829beb..389c279 100644 (file)
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/kmod.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <linux/string.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
index bef58a9..42854bb 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include "mdt_internal.h"
 #include <lnet/nidstr.h>
 #include <lustre_nodemap.h>
index 72827eb..18da798 100644 (file)
@@ -42,6 +42,7 @@
 #define D_MGC D_CONFIG /*|D_WARNING*/
 
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <obd_class.h>
 #include <lustre_dlm.h>
 #include <lprocfs_status.h>
index 2af93d7..8aacd89 100644 (file)
@@ -43,6 +43,7 @@
 #define DEBUG_SUBSYSTEM S_MGS
 #define D_MGS D_CONFIG
 
+#include <linux/kthread.h>
 #include <linux/pagemap.h>
 
 #include <obd.h>
index 4bb4aaa..ba93853 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <asm/atomic.h>
+
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
+#include <linux/atomic.h>
 
 #include <obd_support.h>
 #include <obd_class.h>
@@ -52,7 +57,6 @@
 #include <lustre_ioctl.h>
 #include "llog_internal.h"
 
-
 struct obd_device *obd_devs[MAX_OBD_DEVICES];
 struct list_head obd_types;
 DEFINE_RWLOCK(obd_dev_lock);
@@ -687,6 +691,8 @@ static void cleanup_obdclass(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass);
+module_init(init_obdclass);
+module_exit(cleanup_obdclass);
index 89f7c4b..784082a 100644 (file)
@@ -40,6 +40,8 @@
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
+
+#include <linux/kthread.h>
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <lustre_kernelcomm.h>
@@ -1564,8 +1566,8 @@ void obd_exports_barrier(struct obd_device *obd)
        spin_lock(&obd->obd_dev_lock);
        while (!list_empty(&obd->obd_unlinked_exports)) {
                spin_unlock(&obd->obd_dev_lock);
-               schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                                                  cfs_time_seconds(waited));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(waited));
                if (waited > 5 && IS_PO2(waited)) {
                        LCONSOLE_WARN("%s is waiting for obd_unlinked_exports "
                                      "more than %d seconds. "
index 8fc299d..a7cec60 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_SEC
 
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <lustre_idmap.h>
 #include <upcall_cache.h>
 #include <md_object.h>
 #include <obd_support.h>
 
-#define lustre_get_group_info(group_info) do {             \
-       atomic_inc(&(group_info)->usage);              \
+#define lustre_get_group_info(group_info) do {         \
+       atomic_inc(&(group_info)->usage);               \
 } while (0)
 
-#define lustre_put_group_info(group_info) do {             \
-       if (atomic_dec_and_test(&(group_info)->usage)) \
-               groups_free(group_info);                   \
+#define lustre_put_group_info(group_info) do {         \
+       if (atomic_dec_and_test(&(group_info)->usage))  \
+               groups_free(group_info);                \
 } while (0)
 
 /*
index c34e179..9346f18 100644 (file)
@@ -47,7 +47,7 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-
+#include <linux/kthread.h>
 #include <obd_class.h>
 #include <lustre_log.h>
 #include "llog_internal.h"
index 3660990..c111b05 100644 (file)
@@ -615,7 +615,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
          */
 
        if (likely(waiter != NULL)) {
-               init_waitqueue_entry_current(waiter);
+               init_waitqueue_entry(waiter, current);
                add_wait_queue(&bkt->lsb_marche_funebre, waiter);
                set_current_state(TASK_UNINTERRUPTIBLE);
                lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_DEATH_RACE);
@@ -784,7 +784,7 @@ struct lu_object *lu_object_find_at(const struct lu_env *env,
                 * lu_object_find_try() already added waiter into the
                 * wait queue.
                 */
-               waitq_wait(&wait, TASK_UNINTERRUPTIBLE);
+               schedule();
                bkt = lu_site_bkt_from_fid(dev->ld_site, (void *)f);
                remove_wait_queue(&bkt->lsb_marche_funebre, &wait);
        }
index 457dfc3..33bbc40 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <obd_class.h>
 #include <lustre/lustre_idl.h>
 
index 4d9ef1c..165e717 100644 (file)
@@ -221,13 +221,12 @@ find_again:
                              MAX_SCHEDULE_TIMEOUT;
                long left;
 
-               init_waitqueue_entry_current(&wait);
+               init_waitqueue_entry(&wait, current);
                add_wait_queue(&entry->ue_waitq, &wait);
                set_current_state(TASK_INTERRUPTIBLE);
                spin_unlock(&cache->uc_lock);
 
-               left = waitq_timedwait(&wait, TASK_INTERRUPTIBLE,
-                                          expiry);
+               left = schedule_timeout(expiry);
 
                spin_lock(&cache->uc_lock);
                remove_wait_queue(&entry->ue_waitq, &wait);
index a9886ed..a7cea4b 100644 (file)
@@ -619,7 +619,8 @@ static int echo_cleanup(struct obd_device *obd)
 
        /* XXX Bug 3413; wait for a bit to ensure the BL callback has
         * happened before calling ldlm_namespace_free() */
-       schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE, cfs_time_seconds(1));
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(cfs_time_seconds(1));
 
        ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
        obd->obd_namespace = NULL;
index 7aaf113..944dddd 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_ECHO
+
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <libcfs/libcfs.h>
 
 #include <obd.h>
@@ -1047,8 +1052,8 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
                spin_unlock(&ec->ec_lock);
                CERROR("echo_client still has objects at cleanup time, "
                       "wait for 1 second\n");
-               schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                                                  cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
                lu_site_purge(env, &ed->ed_site->cs_lu, -1);
                spin_lock(&ec->ec_lock);
        }
@@ -2988,8 +2993,10 @@ static void /*__exit*/ obdecho_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Testing Echo OBD driver");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit);
+module_init(obdecho_init);
+module_exit(obdecho_exit);
 
 /** @} echo_client */
index 177f58b..14f8e13 100644 (file)
@@ -40,6 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_FILTER
 
+#include <linux/kthread.h>
 #include "ofd_internal.h"
 
 struct ofd_inconsistency_item {
index 72285ba..a4ab52e 100644 (file)
@@ -482,7 +482,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
  * at any time.
  */
 
-static CFS_DECL_WAITQ(osc_lru_waitq);
+static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq);
 /* LRU pages are freed in batch mode. OSC should at least free this
  * number of pages to avoid running out of LRU budget, and.. */
 static const int lru_shrink_min = 2 << (20 - PAGE_CACHE_SHIFT); /* 2M */
index f841014..2c31e0b 100644 (file)
@@ -2963,6 +2963,8 @@ static void /*__exit*/ osc_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Object Storage Client (OSC)");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(osc, LUSTRE_VERSION_STRING, osc_init, osc_exit);
+module_init(osc_init);
+module_exit(osc_exit);
index 6aa802e..c771ac5 100644 (file)
 #define DEBUG_SUBSYSTEM S_OSD
 
 #include <linux/module.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 
 /* LUSTRE_VERSION_CODE */
 #include <lustre_ver.h>
@@ -6249,6 +6253,8 @@ static void __exit osd_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Object Storage Device ("LUSTRE_OSD_LDISKFS_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(osd, "0.1.0", osd_mod_init, osd_mod_exit);
+module_init(osd_mod_init);
+module_exit(osd_mod_exit);
index dca0776..047e656 100644 (file)
@@ -37,6 +37,7 @@
 
 #define DEBUG_SUBSYSTEM S_LFSCK
 
+#include <linux/kthread.h>
 #include <lustre/lustre_idl.h>
 #include <lustre_disk.h>
 #include <dt_object.h>
index 1625b62..e03668a 100644 (file)
@@ -1212,6 +1212,8 @@ CFS_MODULE_PARM(osd_oi_count, "i", int, 0444,
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Object Storage Device ("LUSTRE_OSD_ZFS_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(osd, LUSTRE_VERSION_STRING, osd_init, osd_exit);
+module_init(osd_init);
+module_exit(osd_exit);
index 445dfd2..63af058 100644 (file)
@@ -1810,6 +1810,8 @@ static void __exit osp_mod_exit(void)
 
 MODULE_AUTHOR("Intel, Inc. <http://www.intel.com/>");
 MODULE_DESCRIPTION("Lustre OST Proxy Device ("LUSTRE_OSP_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(osp, LUSTRE_VERSION_STRING, osp_mod_init, osp_mod_exit);
+module_init(osp_mod_init);
+module_exit(osp_mod_exit);
index 076cc6a..ec64dae 100644 (file)
@@ -44,6 +44,7 @@
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <linux/kthread.h>
 #include "osp_internal.h"
 
 /*
index 64eb8da..d5eaeb2 100644 (file)
@@ -43,6 +43,7 @@
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <linux/kthread.h>
 #include <lustre_log.h>
 #include <lustre_update.h>
 #include "osp_internal.h"
index ffccc5e..d8773ca 100644 (file)
@@ -2154,7 +2154,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
                 CDEBUG(D_RPCTRACE, "set %p going to sleep for %d seconds\n",
                        set, timeout);
 
-                if (timeout == 0 && !cfs_signal_pending())
+               if (timeout == 0 && !signal_pending(current))
                         /*
                          * No requests are in-flight (ether timed out
                          * or delayed), so we can allow interrupts.
@@ -2179,7 +2179,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
                  * pending when we started, we need to handle it now or we risk
                  * it being ignored forever */
                if (rc == -ETIMEDOUT && !lwi.lwi_allow_intr &&
-                   cfs_signal_pending()) {
+                   signal_pending(current)) {
                        sigset_t blocked_sigs =
                                           cfs_block_sigsinv(LUSTRE_FATAL_SIGS);
 
@@ -2187,7 +2187,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
                         * like SIGINT or SIGKILL. We still ignore less
                         * important signals since ptlrpc set is not easily
                         * reentrant from userspace again */
-                       if (cfs_signal_pending())
+                       if (signal_pending(current))
                                ptlrpc_interrupted_set(set);
                        cfs_restore_sigs(blocked_sigs);
                }
index b7f9b23..e3a7ab1 100644 (file)
@@ -919,7 +919,7 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req,
 
        cache_get(&rsip->h); /* take an extra ref */
        init_waitqueue_head(&rsip->waitq);
-       init_waitqueue_entry_current(&wait);
+       init_waitqueue_entry(&wait, current);
        add_wait_queue(&rsip->waitq, &wait);
 
 cache_check:
index 406af8b..007f737 100644 (file)
@@ -40,6 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/kthread.h>
 #include <obd_support.h>
 #include <lustre_ha.h>
 #include <lustre_net.h>
index 45f1817..1e23bab 100644 (file)
@@ -40,6 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/kthread.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include "ptlrpc_internal.h"
index 544cc41..ed0bcb5 100644 (file)
@@ -152,6 +152,8 @@ static void __exit ptlrpc_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
+module_init(ptlrpc_init);
+module_exit(ptlrpc_exit);
index e4f89eb..cf8b3a0 100644 (file)
@@ -55,6 +55,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <lustre_net.h>
 #include <lustre_lib.h>
index 443daff..ccb6d82 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#include <libcfs/libcfs.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <linux/crypto.h>
 #include <linux/key.h>
 
+#include <libcfs/libcfs.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
@@ -566,7 +570,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
         newctx = req->rq_cli_ctx;
         LASSERT(newctx);
 
-        if (unlikely(newctx == oldctx && 
+       if (unlikely(newctx == oldctx &&
                     test_bit(PTLRPC_CTX_DEAD_BIT, &oldctx->cc_flags))) {
                 /*
                  * still get the old dead ctx, usually means system too busy
@@ -575,8 +579,8 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
                        "ctx (%p, fl %lx) doesn't switch, relax a little bit\n",
                        newctx, newctx->cc_flags);
 
-               schedule_timeout_and_set_state(TASK_INTERRUPTIBLE,
-                       msecs_to_jiffies(MSEC_PER_SEC));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC));
        } else {
                 /*
                  * it's possible newctx == oldctx if we're switching
index a4df107..473943c 100644 (file)
@@ -573,11 +573,11 @@ again:
                                                page_pools.epp_waitqlen;
 
                        set_current_state(TASK_UNINTERRUPTIBLE);
-                       init_waitqueue_entry_current(&waitlink);
+                       init_waitqueue_entry(&waitlink, current);
                        add_wait_queue(&page_pools.epp_waitq, &waitlink);
 
                        spin_unlock(&page_pools.epp_lock);
-                       waitq_wait(&waitlink, TASK_UNINTERRUPTIBLE);
+                       schedule();
                        remove_wait_queue(&page_pools.epp_waitq, &waitlink);
                        LASSERT(page_pools.epp_waitqlen > 0);
                        spin_lock(&page_pools.epp_lock);
index 1b60971..a7f3b79 100644 (file)
@@ -40,6 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_SEC
 
+#include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 
 #include <obd_support.h>
index 8609e3f..6229a6f 100644 (file)
@@ -35,6 +35,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+#include <linux/kthread.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lustre_net.h>
index 49a31ac..2e335d9 100644 (file)
@@ -172,8 +172,8 @@ retry:
                        "freed:%lu, repeat:%u\n", hash,
                        d.lid_inuse, d.lid_freed, repeat);
                repeat++;
-               schedule_timeout_and_set_state(TASK_INTERRUPTIBLE,
-                                               cfs_time_seconds(1));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
                goto retry;
        }
        EXIT;
index 8bb7515..33cd13a 100644 (file)
@@ -376,6 +376,8 @@ static void exit_lquota(void)
 
 MODULE_AUTHOR("Intel Corporation <http://www.intel.com/>");
 MODULE_DESCRIPTION("Lustre Quota");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(lquota, "2.4.0", init_lquota, exit_lquota);
+module_init(init_lquota);
+module_exit(exit_lquota);
index 9618fc0..e82f79a 100644 (file)
@@ -30,6 +30,7 @@
 
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
+#include <linux/kthread.h>
 #include <lustre_dlm.h>
 #include <obd_class.h>
 
index bcbe18a..d7e8e5c 100644 (file)
@@ -309,8 +309,8 @@ static void qsd_qtype_fini(const struct lu_env *env, struct qsd_instance *qsd,
                CDEBUG(D_QUOTA, "qqi reference count %u, repeat: %d\n",
                       atomic_read(&qqi->qqi_ref), repeat);
                repeat++;
-               schedule_timeout_and_set_state(TASK_INTERRUPTIBLE,
-                                               cfs_time_seconds(1));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
        }
 
        /* by now, all qqi users should have gone away */
index e92937d..03b7741 100644 (file)
@@ -30,6 +30,7 @@
 
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
+#include <linux/kthread.h>
 #include "qsd_internal.h"
 
 /*
index 67e2d8f..7e82e77 100644 (file)
@@ -30,6 +30,7 @@
 
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
+#include <linux/kthread.h>
 #include "qsd_internal.h"
 
 extern struct kmem_cache *upd_kmem;
index 7804ec4..2bf4c74 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
+
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_cksum.h>
index 5aad0e2..6e00512 100644 (file)
@@ -43,6 +43,8 @@
 #include <time.h>
 #include <sys/time.h>
 
+#define EXPORT_SYMBOL(s)
+
 #include <libcfs/libcfs.h>
 #include <../ldlm/interval_tree.c>
 
index 52728fb..ab4b91d 100644 (file)
@@ -54,6 +54,8 @@
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
+#include <libcfs/util/string.h>
+
 #include "gssd.h"
 #include "err_util.h"
 #include "gss_util.h"
index cf252aa..2a3fdf2 100644 (file)
@@ -50,6 +50,7 @@
 #include <keyutils.h>
 #include <gssapi/gssapi.h>
 
+#include <libcfs/util/string.h>
 #include "lsupport.h"
 #include "lgss_utils.h"
 #include "write_bytes.h"
index c6e9f6c..9f357a4 100644 (file)
@@ -48,6 +48,7 @@
 #include <libgen.h>
 #include <syslog.h>
 
+#include <libcfs/util/string.h>
 #include <libcfs/libcfs.h>
 #include <lnet/nidstr.h>
 #include <lustre/lustre_user.h>
index 4f2475c..bfffbd9 100644 (file)
@@ -66,6 +66,7 @@
 # include <sys/quota.h>
 #endif
 
+#include <libcfs/util/string.h>
 #include <libcfs/libcfs.h>
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/parser.h>
index a0926bb..0f9c793 100644 (file)
@@ -51,6 +51,7 @@
 #include <sys/xattr.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+#include <libcfs/util/string.h>
 #include <lustre/lustre_idl.h>
 #include <lustre/lustreapi.h>
 
@@ -518,7 +519,7 @@ static int ct_copy_data(struct hsm_copyaction_private *hcp, const char *src,
        struct stat              dst_st;
        char                    *buf = NULL;
        __u64                    write_total = 0;
-       __u64                    length;
+       __u64                    length = hai->hai_extent.length;
        time_t                   last_report_time;
        int                      rc = 0;
        double                   start_ct_now = ct_now();
@@ -560,8 +561,8 @@ static int ct_copy_data(struct hsm_copyaction_private *hcp, const char *src,
        }
 
        /* Don't read beyond a given extent */
-       length = min(hai->hai_extent.length,
-                    src_st.st_size - hai->hai_extent.offset);
+       if (length > src_st.st_size - hai->hai_extent.offset)
+               length = src_st.st_size - hai->hai_extent.offset;
 
        start_time = last_bw_print = last_report_time = time(NULL);
 
index ed91959..3c1299c 100644 (file)
@@ -56,6 +56,7 @@
 #include <endian.h>
 #endif
 
+#include <libcfs/util/string.h>
 #include <libcfs/libcfs.h>
 #include <lustre/libiam.h>
 
index 10e8e76..e454837 100644 (file)
@@ -41,6 +41,7 @@
 #include <unistd.h>
 #endif
 
+#include <libcfs/util/string.h>
 #include <libcfs/libcfs.h>
 #include <lustre/lustreapi.h>
 
index b6af2e5..a7af694 100644 (file)
 #include <glob.h>
 
 #include <libcfs/libcfs.h>
+#include <libcfs/util/string.h>
 #include <libcfs/util/parser.h>
 #include <lnet/nidstr.h>
 #include <lustre_cfg.h>
 #include <lustre/lustre_idl.h>
 #include <lustre/lustre_build_version.h>
 
-#include <unistd.h>
 #include <sys/un.h>
 #include <time.h>
 #include <sys/time.h>
index e7b3830..1830ac1 100644 (file)
 #include <utime.h>
 #include <sys/xattr.h>
 
+#include <libcfs/util/string.h>
 #include <libcfs/util/parser.h>
 #include <lustre/lustreapi.h>
 #include <lustre/lustre_idl.h>
@@ -1114,7 +1115,7 @@ int lr_parse_line(void *priv, struct lr_info *info)
        struct changelog_rec            *rec;
        struct changelog_ext_rename     *rnm;
        size_t                           namelen;
-       size_t                           copylen;
+       size_t                           copylen = sizeof(info->name);
 
        if (llapi_changelog_recv(priv, &rec) != 0)
                return -1;
@@ -1126,18 +1127,22 @@ int lr_parse_line(void *priv, struct lr_info *info)
        snprintf(info->pfid, sizeof(info->pfid), DFID, PFID(&rec->cr_pfid));
 
        namelen = strnlen(changelog_rec_name(rec), rec->cr_namelen);
-       copylen = min(sizeof(info->name), namelen + 1);
+       if (copylen > namelen + 1)
+               copylen = namelen + 1;
        strlcpy(info->name, changelog_rec_name(rec), copylen);
 
        /* Don't use rnm if CLF_RENAME isn't set */
        rnm = changelog_rec_rename(rec);
        if (rec->cr_flags & CLF_RENAME && !fid_is_zero(&rnm->cr_sfid)) {
+               copylen = sizeof(info->sname);
+
                snprintf(info->sfid, sizeof(info->sfid), DFID,
                         PFID(&rnm->cr_sfid));
                snprintf(info->spfid, sizeof(info->spfid), DFID,
                         PFID(&rnm->cr_spfid));
                namelen = changelog_rec_snamelen(rec);
-               copylen = min(sizeof(info->sname), namelen + 1);
+               if (copylen > namelen + 1)
+                       copylen = namelen + 1;
                strlcpy(info->sname, changelog_rec_sname(rec), copylen);
 
                if (verbose > 1)
index c349d59..e4cc51a 100644 (file)
@@ -732,15 +732,16 @@ int main(int argc, char *const argv[])
                                                mop.mo_retry - i);
                                 }
 
-                                if (mop.mo_retry) {
-                                        sleep(1 << max((i/2), 5));
-                                }
-                                else {
-                                        rc = errno;
-                                }
-                        }
-                }
-        }
+                               if (mop.mo_retry) {
+                                       int limit = i/2 > 5 ? i/2 : 5;
+
+                                       sleep(1 << limit);
+                               } else {
+                                       rc = errno;
+                               }
+                       }
+               }
+       }
 
         if (rc) {
                 char *cli;
index 37a4812..2ec3489 100644 (file)
@@ -491,7 +491,7 @@ struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type)
 
        /* This deals with duplicate ldd_mount_types resolving to same OSD layer
         * plugin (e.g. ext3/ldiskfs/ldiskfs2 all being ldiskfs) */
-       strlcpy(fsname, mt_type(mount_type), sizeof(fsname));
+       strncpy(fsname, mt_type(mount_type), sizeof(fsname));
        name = fsname + sizeof("osd-") - 1;
 
        /* change osd- to osd_ */
index 0dc4ed9..e1e1b0e 100644 (file)
@@ -1110,7 +1110,9 @@ int jt_obd_alloc_fids(struct jt_fid_space *space, struct lu_fid *fid,
         fid->f_oid = space->jt_id;
         fid->f_ver = 0;
 
-        space->jt_id = min(space->jt_id + *count, space->jt_width);
+       space->jt_id = space->jt_id + *count;
+       if (space->jt_id > space->jt_width)
+               space->jt_id = space->jt_width;
 
         *count = space->jt_id - fid->f_oid;
         return 0;
@@ -3310,7 +3312,10 @@ static int nodemap_cmd(enum lcfg_command_type cmd, void *ret_data,
                if (rc != 0)
                        goto out;
 
-               memcpy(ret_data, data.ioc_pbuf1, min(data.ioc_plen1, ret_size));
+               if (ret_size > data.ioc_plen1)
+                       ret_size = data.ioc_plen1;
+
+               memcpy(ret_data, data.ioc_pbuf1, ret_size);
        }
 out:
        lustre_cfg_free(lcfg);
index 22c4324..16a6dce 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <libcfs/libcfs.h>
-#include <lustre/lustre_idl.h>
+#include <linux/types.h>
 
 #define __REQ_LAYOUT_USER__ (1)
+#define EXPORT_SYMBOL(s)
+
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
+#include <lustre_req_layout.h>
 
 #define lustre_swab_generic_32s NULL
 #define lustre_swab_lu_seq_range NULL