Whamcloud - gitweb
b=17167 libcfs: ensure all libcfs exported symbols to have cfs_ prefix
authorLisa Week <lisa.week@sun.com>
Thu, 14 Jan 2010 05:44:06 +0000 (22:44 -0700)
committerRobert Read <rread@sun.com>
Thu, 14 Jan 2010 16:33:51 +0000 (08:33 -0800)
i=Andreas Dilger

403 files changed:
build/nn-check.py [new file with mode: 0755]
build/nn-final-symbol-list.txt [new file with mode: 0644]
libcfs/include/libcfs/bitmap.h
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_debug.h
libcfs/include/libcfs/libcfs_hash.h
libcfs/include/libcfs/libcfs_ioctl.h
libcfs/include/libcfs/libcfs_prim.h
libcfs/include/libcfs/libcfs_private.h
libcfs/include/libcfs/libcfs_time.h
libcfs/include/libcfs/linux/Makefile.am
libcfs/include/libcfs/linux/kp30.h
libcfs/include/libcfs/linux/libcfs.h
libcfs/include/libcfs/linux/linux-bitops.h [new file with mode: 0644]
libcfs/include/libcfs/linux/linux-fs.h
libcfs/include/libcfs/linux/linux-lock.h
libcfs/include/libcfs/linux/linux-mem.h
libcfs/include/libcfs/linux/linux-prim.h
libcfs/include/libcfs/linux/linux-time.h
libcfs/include/libcfs/linux/linux-types.h [new file with mode: 0644]
libcfs/include/libcfs/linux/portals_compat25.h
libcfs/include/libcfs/list.h
libcfs/include/libcfs/posix/libcfs.h
libcfs/include/libcfs/posix/posix-types.h
libcfs/include/libcfs/user-bitops.h
libcfs/include/libcfs/user-lock.h
libcfs/include/libcfs/user-mem.h
libcfs/include/libcfs/user-prim.h
libcfs/include/libcfs/user-time.h
libcfs/include/libcfs/util/platform.h
libcfs/include/libcfs/winnt/kp30.h
libcfs/include/libcfs/winnt/libcfs.h
libcfs/include/libcfs/winnt/portals_utils.h
libcfs/include/libcfs/winnt/winnt-fs.h
libcfs/include/libcfs/winnt/winnt-lock.h
libcfs/include/libcfs/winnt/winnt-mem.h
libcfs/include/libcfs/winnt/winnt-prim.h
libcfs/include/libcfs/winnt/winnt-tcpip.h
libcfs/include/libcfs/winnt/winnt-time.h
libcfs/include/libcfs/winnt/winnt-types.h
libcfs/libcfs/darwin/darwin-tracefile.c
libcfs/libcfs/debug.c
libcfs/libcfs/hash.c
libcfs/libcfs/linux/linux-debug.c
libcfs/libcfs/linux/linux-fs.c
libcfs/libcfs/linux/linux-module.c
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/linux/linux-proc.c
libcfs/libcfs/linux/linux-tcpip.c
libcfs/libcfs/linux/linux-tracefile.c
libcfs/libcfs/linux/linux-tracefile.h
libcfs/libcfs/lwt.c
libcfs/libcfs/module.c
libcfs/libcfs/nidstrings.c
libcfs/libcfs/posix/posix-debug.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h
libcfs/libcfs/user-bitops.c
libcfs/libcfs/user-lock.c
libcfs/libcfs/user-prim.c
libcfs/libcfs/watchdog.c
libcfs/libcfs/winnt/winnt-curproc.c
libcfs/libcfs/winnt/winnt-fs.c
libcfs/libcfs/winnt/winnt-lock.c
libcfs/libcfs/winnt/winnt-mem.c
libcfs/libcfs/winnt/winnt-module.c
libcfs/libcfs/winnt/winnt-native.c
libcfs/libcfs/winnt/winnt-prim.c
libcfs/libcfs/winnt/winnt-proc.c
libcfs/libcfs/winnt/winnt-sync.c
libcfs/libcfs/winnt/winnt-tcpip.c
libcfs/libcfs/winnt/winnt-tracefile.c
libcfs/libcfs/winnt/winnt-tracefile.h
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/include/lnet/lnetst.h
lnet/klnds/gmlnd/gmlnd.h
lnet/klnds/gmlnd/gmlnd_api.c
lnet/klnds/gmlnd/gmlnd_cb.c
lnet/klnds/gmlnd/gmlnd_comm.c
lnet/klnds/gmlnd/gmlnd_utils.c
lnet/klnds/mxlnd/mxlnd.c
lnet/klnds/mxlnd/mxlnd.h
lnet/klnds/mxlnd/mxlnd_cb.c
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/ptllnd/ptllnd.c
lnet/klnds/ptllnd/ptllnd.h
lnet/klnds/ptllnd/ptllnd_cb.c
lnet/klnds/ptllnd/ptllnd_peer.c
lnet/klnds/ptllnd/ptllnd_ptltrace.c
lnet/klnds/ptllnd/ptllnd_rx_buf.c
lnet/klnds/ptllnd/ptllnd_tx.c
lnet/klnds/ptllnd/wirecheck.c
lnet/klnds/qswlnd/qswlnd.c
lnet/klnds/qswlnd/qswlnd.h
lnet/klnds/qswlnd/qswlnd_cb.c
lnet/klnds/ralnd/ralnd.c
lnet/klnds/ralnd/ralnd.h
lnet/klnds/ralnd/ralnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_lib-linux.c
lnet/klnds/socklnd/socklnd_lib-winnt.c
lnet/klnds/socklnd/socklnd_lib-winnt.h
lnet/klnds/socklnd/socklnd_proto.c
lnet/lnet/acceptor.c
lnet/lnet/api-ni.c
lnet/lnet/config.c
lnet/lnet/lib-eq.c
lnet/lnet/lib-md.c
lnet/lnet/lib-me.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/module.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/lnet/router_proc.c
lnet/selftest/brw_test.c
lnet/selftest/conctl.c
lnet/selftest/conrpc.c
lnet/selftest/conrpc.h
lnet/selftest/console.c
lnet/selftest/console.h
lnet/selftest/framework.c
lnet/selftest/ping_test.c
lnet/selftest/rpc.c
lnet/selftest/selftest.h
lnet/selftest/timer.c
lnet/selftest/timer.h
lnet/selftest/winnt/selftest-winnt.c
lnet/selftest/workitem.c
lnet/ulnds/ptllnd/ptllnd.c
lnet/ulnds/ptllnd/ptllnd.h
lnet/ulnds/ptllnd/ptllnd_cb.c
lnet/ulnds/socklnd/conn.c
lnet/ulnds/socklnd/handlers.c
lnet/ulnds/socklnd/poll.c
lnet/ulnds/socklnd/usocklnd.c
lnet/ulnds/socklnd/usocklnd.h
lnet/ulnds/socklnd/usocklnd_cb.c
lnet/utils/debug.c
lnet/utils/lst.c
lnet/utils/portals.c
lustre/cmm/cmm_device.c
lustre/cmm/cmm_internal.h
lustre/cmm/cmm_object.c
lustre/cmm/cmm_split.c
lustre/cmm/mdc_device.c
lustre/cmm/mdc_internal.h
lustre/fid/fid_handler.c
lustre/fid/fid_request.c
lustre/fid/lproc_fid.c
lustre/fld/fld_cache.c
lustre/fld/fld_handler.c
lustre/fld/fld_internal.h
lustre/fld/fld_request.c
lustre/fld/lproc_fld.c
lustre/include/cl_object.h
lustre/include/dt_object.h
lustre/include/lclient.h
lustre/include/liblustre.h
lustre/include/linux/lprocfs_status.h
lustre/include/linux/lustre_compat25.h
lustre/include/linux/lustre_fsfilt.h
lustre/include/linux/lustre_handles.h
lustre/include/linux/lustre_lite.h
lustre/include/linux/lustre_patchless_compat.h
lustre/include/linux/lvfs.h
lustre/include/linux/lvfs_linux.h
lustre/include/linux/obd.h
lustre/include/lprocfs_status.h
lustre/include/lu_object.h
lustre/include/lu_ref.h
lustre/include/lu_target.h
lustre/include/lustre/lustre_user.h
lustre/include/lustre_capa.h
lustre/include/lustre_cfg.h
lustre/include/lustre_disk.h
lustre/include/lustre_dlm.h
lustre/include/lustre_export.h
lustre/include/lustre_fid.h
lustre/include/lustre_fld.h
lustre/include/lustre_handles.h
lustre/include/lustre_idmap.h
lustre/include/lustre_import.h
lustre/include/lustre_lib.h
lustre/include/lustre_lite.h
lustre/include/lustre_log.h
lustre/include/lustre_mdc.h
lustre/include/lustre_net.h
lustre/include/lustre_quota.h
lustre/include/lustre_sec.h
lustre/include/lustre_ucache.h
lustre/include/md_object.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/include/obd_ost.h
lustre/include/obd_support.h
lustre/lclient/lcommon_cl.c
lustre/lclient/lcommon_misc.c
lustre/ldlm/l_lock.c
lustre/ldlm/ldlm_extent.c
lustre/ldlm/ldlm_flock.c
lustre/ldlm/ldlm_inodebits.c
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_plain.c
lustre/ldlm/ldlm_pool.c
lustre/ldlm/ldlm_request.c
lustre/ldlm/ldlm_resource.c
lustre/liblustre/dir.c
lustre/liblustre/file.c
lustre/liblustre/llite_lib.c
lustre/liblustre/llite_lib.h
lustre/liblustre/lutil.c
lustre/liblustre/namei.c
lustre/liblustre/rw.c
lustre/liblustre/super.c
lustre/llite/dcache.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_capa.c
lustre/llite/llite_close.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_mmap.c
lustre/llite/llite_rmtacl.c
lustre/llite/lloop.c
lustre/llite/lproc_llite.c
lustre/llite/namei.c
lustre/llite/remote_perm.c
lustre/llite/rw.c
lustre/llite/statahead.c
lustre/llite/super25.c
lustre/llite/vvp_dev.c
lustre/llite/vvp_io.c
lustre/llite/vvp_lock.c
lustre/llite/vvp_object.c
lustre/llite/xattr.c
lustre/lmv/lmv_internal.h
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_object.c
lustre/lmv/lproc_lmv.c
lustre/lov/lov_cl_internal.h
lustre/lov/lov_dev.c
lustre/lov/lov_internal.h
lustre/lov/lov_io.c
lustre/lov/lov_lock.c
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/lov/lov_pack.c
lustre/lov/lov_pool.c
lustre/lov/lov_qos.c
lustre/lov/lov_request.c
lustre/lov/lovsub_lock.c
lustre/lvfs/fsfilt.c
lustre/lvfs/fsfilt_ext3.c
lustre/lvfs/fsfilt_reiserfs.c
lustre/lvfs/lustre_quota_fmt.c
lustre/lvfs/lustre_quota_fmt.h
lustre/lvfs/lvfs_lib.c
lustre/lvfs/lvfs_linux.c
lustre/lvfs/prng.c
lustre/lvfs/quotafmt_test.c
lustre/lvfs/upcall_cache.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_device.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lock.c
lustre/mdd/mdd_lov.c
lustre/mdd/mdd_lproc.c
lustre/mdd/mdd_object.c
lustre/mds/handler.c
lustre/mds/lproc_mds.c
lustre/mds/mds_lov.c
lustre/mdt/mdt_capa.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_identity.c
lustre/mdt/mdt_idmap.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_recovery.c
lustre/mdt/mdt_reint.c
lustre/mgc/mgc_request.c
lustre/mgs/lproc_mgs.c
lustre/mgs/mgs_fs.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/mgs/mgs_llog.c
lustre/obdclass/capa.c
lustre/obdclass/cl_io.c
lustre/obdclass/cl_lock.c
lustre/obdclass/cl_object.c
lustre/obdclass/cl_page.c
lustre/obdclass/class_obd.c
lustre/obdclass/dt_object.c
lustre/obdclass/genops.c
lustre/obdclass/idmap.c
lustre/obdclass/linux/linux-module.c
lustre/obdclass/linux/linux-obdo.c
lustre/obdclass/linux/linux-sysctl.c
lustre/obdclass/llog.c
lustre/obdclass/llog_cat.c
lustre/obdclass/llog_internal.h
lustre/obdclass/llog_ioctl.c
lustre/obdclass/llog_obd.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/lu_object.c
lustre/obdclass/lu_ref.c
lustre/obdclass/lu_time.c
lustre/obdclass/lustre_handles.c
lustre/obdclass/lustre_peer.c
lustre/obdclass/md_local_object.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/obdclass/obdo.c
lustre/obdclass/statfs_pack.c
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_capa.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/obdfilter/filter_io_26.c
lustre/obdfilter/filter_log.c
lustre/obdfilter/filter_lvb.c
lustre/obdfilter/lproc_obdfilter.c
lustre/osc/lproc_osc.c
lustre/osc/osc_cl_internal.h
lustre/osc/osc_create.c
lustre/osc/osc_dev.c
lustre/osc/osc_internal.h
lustre/osc/osc_io.c
lustre/osc/osc_lock.c
lustre/osc/osc_object.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c
lustre/osd/osd_handler.c
lustre/osd/osd_iam.c
lustre/osd/osd_iam.h
lustre/osd/osd_iam_lfix.c
lustre/osd/osd_iam_lvar.c
lustre/osd/osd_internal.h
lustre/osd/osd_oi.c
lustre/ost/ost_handler.c
lustre/ptlrpc/client.c
lustre/ptlrpc/connection.c
lustre/ptlrpc/events.c
lustre/ptlrpc/gss/gss_api.h
lustre/ptlrpc/gss/gss_cli_upcall.c
lustre/ptlrpc/gss/gss_internal.h
lustre/ptlrpc/gss/gss_keyring.c
lustre/ptlrpc/gss/gss_krb5_mech.c
lustre/ptlrpc/gss/gss_mech_switch.c
lustre/ptlrpc/gss/gss_pipefs.c
lustre/ptlrpc/gss/gss_rawobj.c
lustre/ptlrpc/gss/gss_svc_upcall.c
lustre/ptlrpc/gss/lproc_gss.c
lustre/ptlrpc/gss/sec_gss.c
lustre/ptlrpc/import.c
lustre/ptlrpc/layout.c
lustre/ptlrpc/llog_client.c
lustre/ptlrpc/llog_net.c
lustre/ptlrpc/llog_server.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpc_module.c
lustre/ptlrpc/ptlrpcd.c
lustre/ptlrpc/recov_thread.c
lustre/ptlrpc/recover.c
lustre/ptlrpc/sec.c
lustre/ptlrpc/sec_bulk.c
lustre/ptlrpc/sec_config.c
lustre/ptlrpc/sec_gc.c
lustre/ptlrpc/sec_lproc.c
lustre/ptlrpc/sec_null.c
lustre/ptlrpc/sec_plain.c
lustre/ptlrpc/service.c
lustre/ptlrpc/target.c
lustre/quota/lproc_quota.c
lustre/quota/quota_adjust_qunit.c
lustre/quota/quota_check.c
lustre/quota/quota_context.c
lustre/quota/quota_ctl.c
lustre/quota/quota_interface.c
lustre/quota/quota_internal.h
lustre/quota/quota_master.c
lustre/tests/it_test.c
lustre/utils/obd.c

diff --git a/build/nn-check.py b/build/nn-check.py
new file mode 100755 (executable)
index 0000000..12d28aa
--- /dev/null
@@ -0,0 +1,131 @@
+#!/usr/bin/python
+
+# This script is for checking that patches don't introduce non-portable symbols
+# into the Lustre/LNET/libcfs code.
+#
+# Input:
+# 1. (Required) Filename (including path) of the diff file to be checked
+# 2. (Optional) path to the nn-final-symbol-list.txt file (By default, this
+#    script looks for nn-final-symbol-list.txt in the current working
+#    directory.)
+#
+# Output:
+# The output of this script is either PASS or FAIL (with WARNINGS).
+# FAIL means that there may have been symbols found that are not supposed
+# to be used.  This requires the person running the script to look into the
+# WARNINGS that are in the output to determine if there is a problem.
+
+# Author: lisa.week@sun.com
+
+import string
+import re
+import sys
+import optparse
+import os.path
+import fileinput
+
+# Setup command line options for nn-check.py
+from optparse import OptionParser
+usage = "%prog DIFF-FILE [options]"
+parser = OptionParser(usage)
+parser.add_option("-s", "--symb", action="store", dest="symb_pathname",
+                 help="(Optional) PATH to nn-final-symbol-list.txt file",
+                 metavar="PATH")
+
+(options, args) = parser.parse_args()
+
+# Check if we have the minimum number of arguments supplied. 
+if len(args) < 1:
+       parser.error("Incorrect number of arguments, see nn-check -h for help.")
+
+# Check if we were passed a path to the nn-final-symbol-list.txt file
+if options.symb_pathname:
+       symb_file = os.path.join(options.symb_pathname,
+                                 'nn-final-symbol-list.txt')
+else:
+       symb_file = 'nn-final-symbol-list.txt'
+
+# Global Variables
+bad_symbol_cnt = 0
+symbol_dict = dict() 
+
+# Function Definitions
+def search_symbol(line, linenum):
+       global bad_symbol_cnt
+
+       for key, val in symbol_dict.items():
+               regex_match = val.search(line)
+
+               if regex_match:
+                       print_symbol = regex_match.group(0)
+                       print 'WARNING: Found %s at line %d:' \
+                               % (print_symbol, linenum)
+                       print '%s' % line.rstrip()
+                       bad_symbol_cnt += 1
+
+# The main portion of the script
+print '================='
+print 'Starting nn-check'
+print '================='
+
+# Open the nn-final-symbol-list.txt file and pull in the symbols to check into
+# a dictionary object.
+try:
+       f = fileinput.input(symb_file)
+except IOError:
+       print 'nn-check.py: error: %s not found.' % symb_file
+       print 'Is nn-final-symbol-list.txt is in your current working directory'
+       print 'or have you have passed nn-check.py a valid path to the file?'
+       sys.exit(1)
+
+
+for line in f:
+       stripped_symbol = line.rstrip()
+       symbol_dict[stripped_symbol] = re.compile(stripped_symbol)
+
+# Close nn-final-symbol-list.txt
+f.close()
+
+# Open the diff file passed to the script and parse it for the symbols from
+# nn-final-symbol-list.txt
+try:
+       f = fileinput.input(sys.argv[1])
+except IOError:
+       print 'nn-check.py: error: %s not found.' % sys.argv[1] 
+       print 'Check the path provided for the diff file.'
+       sys.exit(1)
+
+index = re.compile(r'^\+\+\+ b/(.*)')
+plus = re.compile(r'^\+')
+for line in f:
+       # Check for the "diff --cc " delimiter in order to grab the file name.
+       index_match = index.match(line)
+
+       if index_match:
+               # Store the file name
+               filename=index_match.group(1)
+               print '--> Checking File: %s' % filename
+       else:
+               # Check if the line starts with a "+" character.
+               plus_match = plus.match(line)
+               if plus_match:
+                       # The line starts with a "+" character.  Look for
+                       # non-portable symbols
+                       search_symbol(line, f.lineno())
+               else:
+                       continue
+
+# Close the diff file
+f.close()
+
+# Finish up and print the results of the script (i.e. total number of
+# bad symbols found)
+if bad_symbol_cnt != 0:
+       print '=============================='
+       print 'Finished nn-check status: FAIL'
+       print '=============================='
+       print 'Found %d potential problem(s).  See "WARNINGS" from script output and refer to https://wikis.lustre.org/intra/index.php/Lustre_Name_Normalization for the complete set of rules to make sure you have not used a non-portable symbol.' % bad_symbol_cnt
+else:
+       print '=============================='
+       print 'Finished nn-check status: PASS'
+       print '=============================='
diff --git a/build/nn-final-symbol-list.txt b/build/nn-final-symbol-list.txt
new file mode 100644 (file)
index 0000000..e2aa87e
--- /dev/null
@@ -0,0 +1,334 @@
+\blist_head\b
+\bspin_unlock\b
+\bspin_lock\b
+\blist_empty\b
+\batomic_read\b
+\blist_entry\b
+\blist_add_tail\b
+\blist_del_init\b
+\batomic_inc\b
+\blist_for_each\b
+\bspinlock_t\b
+\blist_add\b
+\bspin_unlock_irqrestore\b
+\batomic_t\b
+\bup\b
+\bspin_lock_irqsave\b
+\bspin_lock_init\b
+\blist_for_each_entry\b
+\bwrite_unlock_irqrestore\b
+\batomic_set\b
+\bdown\b
+\bhlist_node\b
+\bHZ\b
+\batomic_dec\b
+\bcompletion\b
+\blist_for_each_safe\b
+\bin_interrupt\b
+\blist_for_each_entry_safe\b
+\bmutex_up\b
+\bwrite_lock_irqsave\b
+\bcopy_from_user\b
+\bcopy_to_user\b
+\batomic_dec_and_test\b
+\bmutex_down\b
+\bspin_unlock_bh\b
+\bsemaphore\b
+\bread_unlock\b
+\btest_bit\b
+\bup_write\b
+\bsize_round\b
+\bread_lock\b
+\bread_unlock_irqrestore\b
+\bset_current_state\b
+\bhlist_head\b
+\bspin_lock_bh\b
+\bdo_gettimeofday\b
+\bgroup_info\b
+\bset_bit\b
+\bdown_write\b
+\bup_read\b
+\bread_lock_irqsave\b
+\bwrite_unlock\b
+\bwrite_lock\b
+\brwlock_t\b
+\bhlist_entry\b
+\bmutex_unlock\b
+\bdown_read\b
+\bnum_physpages\b
+\bmutex\b
+\bsema_init\b
+\bmutex_lock\b
+\bclear_bit\b
+\bmb\b
+\bATOMIC_INIT\b
+\btime_after_eq\b
+\blist_splice_init\b
+\bcomplete\b
+\bkstatfs\b
+\bwait_for_completion\b
+\bnum_online_cpus\b
+\bhlist_unhashed\b
+\bLIST_HEAD\b
+\blist_for_each_entry_reverse\b
+\bSPIN_LOCK_UNLOCKED\b
+\binit_completion\b
+\bmight_sleep\b
+\brwlock_init\b
+\bkernel_thread\b
+\bhlist_add_head\b
+\blist_move\b
+\bunlock_kernel\b
+\bschedule_timeout\b
+\brw_semaphore\b
+\bmodule\b
+\bhlist_del_init\b
+\batomic_inc_return\b
+\btime_after\b
+\bmodule_put\b
+\binit_mutex\b
+\bget_random_bytes\b
+\bin_group_p\b
+\btime_before\b
+\bumode_t\b
+\binit_rwsem\b
+\bhlist_for_each_entry_safe\b
+\bmutex_init\b
+\block_kernel\b
+\btry_module_get\b
+\bCURRENT_TIME\b
+\brequest_module\b
+\block_class_key\b
+\bhlist_empty\b
+\bhlist_for_each_entry\b
+\bnum_possible_cpus\b
+\blist_splice\b
+\bour_cond_resched\b
+\bshrinker\b
+\bspin_unlock_irq\b
+\btest_and_set_bit\b
+\bDECLARE_MUTEX\b
+\bINIT_HLIST_NODE\b
+\bdown_write_nested\b
+\bspin_lock_irq\b
+\bsize_round4\b
+\bwait_event\b
+\bINIT_HLIST_HEAD\b
+\bMAX_SCHEDULE_TIMEOUT\b
+\bSLAB_HWCACHE_ALIGN\b
+\bcdebug_show\b
+\bcycles_t\b
+\bgroups_free\b
+\bDEFAULT_SEEKS\b
+\bGET_TIMEOUT\b
+\bremove_shrinker\b
+\bset_shrinker\b
+\batomic_sub\b
+\bgroups_alloc\b
+\bhlist_for_each\b
+\bhlist_for_each_safe\b
+\bNR_IRQS\b
+\bhlist_del\b
+\batomic_add_return\b
+\binit_MUTEX_LOCKED\b
+\binit_mutex_locked\b
+\blist_for_each_prev\b
+\bcpu_online\b
+\binit_MUTEX\b
+\bFREE_BITMAP\b
+\bL1_CACHE_ALIGN\b
+\batomic_dec_and_lock\b
+\bfind_first_zero_bit\b
+\bmutex_trylock\b
+\bHLIST_HEAD\b
+\batomic_dec_return\b
+\bcond_resched\b
+\bhash_long\b
+\bmutex_is_locked\b
+\bdown_read_nested\b
+\bmutex_lock_nested\b
+\bwait_event_interruptible_exclusive\b
+\bwait_event_interruptible\b
+\batomic_add\b
+\bCHECK_STACK\b
+\bfor_each_possible_cpu\b
+\bALLOCATE_BITMAP\b
+\bDEFINE_MUTEX\b
+\blist_empty_careful\b
+\bwrite_lock_bh\b
+\bwrite_unlock_bh\b
+\bTHREAD_SIZE\b
+\blist_for_each_entry_safe_from\b
+\bshrinker_t\b
+\bwait_for_completion_interruptible\b
+\bmutex_destroy\b
+\bdown_read_trylock\b
+\bdown_write_trylock\b
+\bfind_next_zero_bit\b
+\bspin_lock_nested\b
+\bspin_trylock\b
+\bbitmap_t\b
+\bsmp_processor_id\b
+\btracefile\b
+\btracefile_sem\b
+\bKERN_ERR\b
+\bDECLARE_COMPLETION\b
+\bhlist_add_after\b
+\bhlist_add_before\b
+\bhlist_for_each_entry_continue\b
+\bhlist_for_each_entry_from\b
+\bINIT_COMPLETION\b
+\bround_strlen\b
+\bRW_LOCK_UNLOCKED\b
+\bsize_round0\b
+\bsize_round16\b
+\bsize_round32\b
+\blist_t\b
+\bmutex_t\b
+\bCOMPLETION_INITIALIZER\b
+\bHLIST_HEAD_INIT\b
+\btime_before_eq\b
+\bspin_is_locked\b
+\btrace_daemon_command_usrstr\b
+\btrace_debug_print\b
+\btrace_dump_debug_buffer_usrstr\b
+\btrace_refill_stock\b
+\btrace_set_debug_mb_usrstr\b
+\bfind_first_bit\b
+\b__list_splice\b
+\btrace_assertion_failed\b
+\btracefile_exit\b
+\btracefile_init\b
+\btrace_flush_pages\b
+\btrace_start_thread\b
+\b__list_add\b
+\btcd_owns_tage\b
+\bKERN_ALERT\b
+\bmutex_down_trylock\b
+\bspin_lock_bh_init\b
+\btrace_get_debug_mb\b
+\btage_allocated\b
+\btrace_daemon_command\b
+\btrace_set_debug_mb\b
+\bfind_next_bit\b
+\btrace_stop_thread\b
+\btracefile_init_arch\b
+\btrace_get_tcd\b
+\btrace_lock_tcd\b
+\btrace_unlock_tcd\b
+\btrace_copyout_string\b
+\btracefile_dump_all_pages\b
+\b__list_del\b
+\bKERN_EMERG\b
+\btracefile_fini_arch\b
+\btrace_get_console_buffer\b
+\btrace_max_debug_mb\b
+\btrace_put_console_buffer\b
+\btrace_copyin_string\b
+\btracefile_read_lock\b
+\btracefile_read_unlock\b
+\btrace_allocate_string_buffer\b
+\btrace_free_string_buffer\b
+\bdebug_file_path_arr\b
+\btrace_thread_sem\b
+\btracefile_write_lock\b
+\btracefile_write_unlock\b
+\btracefile_size\b
+\bprint_to_console\b
+\btrace_put_tcd\b
+\bdebug_file_path\b
+\bfini_rwsem\b
+\bKERN_WARNING\b
+\bcpumask_t\b
+\bcpus_empty\b
+\bfor_each_cpu_mask\b
+\bcpu_set\b
+\bcpus_weight\b
+\bset_cpus_allowed\b
+\bnodemask_t\b
+\blist_del\b
+\blist_move_tail\b
+\b__hlist_del\b
+\brwlock_fini\b
+\batomic_sub_return\b
+\batomic_inc_and_test\b
+\batomic_sub_and_test\b
+\bcall_wait_handler\b
+\binit_completion_module\b
+\bSLAB_DESTROY_BY_RCU\b
+\bSLAB_KERNEL\b
+\bSLAB_NOFS\b
+\bTASK_INTERRUPTIBLE\b
+\bTASK_RUNNING\b
+\bTRACEFILE_SIZE\b
+\btrace_cleanup\b
+\btrace_page\b
+\btrace_get_tage\b
+\btrace_cpu_data\b
+\btrace_get_tage_try\b
+\btrace_data\b
+\btage_from_list\b
+\btage_alloc\b
+\btage_free\b
+\btage_to_tail\b
+\btcd_shrink\b
+\btcd_for_each\b
+\btcd_for_each_type_lock\b
+\bschedule_timeout_interruptible\b
+\bINIT_LIST_HEAD\b
+\b__fls\b
+\bfls\b
+\b__flz\b
+\bflz\b
+\b__ffs\b
+\bffs\b
+\b__ffz\b
+\bffz\b
+\bDEBUG_FILE_PATH_DEFAULT\b
+\btrace_data_union\b
+\bKERN_CRIT\b
+\bKERN_NOTICE\b
+\bKERN_INFO\b
+\bKERN_DEBUG\b
+\bput_group_info\b
+\bget_group_info\b
+\bcleanup_group_info\b
+\bset_current_groups\b
+\btest_and_clear_bit\b
+\btrace_console_buffers\b
+\bset_ptldebug_header\b
+\btrace_buf_idx_get\b
+\btrace_buf_type_t\b
+\bTCD_TYPE_PROC\b
+\bTCD_TYPE_SOFTIRQ\b
+\bTCD_TYPE_IRQ\b
+\bTCD_TYPE_MAX\b
+\bTCD_TYPE_PASSIVE\b
+\bTCD_TYPE_DISPATCH\b
+\brcu_head\b
+\blockdep_on\b
+\blockdep_off\b
+\blockdep_set_class\b
+\b__module_get\b
+\bmodule_refcount\b
+\bNR_CPUS\b
+\bTRACE_CONSOLE_BUFFER_SIZE\b
+\bcomplete_and_wait\b
+\batomic_add_unless\b
+\batomic_inc_not_zero\b
+\bschedule\b
+\bcomplete_and_exit\b
+\binit_waitqueue_head\b
+\binit_waitqueue_entry\b
+\badd_wait_queue\b
+\badd_wait_queue_exclusive\b
+\bremove_wait_queue\b
+\bwaitqueue_active\b
+\bwake_up\b
+\bwake_up_nr\b
+\bwake_up_all\b
+\bwait_queue_head_t\b
+\bwait_queue_t\b
+\bDECLARE_RWSEM\b
+\bCFS_DECL_RWSEM\b
+\blist_for_each_entry_continue\b
index a593701..9f54a73 100644 (file)
 typedef struct {
         int             size;
         unsigned long   data[0];
-} bitmap_t;
+} cfs_bitmap_t;
 
 #define CFS_BITMAP_SIZE(nbits) \
-     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t))
+     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(cfs_bitmap_t))
 
 static inline
-bitmap_t *ALLOCATE_BITMAP(int size)
+cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size)
 {
-        bitmap_t *ptr;
+        cfs_bitmap_t *ptr;
 
         OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size));
         if (ptr == NULL)
@@ -59,42 +59,42 @@ bitmap_t *ALLOCATE_BITMAP(int size)
         RETURN (ptr);
 }
 
-#define FREE_BITMAP(ptr)        OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
+#define CFS_FREE_BITMAP(ptr)        OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))
 
 static inline
-void cfs_bitmap_set(bitmap_t *bitmap, int nbit)
+void cfs_bitmap_set(cfs_bitmap_t *bitmap, int nbit)
 {
-        set_bit(nbit, bitmap->data);
+        cfs_set_bit(nbit, bitmap->data);
 }
 
 static inline
-void cfs_bitmap_clear(bitmap_t *bitmap, int nbit)
+void cfs_bitmap_clear(cfs_bitmap_t *bitmap, int nbit)
 {
-        test_and_clear_bit(nbit, bitmap->data);
+        cfs_test_and_clear_bit(nbit, bitmap->data);
 }
 
 static inline
-int cfs_bitmap_check(bitmap_t *bitmap, int nbit)
+int cfs_bitmap_check(cfs_bitmap_t *bitmap, int nbit)
 {
-        return test_bit(nbit, bitmap->data);
+        return cfs_test_bit(nbit, bitmap->data);
 }
 
 static inline
-int cfs_bitmap_test_and_clear(bitmap_t *bitmap, int nbit)
+int cfs_bitmap_test_and_clear(cfs_bitmap_t *bitmap, int nbit)
 {
-        return test_and_clear_bit(nbit, bitmap->data);
+        return cfs_test_and_clear_bit(nbit, bitmap->data);
 }
 
 /* return 0 is bitmap has none set bits */
 static inline
-int cfs_bitmap_check_empty(bitmap_t *bitmap)
+int cfs_bitmap_check_empty(cfs_bitmap_t *bitmap)
 {
-        return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
+        return cfs_find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
 }
 
 #define cfs_foreach_bit(bitmap, pos) \
-       for((pos)=find_first_bit((bitmap)->data, bitmap->size);   \
+       for((pos)=cfs_find_first_bit((bitmap)->data, bitmap->size);   \
             (pos) < (bitmap)->size;                               \
-            (pos) = find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
+            (pos) = cfs_find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
 
 #endif
index 6ba53d3..bedc82f 100644 (file)
@@ -103,14 +103,8 @@ static inline int __is_po2(unsigned long long val)
 
 #include <libcfs/list.h>
 
-/* for_each_possible_cpu is defined newly, the former is
- * for_each_cpu(eg. sles9 and sles10) b=15878 */
-#ifndef for_each_possible_cpu
-# ifdef for_each_cpu
-#  define for_each_possible_cpu(cpu) for_each_cpu(cpu)
-# else
-#  error for_each_possible_cpu is not supported by kernel!
-# endif
+#ifndef cfs_for_each_possible_cpu
+#  error cfs_for_each_possible_cpu is not supported by kernel!
 #endif
 
 /* libcfs tcpip */
@@ -141,7 +135,7 @@ struct lc_watchdog *lc_watchdog_add(int time,
 
 /* Enables a watchdog and resets its timer. */
 void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout);
-#define GET_TIMEOUT(svc) (max_t(int, obd_timeout,                       \
+#define CFS_GET_TIMEOUT(svc) (max_t(int, obd_timeout,                   \
                           AT_OFF ? 0 : at_get(&svc->srv_at_estimate)) * \
                           svc->srv_watchdog_factor)
 
index 18cd208..1cc8844 100644 (file)
@@ -55,10 +55,7 @@ extern cfs_duration_t libcfs_console_max_delay;
 extern cfs_duration_t libcfs_console_min_delay;
 extern unsigned int libcfs_console_backoff;
 extern unsigned int libcfs_debug_binary;
-extern char debug_file_path_arr[1024];
-#ifdef __KERNEL__
-extern char *debug_file_path;
-#endif
+extern char libcfs_debug_file_path_arr[1024];
 
 int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys);
 int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
@@ -177,7 +174,7 @@ typedef struct {
 /**
  * Filters out logging messages based on mask and subsystem.
  */
-static inline int cdebug_show(unsigned int mask, unsigned int subsystem)
+static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem)
 {
         return mask & D_CANTMASK ||
                 ((libcfs_debug & mask) && (libcfs_subsystem_debug & subsystem));
@@ -185,9 +182,9 @@ static inline int cdebug_show(unsigned int mask, unsigned int subsystem)
 
 #define __CDEBUG(cdls, mask, format, ...)                               \
 do {                                                                    \
-        CHECK_STACK();                                                  \
+        CFS_CHECK_STACK();                                              \
                                                                         \
-        if (cdebug_show(mask, DEBUG_SUBSYSTEM))                         \
+        if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM))                     \
                 libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, mask,           \
                                  __FILE__, __FUNCTION__, __LINE__,      \
                                  format, ## __VA_ARGS__);               \
@@ -203,7 +200,7 @@ do {                                            \
 } while (0)
 
 #else /* !CDEBUG_ENABLED */
-static inline int cdebug_show(unsigned int mask, unsigned int subsystem)
+static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem)
 {
         return 0;
 }
@@ -335,17 +332,17 @@ extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
     libcfs_debug_vmsg2(cdls, subsys, mask, file, fn,line,NULL,NULL,format, ## __VA_ARGS__)
 
 #define cdebug_va(cdls, mask, file, func, line, fmt, args)      do {          \
-        CHECK_STACK();                                                        \
+        CFS_CHECK_STACK();                                                    \
                                                                               \
-        if (cdebug_show(mask, DEBUG_SUBSYSTEM))                               \
+        if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM))                           \
                 libcfs_debug_vmsg(cdls, DEBUG_SUBSYSTEM, (mask),              \
                                   (file), (func), (line), fmt, args);         \
 } while(0)
 
 #define cdebug(cdls, mask, file, func, line, fmt, ...) do {                   \
-        CHECK_STACK();                                                        \
+        CFS_CHECK_STACK();                                                    \
                                                                               \
-        if (cdebug_show(mask, DEBUG_SUBSYSTEM))                               \
+        if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM))                           \
                 libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, (mask),               \
                                  (file), (func), (line), fmt, ## __VA_ARGS__);\
 } while(0)
@@ -354,18 +351,18 @@ extern void libcfs_assertion_failed(const char *expr, const char *file,
                                     const char *fn, const int line);
 
 /* one more external symbol that tracefile provides: */
-extern int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
-                                const char *knl_buffer, char *append);
+extern int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
+                                    const char *knl_buffer, char *append);
 
 
 #if defined(HAVE_BGL_SUPPORT)
-#define DEBUG_FILE_PATH_DEFAULT "/bgl/ion/tmp/lustre-log"
+#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/bgl/ion/tmp/lustre-log"
 #elif defined(__arch_um__)
-#define DEBUG_FILE_PATH_DEFAULT "/r/tmp/lustre-log"
+#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/r/tmp/lustre-log"
 #elif defined(__WINNT__)
-#define DEBUG_FILE_PATH_DEFAULT "\\SystemRoot\\temp\\lustre-log"
+#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "\\SystemRoot\\temp\\lustre-log"
 #else
-#define DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"
+#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"
 #endif
 
 #endif /* __LIBCFS_DEBUG_H__ */
index bab504a..769854f 100644 (file)
@@ -65,6 +65,8 @@
 
 #if (defined __linux__ && defined __KERNEL__)
 #include <linux/hash.h>
+
+#define cfs_hash_long(val, bits)    hash_long(val, bits)
 #else
 /* Fast hashing routine for a long.
    (C) 2002 William Lee Irwin III, IBM */
@@ -79,7 +81,7 @@
 #error Define CFS_GOLDEN_RATIO_PRIME for your wordsize.
 #endif
 
-static inline unsigned long hash_long(unsigned long val, unsigned int bits)
+static inline unsigned long cfs_hash_long(unsigned long val, unsigned int bits)
 {
        unsigned long hash = val;
 
@@ -109,7 +111,7 @@ static inline unsigned long hash_long(unsigned long val, unsigned int bits)
 #if 0
 static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
 {
-       return hash_long((unsigned long)ptr, bits);
+       return cfs_hash_long((unsigned long)ptr, bits);
 }
 #endif
 
@@ -119,9 +121,9 @@ static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
 struct cfs_hash_ops;
 
 typedef struct cfs_hash_bucket {
-        struct hlist_head           hsb_head;       /* entries list */
-        atomic_t                    hsb_count;      /* current entries */
-        rwlock_t                    hsb_rwlock;     /* cfs_hash_bucket */
+        cfs_hlist_head_t            hsb_head;       /* entries list */
+        cfs_atomic_t                hsb_count;      /* current entries */
+        cfs_rwlock_t                hsb_rwlock;     /* cfs_hash_bucket */
 } cfs_hash_bucket_t;
 
 #define CFS_MAX_HASH_NAME 16
@@ -134,21 +136,21 @@ typedef struct cfs_hash {
         int                         hs_min_theta;   /* resize min threshold */
         int                         hs_max_theta;   /* resize max threshold */
         int                         hs_flags;       /* hash flags */
-        atomic_t                    hs_count;       /* current entries */
-        atomic_t                    hs_rehash_count;/* resize count */
+        cfs_atomic_t                hs_count;       /* current entries */
+        cfs_atomic_t                hs_rehash_count;/* resize count */
         struct cfs_hash_bucket    **hs_buckets;     /* hash buckets */
         struct cfs_hash_ops        *hs_ops;         /* hash operations */
-        rwlock_t                    hs_rwlock;      /* cfs_hash */
+        cfs_rwlock_t                hs_rwlock;      /* cfs_hash */
         char                        hs_name[CFS_MAX_HASH_NAME];
 } cfs_hash_t;
 
 typedef struct cfs_hash_ops {
         unsigned (*hs_hash)(cfs_hash_t *hs, void *key, unsigned mask);
-        void *   (*hs_key)(struct hlist_node *hnode);
-        int      (*hs_compare)(void *key, struct hlist_node *hnode);
-        void *   (*hs_get)(struct hlist_node *hnode);
-        void *   (*hs_put)(struct hlist_node *hnode);
-        void     (*hs_exit)(struct hlist_node *hnode);
+        void *   (*hs_key)(cfs_hlist_node_t *hnode);
+        int      (*hs_compare)(void *key, cfs_hlist_node_t *hnode);
+        void *   (*hs_get)(cfs_hlist_node_t *hnode);
+        void *   (*hs_put)(cfs_hlist_node_t *hnode);
+        void     (*hs_exit)(cfs_hlist_node_t *hnode);
 } cfs_hash_ops_t;
 
 #define CFS_HASH_DEBUG          0x0001  /* Enable expensive debug checks */
@@ -168,7 +170,7 @@ cfs_hash_id(cfs_hash_t *hs, void *key, unsigned mask)
 }
 
 static inline void *
-cfs_hash_key(cfs_hash_t *hs, struct hlist_node *hnode)
+cfs_hash_key(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
 {
         LASSERT(hs);
         LASSERT(hnode);
@@ -190,7 +192,7 @@ cfs_hash_key(cfs_hash_t *hs, struct hlist_node *hnode)
  *      ends up not being the case this would be a nice feature.
  */
 static inline int
-cfs_hash_compare(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
+cfs_hash_compare(cfs_hash_t *hs, void *key, cfs_hlist_node_t *hnode)
 {
         LASSERT(hs);
         LASSERT(hnode);
@@ -203,7 +205,7 @@ cfs_hash_compare(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
 }
 
 static inline void *
-cfs_hash_get(cfs_hash_t *hs, struct hlist_node *hnode)
+cfs_hash_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
 {
         LASSERT(hs);
         LASSERT(hnode);
@@ -216,7 +218,7 @@ cfs_hash_get(cfs_hash_t *hs, struct hlist_node *hnode)
 }
 
 static inline void *
-cfs_hash_put(cfs_hash_t *hs, struct hlist_node *hnode)
+cfs_hash_put(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
 {
         LASSERT(hs);
         LASSERT(hnode);
@@ -229,7 +231,7 @@ cfs_hash_put(cfs_hash_t *hs, struct hlist_node *hnode)
 }
 
 static inline void
-cfs_hash_exit(cfs_hash_t *hs, struct hlist_node *hnode)
+cfs_hash_exit(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
 {
         LASSERT(hs);
         LASSERT(hnode);
@@ -242,7 +244,7 @@ cfs_hash_exit(cfs_hash_t *hs, struct hlist_node *hnode)
 /* Validate hnode references the correct key */
 static inline void
 __cfs_hash_key_validate(cfs_hash_t *hs, void *key,
-                        struct hlist_node *hnode)
+                        cfs_hlist_node_t *hnode)
 {
         if (unlikely(hs->hs_flags & CFS_HASH_DEBUG))
                 LASSERT(cfs_hash_compare(hs, key, hnode) > 0);
@@ -251,7 +253,7 @@ __cfs_hash_key_validate(cfs_hash_t *hs, void *key,
 /* Validate hnode is in the correct bucket */
 static inline void
 __cfs_hash_bucket_validate(cfs_hash_t *hs, cfs_hash_bucket_t *hsb,
-                           struct hlist_node *hnode)
+                           cfs_hlist_node_t *hnode)
 {
         unsigned i;
 
@@ -261,13 +263,13 @@ __cfs_hash_bucket_validate(cfs_hash_t *hs, cfs_hash_bucket_t *hsb,
         }
 }
 
-static inline struct hlist_node *
+static inline cfs_hlist_node_t *
 __cfs_hash_bucket_lookup(cfs_hash_t *hs,
                          cfs_hash_bucket_t *hsb, void *key)
 {
-        struct hlist_node *hnode;
+        cfs_hlist_node_t *hnode;
 
-        hlist_for_each(hnode, &hsb->hsb_head)
+        cfs_hlist_for_each(hnode, &hsb->hsb_head)
                 if (cfs_hash_compare(hs, key, hnode) > 0)
                         return hnode;
 
@@ -277,11 +279,11 @@ __cfs_hash_bucket_lookup(cfs_hash_t *hs,
 static inline void *
 __cfs_hash_bucket_add(cfs_hash_t *hs,
                       cfs_hash_bucket_t *hsb,
-                      struct hlist_node *hnode)
+                      cfs_hlist_node_t *hnode)
 {
-        hlist_add_head(hnode, &(hsb->hsb_head));
-        atomic_inc(&hsb->hsb_count);
-        atomic_inc(&hs->hs_count);
+        cfs_hlist_add_head(hnode, &(hsb->hsb_head));
+        cfs_atomic_inc(&hsb->hsb_count);
+        cfs_atomic_inc(&hs->hs_count);
 
         return cfs_hash_get(hs, hnode);
 }
@@ -289,13 +291,13 @@ __cfs_hash_bucket_add(cfs_hash_t *hs,
 static inline void *
 __cfs_hash_bucket_del(cfs_hash_t *hs,
                       cfs_hash_bucket_t *hsb,
-                      struct hlist_node *hnode)
+                      cfs_hlist_node_t *hnode)
 {
-        hlist_del_init(hnode);
-        LASSERT(atomic_read(&hsb->hsb_count) > 0);
-        atomic_dec(&hsb->hsb_count);
-        LASSERT(atomic_read(&hs->hs_count) > 0);
-        atomic_dec(&hs->hs_count);
+        cfs_hlist_del_init(hnode);
+        LASSERT(cfs_atomic_read(&hsb->hsb_count) > 0);
+        cfs_atomic_dec(&hsb->hsb_count);
+        LASSERT(cfs_atomic_read(&hs->hs_count) > 0);
+        cfs_atomic_dec(&hs->hs_count);
 
         return cfs_hash_put(hs, hnode);
 }
@@ -308,14 +310,14 @@ void cfs_hash_destroy(cfs_hash_t *hs);
 
 /* Hash addition functions */
 void cfs_hash_add(cfs_hash_t *hs, void *key,
-                  struct hlist_node *hnode);
+                  cfs_hlist_node_t *hnode);
 int cfs_hash_add_unique(cfs_hash_t *hs, void *key,
-                        struct hlist_node *hnode);
+                        cfs_hlist_node_t *hnode);
 void *cfs_hash_findadd_unique(cfs_hash_t *hs, void *key,
-                              struct hlist_node *hnode);
+                              cfs_hlist_node_t *hnode);
 
 /* Hash deletion functions */
-void *cfs_hash_del(cfs_hash_t *hs, void *key, struct hlist_node *hnode);
+void *cfs_hash_del(cfs_hash_t *hs, void *key, cfs_hlist_node_t *hnode);
 void *cfs_hash_del_key(cfs_hash_t *hs, void *key);
 
 /* Hash lookup/for_each functions */
@@ -333,7 +335,7 @@ void cfs_hash_for_each_key(cfs_hash_t *hs, void *key,
  */
 int cfs_hash_rehash(cfs_hash_t *hs, int bits);
 void cfs_hash_rehash_key(cfs_hash_t *hs, void *old_key,
-                         void *new_key, struct hlist_node *hnode);
+                         void *new_key, cfs_hlist_node_t *hnode);
 
 
 #define CFS_HASH_THETA_BITS  10
@@ -353,7 +355,7 @@ static inline int __cfs_hash_theta_frac(int theta)
 
 static inline int __cfs_hash_theta(cfs_hash_t *hs)
 {
-        return (atomic_read(&hs->hs_count) <<
+        return (cfs_atomic_read(&hs->hs_count) <<
                 CFS_HASH_THETA_BITS) >> hs->hs_cur_bits;
 }
 
index ce14af7..f08d2ef 100644 (file)
@@ -94,7 +94,7 @@ do {                                                    \
 #ifdef __KERNEL__
 
 struct libcfs_ioctl_handler {
-        struct list_head item;
+        cfs_list_t item;
         int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_data *data);
 };
 
@@ -156,8 +156,8 @@ struct libcfs_ioctl_handler {
 static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 {
         int len = sizeof(*data);
-        len += size_round(data->ioc_inllen1);
-        len += size_round(data->ioc_inllen2);
+        len += cfs_size_round(data->ioc_inllen1);
+        len += cfs_size_round(data->ioc_inllen2);
         return len;
 }
 
@@ -209,7 +209,7 @@ static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
                 return 1;
         }
         if (data->ioc_inllen2 &&
-            data->ioc_bulk[size_round(data->ioc_inllen1) +
+            data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
                            data->ioc_inllen2 - 1] != '\0') {
                 CERROR ("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
                 return 1;
index 3d38920..83493e8 100644 (file)
@@ -49,7 +49,9 @@
 /*
  * Schedule
  */
-void cfs_schedule_timeout(cfs_task_state_t state, int64_t timeout);
+void cfs_schedule_timeout_and_set_state(cfs_task_state_t state,
+                                        int64_t timeout);
+void cfs_schedule_timeout(int64_t timeout);
 void cfs_schedule(void);
 void cfs_pause(cfs_duration_t ticks);
 int  cfs_need_resched(void);
index d0fd499..db86bf4 100644 (file)
@@ -138,7 +138,7 @@ void lbug_with_loc(const char *file, const char *func, const int line)
 
 #define LBUG() lbug_with_loc(__FILE__, __FUNCTION__, __LINE__)
 
-extern atomic_t libcfs_kmemory;
+extern cfs_atomic_t libcfs_kmemory;
 /*
  * Memory
  */
@@ -146,11 +146,11 @@ extern atomic_t libcfs_kmemory;
 
 # define libcfs_kmem_inc(ptr, size)             \
 do {                                            \
-        atomic_add(size, &libcfs_kmemory);      \
+        cfs_atomic_add(size, &libcfs_kmemory);  \
 } while (0)
 
 # define libcfs_kmem_dec(ptr, size) do {        \
-        atomic_sub(size, &libcfs_kmemory);      \
+        cfs_atomic_sub(size, &libcfs_kmemory);  \
 } while (0)
 
 #else
@@ -162,7 +162,7 @@ do {                                            \
 
 #define LIBCFS_ALLOC_GFP(ptr, size, mask)                                 \
 do {                                                                      \
-        LASSERT(!in_interrupt() ||                                        \
+        LASSERT(!cfs_in_interrupt() ||                                    \
                (size <= LIBCFS_VMALLOC_SIZE && mask == CFS_ALLOC_ATOMIC));\
         if (unlikely((size) > LIBCFS_VMALLOC_SIZE))                       \
                 (ptr) = cfs_alloc_large(size);                            \
@@ -172,14 +172,14 @@ do {                                                                      \
                 CERROR("LNET: out of memory at %s:%d (tried to alloc '"   \
                        #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\
                 CERROR("LNET: %d total bytes allocated by lnet\n",        \
-                       atomic_read(&libcfs_kmemory));                     \
+                       cfs_atomic_read(&libcfs_kmemory));                 \
                 break;                                                    \
         }                                                                 \
         libcfs_kmem_inc((ptr), (size));                                   \
         if (!((mask) & CFS_ALLOC_ZERO))                                   \
                 memset((ptr), 0, (size));                                 \
         CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n",    \
-               (int)(size), (ptr), atomic_read (&libcfs_kmemory));        \
+               (int)(size), (ptr), cfs_atomic_read (&libcfs_kmemory));    \
 } while (0)
 
 #define LIBCFS_ALLOC(ptr, size) \
@@ -198,7 +198,7 @@ do {                                                                    \
         }                                                               \
         libcfs_kmem_dec((ptr), s);                                      \
         CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
-               s, (ptr), atomic_read(&libcfs_kmemory));                 \
+               s, (ptr), cfs_atomic_read(&libcfs_kmemory));             \
         if (unlikely(s > LIBCFS_VMALLOC_SIZE))                          \
                 cfs_free_large(ptr);                                    \
         else                                                            \
@@ -318,9 +318,9 @@ lnet_nid_t  libcfs_str2nid(const char *str);
 int         libcfs_str2anynid(lnet_nid_t *nid, const char *str);
 char       *libcfs_id2str(lnet_process_id_t id);
 int         cfs_iswhite(char c);
-void        cfs_free_nidlist(struct list_head *list);
-int         cfs_parse_nidlist(char *str, int len, struct list_head *list);
-int         cfs_match_nid(lnet_nid_t nid, struct list_head *list);
+void        cfs_free_nidlist(cfs_list_t *list);
+int         cfs_parse_nidlist(char *str, int len, cfs_list_t *list);
+int         cfs_match_nid(lnet_nid_t nid, cfs_list_t *list);
 
 /* how an LNET NID encodes net:address */
 #define LNET_NIDADDR(nid)      ((__u32)((nid) & 0xffffffff))
@@ -339,8 +339,8 @@ int         cfs_match_nid(lnet_nid_t nid, struct list_head *list);
 /* logical equivalence */
 #define equi(a, b) (!!(a) == !!(b))
 
-#ifndef CURRENT_TIME
-# define CURRENT_TIME time(0)
+#ifndef CFS_CURRENT_TIME
+# define CFS_CURRENT_TIME time(0)
 #endif
 
 /* --------------------------------------------------------------------
@@ -365,50 +365,50 @@ struct libcfs_device_userstate
 
 #define MKSTR(ptr) ((ptr))? (ptr) : ""
 
-static inline int size_round4 (int val)
+static inline int cfs_size_round4 (int val)
 {
         return (val + 3) & (~0x3);
 }
 
-static inline int size_round (int val)
+static inline int cfs_size_round (int val)
 {
         return (val + 7) & (~0x7);
 }
 
-static inline int size_round16(int val)
+static inline int cfs_size_round16(int val)
 {
         return (val + 0xf) & (~0xf);
 }
 
-static inline int size_round32(int val)
+static inline int cfs_size_round32(int val)
 {
         return (val + 0x1f) & (~0x1f);
 }
 
-static inline int size_round0(int val)
+static inline int cfs_size_round0(int val)
 {
         if (!val)
                 return 0;
         return (val + 1 + 7) & (~0x7);
 }
 
-static inline size_t round_strlen(char *fset)
+static inline size_t cfs_round_strlen(char *fset)
 {
-        return (size_t)size_round((int)strlen(fset) + 1);
+        return (size_t)cfs_size_round((int)strlen(fset) + 1);
 }
 
 #define LOGL(var,len,ptr)                                       \
 do {                                                            \
         if (var)                                                \
                 memcpy((char *)ptr, (const char *)var, len);    \
-        ptr += size_round(len);                                 \
+        ptr += cfs_size_round(len);                             \
 } while (0)
 
 #define LOGU(var,len,ptr)                                       \
 do {                                                            \
         if (var)                                                \
                 memcpy((char *)var, (const char *)ptr, len);    \
-        ptr += size_round(len);                                 \
+        ptr += cfs_size_round(len);                             \
 } while (0)
 
 #define LOGL0(var,len,ptr)                              \
@@ -417,7 +417,7 @@ do {                                                    \
                 break;                                  \
         memcpy((char *)ptr, (const char *)var, len);    \
         *((char *)(ptr) + len) = 0;                     \
-        ptr += size_round(len + 1);                     \
+        ptr += cfs_size_round(len + 1);                 \
 } while (0)
 
 /**
index 946c2be..96a1d75 100644 (file)
@@ -55,16 +55,6 @@ static inline cfs_duration_t cfs_time_sub(cfs_time_t t1, cfs_time_t t2)
         return (cfs_time_t)(t1 - t2);
 }
 
-static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
-{
-        return time_before(t1, t2);
-}
-
-static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
-{
-        return time_before_eq(t1, t2);
-}
-
 static inline int cfs_time_after(cfs_time_t t1, cfs_time_t t2)
 {
         return cfs_time_before(t2, t1);
index a1f46cc..874efed 100644 (file)
@@ -1,3 +1,3 @@
 EXTRA_DIST := kp30.h libcfs.h linux-fs.h linux-lock.h linux-mem.h      \
        linux-prim.h linux-time.h linux-tcpip.h lltrace.h               \
-       portals_compat25.h
\ No newline at end of file
+       portals_compat25.h linux-bitops.h linux-types.h
index ae23e8c..ba566f7 100644 (file)
@@ -90,12 +90,7 @@ do {                                                                          \
 
 #define PageUptodate Page_Uptodate
 #define our_recalc_sigpending(current) recalc_sigpending(current)
-#define num_online_cpus() smp_num_cpus
-static inline void our_cond_resched(void)
-{
-        if (current->need_resched)
-               schedule ();
-}
+#define cfs_num_online_cpus() smp_num_cpus
 #define work_struct_t                   struct tq_struct
 #define cfs_get_work_data(type,field,data)   (data)
 #else
@@ -120,13 +115,10 @@ do {                                                                          \
 
 #endif
 
+#define cfs_num_online_cpus() num_online_cpus()
 #define wait_on_page wait_on_page_locked
 #define our_recalc_sigpending(current) recalc_sigpending()
 #define strtok(a,b) strpbrk(a, b)
-static inline void our_cond_resched(void)
-{
-        cond_resched();
-}
 #define work_struct_t      struct work_struct
 
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
@@ -210,7 +202,9 @@ static inline void our_cond_resched(void)
 # define time(a) CURRENT_TIME
 
 #ifndef num_possible_cpus
-#define num_possible_cpus() NR_CPUS
+#define cfs_num_possible_cpus() NR_CPUS
+#else
+#define cfs_num_possible_cpus() num_possible_cpus()
 #endif
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 #define i_size_read(a) ((a)->i_size)
@@ -255,9 +249,9 @@ typedef struct {
 #  if !KLWT_SUPPORT
 
 typedef struct _lwt_page {
-        struct list_head     lwtp_list;
-        struct page         *lwtp_page;
-        lwt_event_t         *lwtp_events;
+        cfs_list_t               lwtp_list;
+        struct page             *lwtp_page;
+        lwt_event_t             *lwtp_events;
 } lwt_page_t;
 
 typedef struct {
@@ -292,8 +286,8 @@ do {                                                                    \
                                                                         \
                 if (cpu->lwtc_current_index >= LWT_EVENTS_PER_PAGE) {   \
                         cpu->lwtc_current_page =                        \
-                                list_entry (p->lwtp_list.next,          \
-                                            lwt_page_t, lwtp_list);     \
+                                cfs_list_entry (p->lwtp_list.next,      \
+                                                lwt_page_t, lwtp_list); \
                         cpu->lwtc_current_index = 0;                    \
                 }                                                       \
                                                                         \
@@ -316,7 +310,7 @@ extern void lwt_fini (void);
 extern int  lwt_lookup_string (int *size, char *knlptr,
                                char *usrptr, int usrsize);
 extern int  lwt_control (int enable, int clear);
-extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
+extern int  lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size,
                           void *user_ptr, int user_size);
 # else  /* __KERNEL__ */
 #  define LWT_EVENT(p1,p2,p3,p4)     /* no userland implementation yet */
@@ -405,6 +399,8 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
 }
 #endif
 
+#define cfs_smp_processor_id()  smp_processor_id()
+
 #ifndef get_cpu
 # ifdef CONFIG_PREEMPT
 #  define cfs_get_cpu()  ({ preempt_disable(); smp_processor_id(); })
index 9e75d75..eb27038 100644 (file)
@@ -53,6 +53,8 @@
 #include <libcfs/linux/linux-lock.h>
 #include <libcfs/linux/linux-fs.h>
 #include <libcfs/linux/linux-tcpip.h>
+#include <libcfs/linux/linux-bitops.h>
+#include <libcfs/linux/linux-types.h>
 #include <libcfs/linux/kp30.h>
 
 #ifdef HAVE_ASM_TYPES_H
@@ -62,6 +64,7 @@
 #include <asm/timex.h>
 #include <linux/sched.h> /* THREAD_SIZE */
 
+#define CFS_THREAD_SIZE   THREAD_SIZE
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
 #if !defined(__x86_64__)
@@ -77,7 +80,7 @@
 
 #define __CHECK_STACK(file, func, line)                                 \
 do {                                                                    \
-        unsigned long _stack = CDEBUG_STACK();                           \
+        unsigned long _stack = CDEBUG_STACK();                          \
                                                                         \
         if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) {        \
                 libcfs_stack = _stack;                                  \
@@ -88,9 +91,9 @@ do {                                                                    \
               /*panic("LBUG");*/                                        \
         }                                                               \
 } while (0)
-#define CHECK_STACK()     __CHECK_STACK(__FILE__, __func__, __LINE__)
+#define CFS_CHECK_STACK()     __CHECK_STACK(__FILE__, __func__, __LINE__)
 #else /* __x86_64__ */
-#define CHECK_STACK() do { } while(0)
+#define CFS_CHECK_STACK() do { } while(0)
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
diff --git a/libcfs/include/libcfs/linux/linux-bitops.h b/libcfs/include/libcfs/linux/linux-bitops.h
new file mode 100644 (file)
index 0000000..75e37a6
--- /dev/null
@@ -0,0 +1,53 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * 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  2009 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * libcfs/include/libcfs/linux/linux-bitops.h
+ */
+#include <linux/bitops.h>
+
+#define cfs_test_bit(nr, addr)              test_bit(nr, addr)
+#define cfs_set_bit(nr, addr)               set_bit(nr, addr)
+#define cfs_clear_bit(nr, addr)             clear_bit(nr, addr)
+#define cfs_test_and_set_bit(nr, addr)      test_and_set_bit(nr, addr)
+#define cfs_test_and_clear_bit(nr, addr)    test_and_clear_bit(nr, addr)
+#define cfs_find_first_bit(addr, size)      find_first_bit(addr, size)
+#define cfs_find_first_zero_bit(addr, size) find_first_zero_bit(addr, size)
+#define cfs_find_next_bit(addr, size, off)  find_next_bit(addr, size, off)
+#define cfs_find_next_zero_bit(addr, size, off) \
+        find_next_zero_bit(addr, size, off)
+
+#define cfs_ffz(x)                          ffz(x)
+#define cfs_ffs(x)                          ffs(x)
+#define cfs_fls(x)                          fls(x)
index dc9ab89..64d8936 100644 (file)
@@ -56,6 +56,7 @@
 typedef struct file cfs_file_t;
 typedef struct dentry cfs_dentry_t;
 typedef struct dirent64 cfs_dirent_t;
+typedef struct kstatfs cfs_kstatfs_t;
 
 #define cfs_filp_size(f)               (i_size_read((f)->f_dentry->d_inode))
 #define cfs_filp_poff(f)                (&(f)->f_pos)
index 67a65cb..789718e 100644 (file)
  * declared by CFS_DECL_* should be initialized explicitly.
  */
 
-
 /*
- * spin_lock (use Linux kernel's primitives)
+ * spin_lock "implementation" (use Linux kernel's primitives)
  *
  * - spin_lock_init(x)
  * - spin_lock(x)
+ * - spin_lock_bh(x)
+ * - spin_lock_bh_init(x)
  * - spin_unlock(x)
+ * - spin_unlock_bh(x)
  * - spin_trylock(x)
+ * - spin_is_locked(x)
  *
+ * - spin_lock_irq(x)
  * - spin_lock_irqsave(x, f)
  * - spin_unlock_irqrestore(x, f)
+ * - read_lock_irqsave(lock, f)
+ * - write_lock_irqsave(lock, f)
+ * - write_unlock_irqrestore(lock, f)
+ *
+ * - SPIN_LOCK_UNLOCKED
  */
 
 /*
- * rw_semaphore (use Linux kernel's primitives)
+ * spinlock "implementation"
+ */
+
+typedef spinlock_t cfs_spinlock_t;
+
+#define cfs_spin_lock_init(lock)             spin_lock_init(lock)
+#define cfs_spin_lock(lock)                  spin_lock(lock)
+#define cfs_spin_lock_bh(lock)               spin_lock_bh(lock)
+#define cfs_spin_lock_bh_init(lock)          spin_lock_bh_init(lock)
+#define cfs_spin_unlock(lock)                spin_unlock(lock)
+#define cfs_spin_unlock_bh(lock)             spin_unlock_bh(lock)
+#define cfs_spin_trylock(lock)               spin_trylock(lock)
+#define cfs_spin_is_locked(lock)             spin_is_locked(lock)
+
+#define cfs_spin_lock_irq(lock)              spin_lock_irq(lock)
+#define cfs_spin_unlock_irq(lock)            spin_unlock_irq(lock)
+#define cfs_read_lock_irqsave(lock, f)       read_lock_irqsave(lock, f)
+#define cfs_write_lock_irqsave(lock, f)      write_lock_irqsave(lock, f)
+#define cfs_write_unlock_irqrestore(lock, f) write_unlock_irqrestore(lock, f)
+#define cfs_spin_lock_irqsave(lock, f)       spin_lock_irqsave(lock, f)
+#define cfs_spin_unlock_irqrestore(lock, f)  spin_unlock_irqrestore(lock, f)
+
+#define CFS_SPIN_LOCK_UNLOCKED               SPIN_LOCK_UNLOCKED
+
+/*
+ * rw_semaphore "implementation" (use Linux kernel's primitives)
  *
+ * - sema_init(x)
  * - init_rwsem(x)
  * - down_read(x)
  * - up_read(x)
  * - down_write(x)
  * - up_write(x)
  */
-#define fini_rwsem(s) do {} while(0)
+typedef struct rw_semaphore cfs_rw_semaphore_t;
+
+#define cfs_sema_init(s, val)     sema_init(s, val)
+#define cfs_init_rwsem(s)         init_rwsem(s)
+#define cfs_down_read(s)          down_read(s)
+#define cfs_down_read_trylock(s)  down_read_trylock(s)
+#define cfs_up_read(s)            up_read(s)
+#define cfs_down_write(s)         down_write(s)
+#define cfs_down_write_trylock(s) down_write_trylock(s)
+#define cfs_up_write(s)           up_write(s)
+
+#define cfs_fini_rwsem(s)         do {} while(0)
+
+#define CFS_DECLARE_RWSEM(name)   DECLARE_RWSEM(name)
 
 /*
- * rwlock_t (use Linux kernel's primitives)
+ * semaphore "implementation" (use Linux kernel's primitives)
+ */
+typedef struct semaphore      cfs_semaphore_t;
+
+/*
+ * rwlock_t "implementation" (use Linux kernel's primitives)
  *
  * - rwlock_init(x)
  * - read_lock(x)
  * - read_unlock(x)
  * - write_lock(x)
  * - write_unlock(x)
+ * - write_lock_bh(x)
+ * - write_unlock_bh(x)
+ *
+ * - RW_LOCK_UNLOCKED
  */
+typedef rwlock_t cfs_rwlock_t;
+
+#define cfs_rwlock_init(lock)                  rwlock_init(lock)
+#define cfs_read_lock(lock)                    read_lock(lock)
+#define cfs_read_unlock(lock)                  read_unlock(lock)
+#define cfs_read_unlock_irqrestore(lock,flags) \
+        read_unlock_irqrestore(lock, flags)
+#define cfs_write_lock(lock)                   write_lock(lock)
+#define cfs_write_unlock(lock)                 write_unlock(lock)
+#define cfs_write_lock_bh(lock)                write_lock_bh(lock)
+#define cfs_write_unlock_bh(lock)              write_unlock_bh(lock)
+
+#define CFS_RW_LOCK_UNLOCKED                   RW_LOCK_UNLOCKED
 
 /*
- * mutex:
+ * completion "implementation" (use Linux kernel's primitives)
  *
- * - init_mutex(x)
- * - init_mutex_locked(x)
- * - mutex_up(x)
- * - mutex_down(x)
+ * - DECLARE_COMPLETION(work)
+ * - INIT_COMPLETION(c)
+ * - COMPLETION_INITIALIZER(work)
+ * - init_completion(c)
+ * - complete(c)
+ * - wait_for_completion(c)
+ * - wait_for_completion_interruptible(c)
+ * - fini_completion(c)
  */
-#define init_mutex(x)                   init_MUTEX(x)
-#define init_mutex_locked(x)            init_MUTEX_LOCKED(x)
-#define mutex_up(x)                     up(x)
-#define mutex_down(x)                   down(x)
-#define mutex_down_trylock(x)           down_trylock(x)
+typedef struct completion cfs_completion_t;
+
+#define CFS_DECLARE_COMPLETION(work)             DECLARE_COMPLETION(work)
+#define CFS_INIT_COMPLETION(c)                   INIT_COMPLETION(c)
+#define CFS_COMPLETION_INITIALIZER(work)         COMPLETION_INITIALIZER(work)
+#define cfs_init_completion(c)                   init_completion(c)
+#define cfs_complete(c)                          complete(c)
+#define cfs_wait_for_completion(c)               wait_for_completion(c)
+#define cfs_wait_for_completion_interruptible(c) \
+        wait_for_completion_interruptible(c)
+#define cfs_complete_and_exit(c, code)           complete_and_exit(c, code)
+#define cfs_fini_completion(c)                   do { } while (0)
 
 /*
- * completion (use Linux kernel's primitives)
+ * mutex "implementation" (use Linux kernel's primitives)
  *
- * - init_complition(c)
- * - complete(c)
- * - wait_for_completion(c)
+ * - DECLARE_MUTEX(name)
+ * - mutex_init(x)
+ * - init_mutex(x)
+ * - init_mutex_locked(x)
+ * - init_MUTEX_LOCKED(x)
+ * - mutex_up(x)
+ * - mutex_down(x)
+ * - up(x)
+ * - down(x)
+ * - mutex_down_trylock(x)
+ * - mutex_lock(x)
+ * - mutex_unlock(x)
  */
+typedef struct mutex cfs_mutex_t;
+
+#define CFS_DEFINE_MUTEX(name)             DEFINE_MUTEX(name)
+#define CFS_DECLARE_MUTEX(name)            DECLARE_MUTEX(name)
+
+#define cfs_mutex_init(x)                   mutex_init(x)
+#define cfs_init_mutex(x)                   init_MUTEX(x)
+#define cfs_init_mutex_locked(x)            init_MUTEX_LOCKED(x)
+#define cfs_mutex_up(x)                     up(x)
+#define cfs_mutex_down(x)                   down(x)
+#define cfs_up(x)                           up(x)
+#define cfs_down(x)                         down(x)
+#define cfs_mutex_down_trylock(x)           down_trylock(x)
+#define cfs_mutex_lock(x)                   mutex_lock(x)
+#define cfs_mutex_unlock(x)                 mutex_unlock(x)
+#define cfs_mutex_trylock(x)                mutex_trylock(x)
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
 
  *
  **************************************************************************/
 
-struct mutex;
-
-static inline void mutex_destroy(struct mutex *lock)
+static inline void cfs_mutex_destroy(cfs_mutex_t *lock)
 {
 }
 
@@ -140,12 +244,24 @@ static inline void mutex_destroy(struct mutex *lock)
  *
  * \retval 0 mutex is not locked. This should never happen.
  */
-static inline int mutex_is_locked(struct mutex *lock)
+static inline int cfs_mutex_is_locked(cfs_mutex_t *lock)
 {
         return 1;
 }
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) */
+#define cfs_mutex_destroy(x)    mutex_destroy(x)
+#define cfs_mutex_is_locked(x)  mutex_is_locked(x)
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) */
 
+/*
+ * Kernel locking primitives
+ *
+ * - lock_kernel
+ * - unlock_kernel
+ */
+#define cfs_lock_kernel()      lock_kernel()
+#define cfs_unlock_kernel()    unlock_kernel()
+
 #ifndef lockdep_set_class
 
 /**************************************************************************
@@ -154,67 +270,57 @@ static inline int mutex_is_locked(struct mutex *lock)
  *
  **************************************************************************/
 
-struct lock_class_key {
+typedef struct cfs_lock_class_key {
         ;
-};
+} cfs_lock_class_key_t;
 
-# define lockdep_set_class(lock, key) \
+#define cfs_lockdep_set_class(lock, key) \
         do { (void)sizeof (lock);(void)sizeof (key); } while (0)
 /* This has to be a macro, so that `subclass' can be undefined in kernels that
  * do not support lockdep. */
 
 
-static inline void lockdep_off(void)
+static inline void cfs_lockdep_off(void)
 {
 }
 
-static inline void lockdep_on(void)
+static inline void cfs_lockdep_on(void)
 {
 }
+#else
+typedef struct lock_class_key cfs_lock_class_key_t;
 
+#define cfs_lockdep_set_class(lock, key) lockdep_set_class(lock, key)
+#define cfs_lockdep_off()                lockdep_off()
+#define cfs_lockdep_on()                 lockdep_on()
 #endif /* lockdep_set_class */
 
 #ifndef CONFIG_DEBUG_LOCK_ALLOC
 #ifndef mutex_lock_nested
-# define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
+#define cfs_mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
+#else
+#define cfs_mutex_lock_nested(mutex, subclass) \
+        mutex_lock_nested(mutex, subclass)
 #endif
 
 #ifndef spin_lock_nested
-# define spin_lock_nested(lock, subclass) spin_lock(lock)
+#define cfs_spin_lock_nested(lock, subclass) spin_lock(lock)
+#else
+#define cfs_spin_lock_nested(lock, subclass) spin_lock_nested(lock, subclass)
 #endif
 
 #ifndef down_read_nested
-# define down_read_nested(lock, subclass) down_read(lock)
+#define cfs_down_read_nested(lock, subclass) down_read(lock)
+#else
+#define cfs_down_read_nested(lock, subclass) down_read_nested(lock, subclass)
 #endif
 
 #ifndef down_write_nested
-# define down_write_nested(lock, subclass) down_write(lock)
+#define cfs_down_write_nested(lock, subclass) down_write(lock)
+#else
+#define cfs_down_write_nested(lock, subclass) down_write_nested(lock, subclass)
 #endif
 #endif /* CONFIG_DEBUG_LOCK_ALLOC */
 
 
-/*
- * spinlock "implementation"
- */
-
-typedef spinlock_t cfs_spinlock_t;
-
-#define cfs_spin_lock_init(lock) spin_lock_init(lock)
-#define cfs_spin_lock(lock)      spin_lock(lock)
-#define cfs_spin_lock_bh(lock)   spin_lock_bh(lock)
-#define cfs_spin_unlock(lock)    spin_unlock(lock)
-#define cfs_spin_unlock_bh(lock) spin_unlock_bh(lock)
-
-/*
- * rwlock "implementation"
- */
-
-typedef rwlock_t cfs_rwlock_t;
-
-#define cfs_rwlock_init(lock)      rwlock_init(lock)
-#define cfs_read_lock(lock)        read_lock(lock)
-#define cfs_read_unlock(lock)      read_unlock(lock)
-#define cfs_write_lock_bh(lock)    write_lock_bh(lock)
-#define cfs_write_unlock_bh(lock)  write_unlock_bh(lock)
-
 #endif /* __LIBCFS_LINUX_CFS_LOCK_H__ */
index 8f5a925..1769927 100644 (file)
@@ -62,6 +62,11 @@ typedef struct page                     cfs_page_t;
 #define CFS_PAGE_SHIFT                  PAGE_CACHE_SHIFT
 #define CFS_PAGE_MASK                   (~((__u64)CFS_PAGE_SIZE-1))
 
+#define cfs_num_physpages               num_physpages
+
+#define cfs_copy_from_user(to, from, n) copy_from_user(to, from, n)
+#define cfs_copy_to_user(to, from, n)   copy_to_user(to, from, n)
+
 static inline void *cfs_page_address(cfs_page_t *page)
 {
         /*
@@ -116,9 +121,10 @@ extern void __cfs_free_pages(cfs_page_t *page, unsigned int order);
 
 #if BITS_PER_LONG == 32
 /* limit to lowmem on 32-bit systems */
-#define CFS_NUM_CACHEPAGES min(num_physpages, 1UL << (30-CFS_PAGE_SHIFT) *3/4)
+#define CFS_NUM_CACHEPAGES \
+        min(cfs_num_physpages, 1UL << (30 - CFS_PAGE_SHIFT) * 3 / 4)
 #else
-#define CFS_NUM_CACHEPAGES num_physpages
+#define CFS_NUM_CACHEPAGES cfs_num_physpages
 #endif
 
 /*
@@ -142,10 +148,28 @@ extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
 extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
 extern int cfs_mem_is_in_cache(const void *addr, const cfs_mem_cache_t *kmem);
 
-/*
- */
 #define CFS_DECL_MMSPACE                mm_segment_t __oldfs
-#define CFS_MMSPACE_OPEN                do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
+#define CFS_MMSPACE_OPEN \
+        do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
 #define CFS_MMSPACE_CLOSE               set_fs(__oldfs)
 
+#define CFS_SLAB_HWCACHE_ALIGN          SLAB_HWCACHE_ALIGN
+#define CFS_SLAB_KERNEL                 SLAB_KERNEL
+#define CFS_SLAB_NOFS                   SLAB_NOFS
+
+/*
+ * Shrinker
+ */
+
+#ifndef HAVE_REGISTER_SHRINKER
+/* Shrinker callback */
+typedef shrinker_t cfs_shrinker_t;
+#define cfs_set_shrinker(seeks, shrinker) set_shrinker(seeks, shrinker)
+#define cfs_remove_shrinker(shrinker)     remove_shrinker(shrinker)
+#endif /* !HAVE_REGISTER_SHRINKER */
+
+/* struct shrinker */
+#define cfs_shrinker shrinker
+
+#define CFS_DEFAULT_SEEKS                 DEFAULT_SEEKS
 #endif /* __LINUX_CFS_MEM_H__ */
index f0bf4e6..1dca9ac 100644 (file)
 
 #include <libcfs/linux/linux-time.h>
 
+#define CFS_KERN_EMERG   KERN_EMERG
+#define CFS_KERN_ALERT   KERN_ALERT
+#define CFS_KERN_CRIT    KERN_CRIT
+#define CFS_KERN_ERR     KERN_ERR
+#define CFS_KERN_WARNING KERN_WARNING
+#define CFS_KERN_NOTICE  KERN_NOTICE
+#define CFS_KERN_INFO    KERN_INFO
+#define CFS_KERN_DEBUG   KERN_DEBUG
+
+/*
+ * 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
+
+#ifdef NR_CPUS
+#define CFS_NR_CPUS     NR_CPUS
+#else
+#define CFS_NR_CPUS     1
+#endif
+
+#define cfs_set_cpus_allowed(t, mask)  set_cpus_allowed(t, mask)
+/*
+ * cache
+ */
+#define CFS_L1_CACHE_ALIGN(x)           L1_CACHE_ALIGN(x)
+
+/*
+ * IRQs
+ */
+#define CFS_NR_IRQS                     NR_IRQS
+
 #define CFS_EXPORT_SYMBOL(s)            EXPORT_SYMBOL(s)
 
 /*
@@ -111,16 +146,20 @@ LL_PROC_PROTO(name)                                     \
 #define cfs_symbol_get(s)               inter_module_get(s)
 #define cfs_symbol_put(s)               inter_module_put(s)
 #define cfs_module_get()                MOD_INC_USE_COUNT
-#define cfs_module_put()                MOD_DEC_USE_COUNT
 #else
 #define cfs_symbol_register(s, p)       do {} while(0)
 #define cfs_symbol_unregister(s)        do {} while(0)
 #define cfs_symbol_get(s)               symbol_get(s)
 #define cfs_symbol_put(s)               symbol_put(s)
 #define cfs_module_get()                try_module_get(THIS_MODULE)
-#define cfs_module_put()                module_put(THIS_MODULE)
+#define cfs_try_module_get(m)           try_module_get(m)
+#define __cfs_module_get(m)             __module_get(m)
+#define cfs_module_put(m)               module_put(m)
+#define cfs_module_refcount(m)          module_refcount(m)
 #endif
 
+typedef struct module cfs_module_t;
+
 /*
  * Proc file system APIs
  */
@@ -138,7 +177,8 @@ typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
 #define CFS_TASK_UNINT                  TASK_UNINTERRUPTIBLE
 #define CFS_TASK_RUNNING                TASK_RUNNING
 
-#define cfs_set_current_state(state) set_current_state(state)
+#define cfs_set_current_state(state)    set_current_state(state)
+#define cfs_wait_event(wq, cond)        wait_event(wq, cond)
 
 typedef wait_queue_t                   cfs_waitlink_t;
 typedef wait_queue_head_t              cfs_waitq_t;
@@ -180,8 +220,9 @@ typedef struct task_struct              cfs_task_t;
 
 /* Module interfaces */
 #define cfs_module(name, version, init, fini) \
-module_init(init);                            \
-module_exit(fini)
+        module_init(init);                    \
+        module_exit(fini)
+#define cfs_request_module              request_module
 
 /*
  * Signal
@@ -236,7 +277,7 @@ do {                                                                 \
 #endif
 
 #ifndef wait_event_interruptible_timeout /* Only for RHEL3 2.4.21 kernel */
-#define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
+#define __wait_event_interruptible_timeout(wq, condition, timeout, ret)  \
 do {                                                           \
        int __ret = 0;                                         \
        if (!(condition)) {                                    \
@@ -276,7 +317,7 @@ do {                                                              \
        ret = 0;                                                  \
        if (!(condition))                                         \
                __wait_event_interruptible_timeout(wq, condition, \
-                                               timeout, ret);     \
+                                                   timeout, ret); \
 } while (0)
 #else
 #define cfs_waitq_wait_event_interruptible_timeout(wq, c, timeout, ret) \
@@ -289,13 +330,22 @@ do {                                                              \
 
 typedef atomic_t cfs_atomic_t;
 
-#define cfs_atomic_read(atom)         atomic_read(atom)
-#define cfs_atomic_inc(atom)          atomic_inc(atom)
-#define cfs_atomic_dec(atom)          atomic_dec(atom)
-#define cfs_atomic_dec_and_test(atom) atomic_dec_and_test(atom)
-#define cfs_atomic_set(atom, value)   atomic_set(atom, value)
-#define cfs_atomic_add(value, atom)   atomic_add(value, atom)
-#define cfs_atomic_sub(value, atom)   atomic_sub(value, atom)
+#define cfs_atomic_read(atom)                atomic_read(atom)
+#define cfs_atomic_inc(atom)                 atomic_inc(atom)
+#define cfs_atomic_inc_and_test(atom)        atomic_inc_and_test(atom)
+#define cfs_atomic_inc_return(atom)          atomic_inc_return(atom)
+#define cfs_atomic_inc_not_zero(atom)        atomic_inc_not_zero(atom)
+#define cfs_atomic_dec(atom)                 atomic_dec(atom)
+#define cfs_atomic_dec_and_test(atom)        atomic_dec_and_test(atom)
+#define cfs_atomic_dec_and_lock(atom, lock)  atomic_dec_and_lock(atom, lock)
+#define cfs_atomic_dec_return(atom)          atomic_dec_return(atom)
+#define cfs_atomic_set(atom, value)          atomic_set(atom, value)
+#define cfs_atomic_add(value, atom)          atomic_add(value, atom)
+#define cfs_atomic_add_return(value, atom)   atomic_add_return(value, atom)
+#define cfs_atomic_sub(value, atom)          atomic_sub(value, atom)
+#define cfs_atomic_sub_and_test(value, atom) atomic_sub_and_test(value, atom)
+#define cfs_atomic_sub_return(value, atom)   atomic_sub_return(value, atom)
+#define CFS_ATOMIC_INIT(i)                   ATOMIC_INIT(i)
 
 /*
  * membar
@@ -309,4 +359,24 @@ typedef atomic_t cfs_atomic_t;
 
 #define cfs_in_interrupt() in_interrupt()
 
+/*
+ * might_sleep
+ */
+#define cfs_might_sleep() might_sleep()
+
+/*
+ * group_info
+ */
+typedef struct group_info cfs_group_info_t;
+
+#define cfs_get_group_info(group_info)     get_group_info(group_info)
+#define cfs_put_group_info(group_info)     put_group_info(group_info)
+#define cfs_set_current_groups(group_info) set_current_groups(group_info)
+#define cfs_groups_free(group_info)        groups_free(group_info)
+#define cfs_groups_alloc(gidsetsize)       groups_alloc(gidsetsize)
+
+/*
+ * Random bytes
+ */
+#define cfs_get_random_bytes(buf, nbytes)  get_random_bytes(buf, nbytes)
 #endif
index 7d63338..c473c62 100644 (file)
@@ -69,8 +69,8 @@
  *  cfs_time_t     cfs_time_current(void);
  *  cfs_time_t     cfs_time_add    (cfs_time_t, cfs_duration_t);
  *  cfs_duration_t cfs_time_sub    (cfs_time_t, cfs_time_t);
- *  int            cfs_time_before (cfs_time_t, cfs_time_t);
- *  int            cfs_time_beforeq(cfs_time_t, cfs_time_t);
+ *  int            cfs_impl_time_before (cfs_time_t, cfs_time_t);
+ *  int            cfs_impl_time_before_eq(cfs_time_t, cfs_time_t);
  *
  *  cfs_duration_t cfs_duration_build(int64_t);
  *
@@ -92,6 +92,7 @@
 
 #define ONE_BILLION ((u_int64_t)1000000000)
 #define ONE_MILLION 1000000
+#define CFS_HZ      HZ
 
 #ifndef __KERNEL__
 #error This include is only for kernel use.
@@ -177,7 +178,17 @@ static inline unsigned long long __cfs_fs_time_flat(cfs_fs_time_t *t)
 
 typedef unsigned long cfs_time_t;      /* jiffies */
 typedef long cfs_duration_t;
+typedef cycles_t cfs_cycles_t;
 
+static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
+{       
+        return time_before(t1, t2);
+}
+
+static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
+{       
+        return time_before_eq(t1, t2);
+}
 
 static inline cfs_time_t cfs_time_current(void)
 {
@@ -246,7 +257,8 @@ static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
         s->tv_usec = t;
 #else
         s->tv_sec = d / HZ;
-        s->tv_usec = ((d - (cfs_duration_t)s->tv_sec * HZ) * ONE_MILLION) / HZ;
+        s->tv_usec = ((d - (cfs_duration_t)s->tv_sec * HZ) * \
+                ONE_MILLION) / HZ;
 #endif
 }
 
@@ -306,7 +318,7 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2)
 #define CFS_TIME_T              "%lu"
 #define CFS_DURATION_T          "%ld"
 
-#define cfs_do_gettimeofday(tv) do_gettimeofday(tv)
+#define cfs_gettimeofday(tv) do_gettimeofday(tv)
 
 #endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
 /*
diff --git a/libcfs/include/libcfs/linux/linux-types.h b/libcfs/include/libcfs/linux/linux-types.h
new file mode 100644 (file)
index 0000000..672b812
--- /dev/null
@@ -0,0 +1,40 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * 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  2009 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * libcfs/include/libcfs/user-bitops.h
+ */
+#include <linux/types.h>
+
+typedef umode_t cfs_umode_t;
index 8d66df5..e816908 100644 (file)
 #endif
 
 #ifndef HAVE_CPU_ONLINE
-#define cpu_online(cpu) ((1<<cpu) & (cpu_online_map))
+#define cfs_cpu_online(cpu) ((1<<cpu) & (cpu_online_map))
+#else
+#define cfs_cpu_online(cpu) cpu_online(cpu)
 #endif
 #ifndef HAVE_CPUMASK_T
-typedef unsigned long cpumask_t;
-#define cpu_set(cpu, map) set_bit(cpu, &(map))
-#define cpus_clear(map) memset(&(map), 0, sizeof(cpumask_t))
+typedef unsigned long cfs_cpumask_t;
+#define cfs_cpu_set(cpu, map) set_bit(cpu, &(map))
+#define cpus_clear(map) memset(&(map), 0, sizeof(cfs_cpumask_t))
 #endif
 
 #ifndef __user
@@ -141,7 +143,9 @@ typedef unsigned long cpumask_t;
 #endif
 
 #ifndef __fls
-#define __fls fls
+#define __cfs_fls fls
+#else
+#define __cfs_fls __fls
 #endif
 
 #define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
index bbdbff5..7b9f9cc 100644 (file)
@@ -5,16 +5,81 @@
 
 #include <linux/list.h>
 
-#define CFS_LIST_HEAD_INIT(n)          LIST_HEAD_INIT(n)
-#define CFS_LIST_HEAD(n)               LIST_HEAD(n)
-#define CFS_INIT_LIST_HEAD(p)          INIT_LIST_HEAD(p)
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define CFS_HLIST_HEAD_INIT            HLIST_HEAD_INIT
-#define CFS_HLIST_HEAD(n)              HLIST_HEAD(n)
-#define CFS_INIT_HLIST_HEAD(p)         INIT_HLIST_HEAD(p)
-#define CFS_INIT_HLIST_NODE(p)         INIT_HLIST_NODE(p)
-#endif
+typedef struct list_head cfs_list_t;
+
+#define __cfs_list_add(new, prev, next)      __list_add(new, prev, next)
+#define cfs_list_add(new, head)              list_add(new, head)
+
+#define cfs_list_add_tail(new, head)         list_add_tail(new, head)
+
+#define __cfs_list_del(prev, next)           __list_del(prev, next)
+#define cfs_list_del(entry)                  list_del(entry)
+#define cfs_list_del_init(entry)             list_del_init(entry)
+
+#define cfs_list_move(list, head)            list_move(list, head)
+#define cfs_list_move_tail(list, head)       list_move_tail(list, head)
+
+#define cfs_list_empty(head)                 list_empty(head)
+#define cfs_list_empty_careful(head)         list_empty_careful(head)
+
+#define __cfs_list_splice(list, head)        __list_splice(list, head)
+#define cfs_list_splice(list, head)          list_splice(list, head)
+
+#define cfs_list_splice_init(list, head)     list_splice_init(list, head)
+
+#define cfs_list_entry(ptr, type, member)    list_entry(ptr, type, member)
+#define cfs_list_for_each(pos, head)         list_for_each(pos, head)
+#define cfs_list_for_each_safe(pos, n, head) list_for_each_safe(pos, n, head)
+#define cfs_list_for_each_prev(pos, head)    list_for_each_prev(pos, head)
+#define cfs_list_for_each_entry(pos, head, member) \
+        list_for_each_entry(pos, head, member)
+#define cfs_list_for_each_entry_reverse(pos, head, member) \
+        list_for_each_entry_reverse(pos, head, member)
+#define cfs_list_for_each_entry_safe(pos, n, head, member) \
+        list_for_each_entry_safe(pos, n, head, member)
+#ifdef list_for_each_entry_safe_from
+#define cfs_list_for_each_entry_safe_from(pos, n, head, member) \
+        list_for_each_entry_safe_from(pos, n, head, member)
+#endif /* list_for_each_entry_safe_from */
+#define cfs_list_for_each_entry_continue(pos, head, member) \
+        list_for_each_entry_continue(pos, head, member)
+
+#define CFS_LIST_HEAD_INIT(n)               LIST_HEAD_INIT(n)
+#define CFS_LIST_HEAD(n)                    LIST_HEAD(n)
+#define CFS_INIT_LIST_HEAD(p)               INIT_LIST_HEAD(p)
+
+typedef struct hlist_head cfs_hlist_head_t;
+typedef struct hlist_node cfs_hlist_node_t;
+
+#define cfs_hlist_unhashed(h)              hlist_unhashed(h)
+
+#define cfs_hlist_empty(h)                 hlist_empty(h)
+
+#define __cfs_hlist_del(n)                 __hlist_del(n)
+#define cfs_hlist_del(n)                   hlist_del(n)
+#define cfs_hlist_del_init(n)              hlist_del_init(n)
+
+#define cfs_hlist_add_head(n, next)        hlist_add_head(n, next)
+#define cfs_hlist_add_before(n, next)      hlist_add_before(n, next)
+#define cfs_hlist_add_after(n, next)       hlist_add_after(n, next)
+
+#define cfs_hlist_entry(ptr, type, member) hlist_entry(ptr, type, member)
+#define cfs_hlist_for_each(pos, head)      hlist_for_each(pos, head)
+#define cfs_hlist_for_each_safe(pos, n, head) \
+        hlist_for_each_safe(pos, n, head)
+#define cfs_hlist_for_each_entry(tpos, pos, head, member) \
+        hlist_for_each_entry(tpos, pos, head, member)
+#define cfs_hlist_for_each_entry_continue(tpos, pos, member) \
+        hlist_for_each_entry_continue(tpos, pos, member)
+#define cfs_hlist_for_each_entry_from(tpos, pos, member) \
+        hlist_for_each_entry_from(tpos, pos, member)
+#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member) \
+        hlist_for_each_entry_safe(tpos, pos, n, head, member)
+
+#define CFS_HLIST_HEAD_INIT               HLIST_HEAD_INIT
+#define CFS_HLIST_HEAD(n)                 HLIST_HEAD(n)
+#define CFS_INIT_HLIST_HEAD(p)            INIT_HLIST_HEAD(p)
+#define CFS_INIT_HLIST_NODE(p)            INIT_HLIST_NODE(p)
 
 #else /* !defined (__linux__) || !defined(__KERNEL__) */
 
 
 #define prefetch(a) ((void)a)
 
-struct list_head {
-       struct list_head *next, *prev;
+struct cfs_list_head {
+       struct cfs_list_head *next, *prev;
 };
 
-typedef struct list_head list_t;
+typedef struct cfs_list_head cfs_list_t;
 
 #define CFS_LIST_HEAD_INIT(name) { &(name), &(name) }
 
 #define CFS_LIST_HEAD(name) \
-       struct list_head name = CFS_LIST_HEAD_INIT(name)
+       cfs_list_t name = CFS_LIST_HEAD_INIT(name)
 
 #define CFS_INIT_LIST_HEAD(ptr) do { \
        (ptr)->next = (ptr); (ptr)->prev = (ptr); \
@@ -51,9 +116,9 @@ typedef struct list_head list_t;
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_add(struct list_head * new,
-                             struct list_head * prev,
-                             struct list_head * next)
+static inline void __cfs_list_add(cfs_list_t * new,
+                                  cfs_list_t * prev,
+                                  cfs_list_t * next)
 {
        next->prev = new;
        new->next = next;
@@ -69,9 +134,10 @@ static inline void __list_add(struct list_head * new,
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head)
+static inline void cfs_list_add(cfs_list_t *new,
+                                cfs_list_t *head)
 {
-       __list_add(new, head, head->next);
+       __cfs_list_add(new, head, head->next);
 }
 
 /**
@@ -82,9 +148,10 @@ static inline void list_add(struct list_head *new, struct list_head *head)
  * Insert a new entry before the specified head.
  * This is useful for implementing queues.
  */
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+static inline void cfs_list_add_tail(cfs_list_t *new,
+                                     cfs_list_t *head)
 {
-       __list_add(new, head->prev, head);
+       __cfs_list_add(new, head->prev, head);
 }
 
 /*
@@ -94,7 +161,8 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
+static inline void __cfs_list_del(cfs_list_t *prev,
+                                  cfs_list_t *next)
 {
        next->prev = prev;
        prev->next = next;
@@ -103,51 +171,55 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
 /**
  * Remove an entry from the list it is currently in.
  * \param entry the entry to remove
- * Note: list_empty(entry) does not return true after this, the entry is in an undefined state.
+ * Note: list_empty(entry) does not return true after this, the entry is in an
+ * undefined state.
  */
-static inline void list_del(struct list_head *entry)
+static inline void cfs_list_del(cfs_list_t *entry)
 {
-       __list_del(entry->prev, entry->next);
+       __cfs_list_del(entry->prev, entry->next);
 }
 
 /**
  * Remove an entry from the list it is currently in and reinitialize it.
  * \param entry the entry to remove.
  */
-static inline void list_del_init(struct list_head *entry)
+static inline void cfs_list_del_init(cfs_list_t *entry)
 {
-       __list_del(entry->prev, entry->next);
+       __cfs_list_del(entry->prev, entry->next);
        CFS_INIT_LIST_HEAD(entry);
 }
 
 /**
- * Remove an entry from the list it is currently in and insert it at the start of another list.
+ * Remove an entry from the list it is currently in and insert it at the start
+ * of another list.
  * \param list the entry to move
  * \param head the list to move it to
  */
-static inline void list_move(struct list_head *list, struct list_head *head)
+static inline void cfs_list_move(cfs_list_t *list,
+                                 cfs_list_t *head)
 {
-       __list_del(list->prev, list->next);
-       list_add(list, head);
+       __cfs_list_del(list->prev, list->next);
+       cfs_list_add(list, head);
 }
 
 /**
- * Remove an entry from the list it is currently in and insert it at the end of another list.
+ * Remove an entry from the list it is currently in and insert it at the end of
+ * another list.
  * \param list the entry to move
  * \param head the list to move it to
  */
-static inline void list_move_tail(struct list_head *list,
-                                 struct list_head *head)
+static inline void cfs_list_move_tail(cfs_list_t *list,
+                                      cfs_list_t *head)
 {
-       __list_del(list->prev, list->next);
-       list_add_tail(list, head);
+       __cfs_list_del(list->prev, list->next);
+       cfs_list_add_tail(list, head);
 }
 
 /**
  * Test whether a list is empty
  * \param head the list to test.
  */
-static inline int list_empty(struct list_head *head)
+static inline int cfs_list_empty(cfs_list_t *head)
 {
        return head->next == head;
 }
@@ -159,23 +231,23 @@ static inline int list_empty(struct list_head *head)
  * Tests whether a list is empty _and_ checks that no other CPU might be
  * in the process of modifying either member (next or prev)
  *
- * NOTE: using list_empty_careful() without synchronization
+ * NOTE: using cfs_list_empty_careful() without synchronization
  * can only be safe if the only activity that can happen
- * to the list entry is list_del_init(). Eg. it cannot be used
+ * to the list entry is cfs_list_del_init(). Eg. it cannot be used
  * if another CPU could re-list_add() it.
  */
-static inline int list_empty_careful(const struct list_head *head)
+static inline int cfs_list_empty_careful(const cfs_list_t *head)
 {
-        struct list_head *next = head->next;
+        cfs_list_t *next = head->next;
         return (next == head) && (next == head->prev);
 }
 
-static inline void __list_splice(struct list_head *list,
-                                struct list_head *head)
+static inline void __cfs_list_splice(cfs_list_t *list,
+                                     cfs_list_t *head)
 {
-       struct list_head *first = list->next;
-       struct list_head *last = list->prev;
-       struct list_head *at = head->next;
+       cfs_list_t *first = list->next;
+       cfs_list_t *last = list->prev;
+       cfs_list_t *at = head->next;
 
        first->prev = head;
        head->next = first;
@@ -192,10 +264,11 @@ static inline void __list_splice(struct list_head *list,
  * The contents of \a list are added at the start of \a head.  \a list is in an
  * undefined state on return.
  */
-static inline void list_splice(struct list_head *list, struct list_head *head)
+static inline void cfs_list_splice(cfs_list_t *list,
+                                   cfs_list_t *head)
 {
-       if (!list_empty(list))
-               __list_splice(list, head);
+       if (!cfs_list_empty(list))
+               __cfs_list_splice(list, head);
 }
 
 /**
@@ -206,38 +279,38 @@ static inline void list_splice(struct list_head *list, struct list_head *head)
  * The contents of \a list are added at the start of \a head.  \a list is empty
  * on return.
  */
-static inline void list_splice_init(struct list_head *list,
-                                   struct list_head *head)
+static inline void cfs_list_splice_init(cfs_list_t *list,
+                                        cfs_list_t *head)
 {
-       if (!list_empty(list)) {
-               __list_splice(list, head);
+       if (!cfs_list_empty(list)) {
+               __cfs_list_splice(list, head);
                CFS_INIT_LIST_HEAD(list);
        }
 }
 
 /**
- * Get the container of a list 
+ * Get the container of a list
  * \param ptr   the embedded list.
  * \param type  the type of the struct this is embedded in.
  * \param member the member name of the list within the struct.
  */
-#define list_entry(ptr, type, member) \
+#define cfs_list_entry(ptr, type, member) \
        ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
 
 /**
  * Iterate over a list
  * \param pos  the iterator
  * \param head the list to iterate over
- * 
+ *
  * Behaviour is undefined if \a pos is removed from the list in the body of the
  * loop.
  */
-#define list_for_each(pos, head) \
+#define cfs_list_for_each(pos, head) \
        for (pos = (head)->next, prefetch(pos->next); pos != (head); \
                pos = pos->next, prefetch(pos->next))
 
 /**
- * iterate over a list safely
+ * Iterate over a list safely
  * \param pos  the iterator
  * \param n     temporary storage
  * \param head the list to iterate over
@@ -245,11 +318,22 @@ static inline void list_splice_init(struct list_head *list,
  * This is safe to use if \a pos could be removed from the list in the body of
  * the loop.
  */
-#define list_for_each_safe(pos, n, head) \
+#define cfs_list_for_each_safe(pos, n, head) \
        for (pos = (head)->next, n = pos->next; pos != (head); \
                pos = n, n = pos->next)
 
 /**
+ * Iterate over a list continuing after existing point
+ * \param pos    the type * to use as a loop counter
+ * \param head   the list head
+ * \param member the name of the list_struct within the struct  
+ */
+#define cfs_list_for_each_entry_continue(pos, head, member)                 \
+        for (pos = cfs_list_entry(pos->member.next, typeof(*pos), member);  \
+             prefetch(pos->member.next), &pos->member != (head);            \
+             pos = cfs_list_entry(pos->member.next, typeof(*pos), member))
+
+/**
  * \defgroup hlist Hash List
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is too
@@ -257,13 +341,13 @@ static inline void list_splice_init(struct list_head *list,
  * @{
  */
 
-struct hlist_head {
-       struct hlist_node *first;
-};
+typedef struct cfs_hlist_node {
+       struct cfs_hlist_node *next, **pprev;
+} cfs_hlist_node_t;
 
-struct hlist_node {
-       struct hlist_node *next, **pprev;
-};
+typedef struct cfs_hlist_head {
+       cfs_hlist_node_t *first;
+} cfs_hlist_head_t;
 
 /* @} */
 
@@ -282,50 +366,46 @@ struct hlist_node {
  */
 
 #define CFS_HLIST_HEAD_INIT { NULL_P }
-#define CFS_HLIST_HEAD(name) struct hlist_head name = { NULL_P }
+#define CFS_HLIST_HEAD(name) cfs_hlist_head_t name = { NULL_P }
 #define CFS_INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL_P)
 #define CFS_INIT_HLIST_NODE(ptr) ((ptr)->next = NULL_P, (ptr)->pprev = NULL_P)
 
-#define HLIST_HEAD_INIT                CFS_HLIST_HEAD_INIT
-#define HLIST_HEAD(n)          CFS_HLIST_HEAD(n)
-#define INIT_HLIST_HEAD(p)     CFS_INIT_HLIST_HEAD(p)
-#define INIT_HLIST_NODE(p)     CFS_INIT_HLIST_NODE(p)
-
-static inline int hlist_unhashed(const struct hlist_node *h)
+static inline int cfs_hlist_unhashed(const cfs_hlist_node_t *h)
 {
        return !h->pprev;
 }
 
-static inline int hlist_empty(const struct hlist_head *h)
+static inline int cfs_hlist_empty(const cfs_hlist_head_t *h)
 {
        return !h->first;
 }
 
-static inline void __hlist_del(struct hlist_node *n)
+static inline void __cfs_hlist_del(cfs_hlist_node_t *n)
 {
-       struct hlist_node *next = n->next;
-       struct hlist_node **pprev = n->pprev;
+       cfs_hlist_node_t *next = n->next;
+       cfs_hlist_node_t **pprev = n->pprev;
        *pprev = next;
        if (next)
                next->pprev = pprev;
 }
 
-static inline void hlist_del(struct hlist_node *n)
+static inline void cfs_hlist_del(cfs_hlist_node_t *n)
 {
-       __hlist_del(n);
+       __cfs_hlist_del(n);
 }
 
-static inline void hlist_del_init(struct hlist_node *n)
+static inline void cfs_hlist_del_init(cfs_hlist_node_t *n)
 {
        if (n->pprev)  {
-               __hlist_del(n);
-               INIT_HLIST_NODE(n);
+               __cfs_hlist_del(n);
+               CFS_INIT_HLIST_NODE(n);
        }
 }
 
-static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+static inline void cfs_hlist_add_head(cfs_hlist_node_t *n,
+                                      cfs_hlist_head_t *h)
 {
-       struct hlist_node *first = h->first;
+       cfs_hlist_node_t *first = h->first;
        n->next = first;
        if (first)
                first->pprev = &n->next;
@@ -334,8 +414,8 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
 }
 
 /* next must be != NULL */
-static inline void hlist_add_before(struct hlist_node *n,
-                                       struct hlist_node *next)
+static inline void cfs_hlist_add_before(cfs_hlist_node_t *n,
+                                       cfs_hlist_node_t *next)
 {
        n->pprev = next->pprev;
        n->next = next;
@@ -343,8 +423,8 @@ static inline void hlist_add_before(struct hlist_node *n,
        *(n->pprev) = n;
 }
 
-static inline void hlist_add_after(struct hlist_node *n,
-                                       struct hlist_node *next)
+static inline void cfs_hlist_add_after(cfs_hlist_node_t *n,
+                                       cfs_hlist_node_t *next)
 {
        next->next = n->next;
        n->next = next;
@@ -354,13 +434,13 @@ static inline void hlist_add_after(struct hlist_node *n,
                next->next->pprev  = &next->next;
 }
 
-#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+#define cfs_hlist_entry(ptr, type, member) container_of(ptr,type,member)
 
-#define hlist_for_each(pos, head) \
+#define cfs_hlist_for_each(pos, head) \
        for (pos = (head)->first; pos && (prefetch(pos->next), 1); \
             pos = pos->next)
 
-#define hlist_for_each_safe(pos, n, head) \
+#define cfs_hlist_for_each_safe(pos, n, head) \
        for (pos = (head)->first; pos && (n = pos->next, 1); \
             pos = n)
 
@@ -371,10 +451,10 @@ static inline void hlist_add_after(struct hlist_node *n,
  * \param head  the head for your list.
  * \param member the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry(tpos, pos, head, member)                   \
-       for (pos = (head)->first;                                        \
-            pos && ({ prefetch(pos->next); 1;}) &&                      \
-               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+#define cfs_hlist_for_each_entry(tpos, pos, head, member)                    \
+       for (pos = (head)->first;                                            \
+            pos && ({ prefetch(pos->next); 1;}) &&                          \
+               ({ tpos = cfs_hlist_entry(pos, typeof(*tpos), member); 1;}); \
             pos = pos->next)
 
 /**
@@ -383,10 +463,10 @@ static inline void hlist_add_after(struct hlist_node *n,
  * \param pos   the &struct hlist_node to use as a loop counter.
  * \param member the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_continue(tpos, pos, member)                \
-       for (pos = (pos)->next;                                          \
-            pos && ({ prefetch(pos->next); 1;}) &&                      \
-               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+#define cfs_hlist_for_each_entry_continue(tpos, pos, member)                 \
+       for (pos = (pos)->next;                                              \
+            pos && ({ prefetch(pos->next); 1;}) &&                          \
+               ({ tpos = cfs_hlist_entry(pos, typeof(*tpos), member); 1;}); \
             pos = pos->next)
 
 /**
@@ -395,9 +475,9 @@ static inline void hlist_add_after(struct hlist_node *n,
  * \param pos   the &struct hlist_node to use as a loop counter.
  * \param member the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_from(tpos, pos, member)                    \
-       for (; pos && ({ prefetch(pos->next); 1;}) &&                    \
-               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+#define cfs_hlist_for_each_entry_from(tpos, pos, member)                        \
+       for (; pos && ({ prefetch(pos->next); 1;}) &&                        \
+               ({ tpos = cfs_hlist_entry(pos, typeof(*tpos), member); 1;}); \
             pos = pos->next)
 
 /**
@@ -408,62 +488,57 @@ static inline void hlist_add_after(struct hlist_node *n,
  * \param head  the head for your list.
  * \param member the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_safe(tpos, pos, n, head, member)           \
-       for (pos = (head)->first;                                        \
-            pos && ({ n = pos->next; 1; }) &&                           \
-               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+#define cfs_hlist_for_each_entry_safe(tpos, pos, n, head, member)            \
+       for (pos = (head)->first;                                            \
+            pos && ({ n = pos->next; 1; }) &&                               \
+               ({ tpos = cfs_hlist_entry(pos, typeof(*tpos), member); 1;}); \
             pos = n)
 
 /* @} */
 
 #endif /* __linux__ && __KERNEL__ */
 
-#ifndef list_for_each_prev
+#ifndef cfs_list_for_each_prev
 /**
  * Iterate over a list in reverse order
  * \param pos  the &struct list_head to use as a loop counter.
  * \param head the head for your list.
  */
-#define list_for_each_prev(pos, head) \
+#define cfs_list_for_each_prev(pos, head) \
        for (pos = (head)->prev, prefetch(pos->prev); pos != (head);     \
                pos = pos->prev, prefetch(pos->prev))
 
-#endif /* list_for_each_prev */
+#endif /* cfs_list_for_each_prev */
 
-#ifndef list_for_each_entry
+#ifndef cfs_list_for_each_entry
 /**
  * Iterate over a list of given type
  * \param pos        the type * to use as a loop counter.
  * \param head       the head for your list.
  * \param member     the name of the list_struct within the struct.
  */
-#define list_for_each_entry(pos, head, member)                         \
-        for (pos = list_entry((head)->next, typeof(*pos), member),     \
-                    prefetch(pos->member.next);                        \
-            &pos->member != (head);                                    \
-            pos = list_entry(pos->member.next, typeof(*pos), member),  \
+#define cfs_list_for_each_entry(pos, head, member)                          \
+        for (pos = cfs_list_entry((head)->next, typeof(*pos), member),      \
+                    prefetch(pos->member.next);                            \
+            &pos->member != (head);                                        \
+            pos = cfs_list_entry(pos->member.next, typeof(*pos), member),  \
             prefetch(pos->member.next))
-#endif /* list_for_each_entry */
+#endif /* cfs_list_for_each_entry */
 
-#ifndef list_for_each_entry_rcu
-#define list_for_each_entry_rcu(pos, head, member) \
-       list_for_each_entry(pos, head, member)
-#endif
-
-#ifndef list_for_each_entry_reverse
+#ifndef cfs_list_for_each_entry_reverse
 /**
  * Iterate backwards over a list of given type.
  * \param pos        the type * to use as a loop counter.
  * \param head       the head for your list.
  * \param member     the name of the list_struct within the struct.
  */
-#define list_for_each_entry_reverse(pos, head, member)                  \
-       for (pos = list_entry((head)->prev, typeof(*pos), member);      \
-            prefetch(pos->member.prev), &pos->member != (head);        \
-            pos = list_entry(pos->member.prev, typeof(*pos), member))
-#endif /* list_for_each_entry_reverse */
+#define cfs_list_for_each_entry_reverse(pos, head, member)                  \
+       for (pos = cfs_list_entry((head)->prev, typeof(*pos), member);      \
+            prefetch(pos->member.prev), &pos->member != (head);            \
+            pos = cfs_list_entry(pos->member.prev, typeof(*pos), member))
+#endif /* cfs_list_for_each_entry_reverse */
 
-#ifndef list_for_each_entry_safe
+#ifndef cfs_list_for_each_entry_safe
 /**
  * Iterate over a list of given type safe against removal of list entry
  * \param pos        the type * to use as a loop counter.
@@ -471,15 +546,15 @@ static inline void hlist_add_after(struct hlist_node *n,
  * \param head       the head for your list.
  * \param member     the name of the list_struct within the struct.
  */
-#define list_for_each_entry_safe(pos, n, head, member)                 \
-        for (pos = list_entry((head)->next, typeof(*pos), member),     \
-               n = list_entry(pos->member.next, typeof(*pos), member); \
-            &pos->member != (head);                                    \
-            pos = n, n = list_entry(n->member.next, typeof(*n), member))
+#define cfs_list_for_each_entry_safe(pos, n, head, member)                   \
+        for (pos = cfs_list_entry((head)->next, typeof(*pos), member),       \
+               n = cfs_list_entry(pos->member.next, typeof(*pos), member);  \
+            &pos->member != (head);                                         \
+            pos = n, n = cfs_list_entry(n->member.next, typeof(*n), member))
 
-#endif /* list_for_each_entry_safe */
+#endif /* cfs_list_for_each_entry_safe */
 
-#ifndef list_for_each_entry_safe_from
+#ifndef cfs_list_for_each_entry_safe_from
 /**
  * Iterate over a list continuing from an existing point
  * \param pos        the type * to use as a loop cursor.
@@ -490,44 +565,45 @@ static inline void hlist_add_after(struct hlist_node *n,
  * Iterate over list of given type from current point, safe against
  * removal of list entry.
  */
-#define list_for_each_entry_safe_from(pos, n, head, member)             \
-        for (n = list_entry(pos->member.next, typeof(*pos), member);    \
-             &pos->member != (head);                                    \
-             pos = n, n = list_entry(n->member.next, typeof(*n), member))
-#endif /* list_for_each_entry_safe_from */
+#define cfs_list_for_each_entry_safe_from(pos, n, head, member)             \
+        for (n = cfs_list_entry(pos->member.next, typeof(*pos), member);    \
+             &pos->member != (head);                                        \
+             pos = n, n = cfs_list_entry(n->member.next, typeof(*n), member))
+#endif /* cfs_list_for_each_entry_safe_from */
 
 #define cfs_list_for_each_entry_typed(pos, head, type, member)         \
-        for (pos = list_entry((head)->next, type, member),             \
-                    prefetch(pos->member.next);                        \
-            &pos->member != (head);                                    \
-            pos = list_entry(pos->member.next, type, member),          \
+        for (pos = cfs_list_entry((head)->next, type, member),         \
+                    prefetch(pos->member.next);                        \
+            &pos->member != (head);                                    \
+            pos = cfs_list_entry(pos->member.next, type, member),      \
             prefetch(pos->member.next))
 
 #define cfs_list_for_each_entry_reverse_typed(pos, head, type, member) \
-       for (pos = list_entry((head)->prev, type, member);              \
+       for (pos = cfs_list_entry((head)->prev, type, member);          \
             prefetch(pos->member.prev), &pos->member != (head);        \
-            pos = list_entry(pos->member.prev, type, member))
+            pos = cfs_list_entry(pos->member.prev, type, member))
 
 #define cfs_list_for_each_entry_safe_typed(pos, n, head, type, member) \
-    for (pos = list_entry((head)->next, type, member),                 \
-               n = list_entry(pos->member.next, type, member);         \
-            &pos->member != (head);                                    \
-            pos = n, n = list_entry(n->member.next, type, member))
-
-#define cfs_list_for_each_entry_safe_from_typed(pos, n, head, type, member)   \
-        for (n = list_entry(pos->member.next, type, member);            \
-             &pos->member != (head);                                    \
-             pos = n, n = list_entry(n->member.next, type, member))
+    for (pos = cfs_list_entry((head)->next, type, member),             \
+               n = cfs_list_entry(pos->member.next, type, member);     \
+            &pos->member != (head);                                    \
+            pos = n, n = cfs_list_entry(n->member.next, type, member))
+
+#define cfs_list_for_each_entry_safe_from_typed(pos, n, head, type, member)  \
+        for (n = cfs_list_entry(pos->member.next, type, member);             \
+             &pos->member != (head);                                         \
+             pos = n, n = cfs_list_entry(n->member.next, type, member))
+
 #define cfs_hlist_for_each_entry_typed(tpos, pos, head, type, member)   \
        for (pos = (head)->first;                                       \
             pos && (prefetch(pos->next), 1) &&                         \
-               (tpos = hlist_entry(pos, type, member), 1);             \
+               (tpos = cfs_hlist_entry(pos, type, member), 1);         \
             pos = pos->next)
 
-#define cfs_hlist_for_each_entry_safe_typed(tpos, pos, n, head, type, member)\
-       for (pos = (head)->first;                                       \
-            pos && (n = pos->next, 1) &&                               \
-               (tpos = hlist_entry(pos, type, member), 1);             \
+#define cfs_hlist_for_each_entry_safe_typed(tpos, pos, n, head, type, member) \
+       for (pos = (head)->first;                                             \
+            pos && (n = pos->next, 1) &&                                     \
+               (tpos = cfs_hlist_entry(pos, type, member), 1);               \
             pos = n)
 
 #endif /* __LIBCFS_LUSTRE_LIST_H__ */
index 2173ab9..c16d8d9 100644 (file)
 #include <libcfs/user-bitops.h>
 #include <libcfs/posix/posix-kernelcomm.h>
 
-# define do_gettimeofday(tv) gettimeofday(tv, NULL);
-typedef unsigned long long cycles_t;
+# define cfs_gettimeofday(tv) gettimeofday(tv, NULL);
+typedef unsigned long long cfs_cycles_t;
 
 #define IS_ERR(a) ((unsigned long)(a) > (unsigned long)-1000L)
 #define PTR_ERR(a) ((long)(a))
@@ -197,12 +197,14 @@ typedef struct dirent64 cfs_dirent_t;
 
 
 # ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */
-#  define THREAD_SIZE 8192
+#  define CFS_THREAD_SIZE 8192
+# else
+#  define CFS_THREAD_SIZE THREAD_SIZE
 # endif
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
+#define LUSTRE_TRACE_SIZE (CFS_THREAD_SIZE >> 5)
 
-#define CHECK_STACK() do { } while(0)
+#define CFS_CHECK_STACK() do { } while(0)
 #define CDEBUG_STACK() (0L)
 
 /* initial pid  */
@@ -225,10 +227,10 @@ typedef __u32 cfs_kernel_cap_t;
 /**
  * Module support (probably shouldn't be used in generic code?)
  */
-struct module {
+typedef struct cfs_module {
         int count;
         char *name;
-};
+} cfs_module_t;
 
 static inline void MODULE_AUTHOR(char *name)
 {
@@ -241,26 +243,26 @@ static inline void MODULE_AUTHOR(char *name)
 #define __init
 #define __exit
 
-static inline int request_module(const char *name, ...)
+static inline int cfs_request_module(const char *name, ...)
 {
         return (-EINVAL);
 }
 
-static inline void __module_get(struct module *module)
+static inline void __cfs_module_get(cfs_module_t *module)
 {
 }
 
-static inline int try_module_get(struct module *module)
+static inline int cfs_try_module_get(cfs_module_t *module)
 {
         return 1;
 }
 
-static inline void module_put(struct module *module)
+static inline void cfs_module_put(cfs_module_t *module)
 {
 }
 
 
-static inline int module_refcount(struct module *m)
+static inline int cfs_module_refcount(cfs_module_t *m)
 {
         return 1;
 }
@@ -271,20 +273,21 @@ static inline int module_refcount(struct module *m)
  *
  ***************************************************************************/
 
-struct shrinker {
+struct cfs_shrinker {
         ;
 };
 
-#define DEFAULT_SEEKS (0)
+#define CFS_DEFAULT_SEEKS (0)
 
-typedef int (*shrinker_t)(int, unsigned int);
+typedef int (*cfs_shrinker_t)(int, unsigned int);
 
-static inline struct shrinker *set_shrinker(int seeks, shrinker_t shrinkert)
+static inline
+struct cfs_shrinker *cfs_set_shrinker(int seeks, cfs_shrinker_t shrink)
 {
-        return (struct shrinker *)0xdeadbea1; // Cannot return NULL here
+        return (struct cfs_shrinker *)0xdeadbea1; // Cannot return NULL here
 }
 
-static inline void remove_shrinker(struct shrinker *shrinker)
+static inline void cfs_remove_shrinker(struct cfs_shrinker *shrinker)
 {
 }
 
@@ -299,12 +302,12 @@ static inline void remove_shrinker(struct shrinker *shrinker)
  ***************************************************************************/
 
 struct radix_tree_root {
-        struct list_head list;
+        cfs_list_t list;
         void *rnode;
 };
 
 struct radix_tree_node {
-        struct list_head _node;
+        cfs_list_t _node;
         unsigned long index;
         void *item;
 };
@@ -334,7 +337,7 @@ static inline int radix_tree_insert(struct radix_tree_root *root,
         CFS_INIT_LIST_HEAD(&node->_node);
         node->index = idx;
         node->item = item;
-        list_add_tail(&node->_node, &root->list);
+        cfs_list_add_tail(&node->_node, &root->list);
         root->rnode = (void *)1001;
         return 0;
 }
@@ -344,7 +347,7 @@ static inline struct radix_tree_node *radix_tree_lookup0(struct radix_tree_root
 {
         struct radix_tree_node *node;
 
-        if (list_empty(&root->list))
+        if (cfs_list_empty(&root->list))
                 return NULL;
 
         cfs_list_for_each_entry_typed(node, &root->list,
@@ -374,10 +377,10 @@ static inline void *radix_tree_delete(struct radix_tree_root *root,
         if (p == NULL)
                 return NULL;
 
-        list_del_init(&p->_node);
+        cfs_list_del_init(&p->_node);
         item = p->item;
         free(p);
-        if (list_empty(&root->list))
+        if (cfs_list_empty(&root->list))
                 root->rnode = NULL;
 
         return item;
index 1736a02..b5c66aa 100644 (file)
@@ -44,7 +44,9 @@
 
 #include <asm/types.h>
 #ifndef HAVE_UMODE_T
-typedef unsigned short umode_t;
+typedef unsigned short cfs_umode_t;
+#else
+typedef umode_t cfs_umode_t;
 #endif
 
 /*
index cd0d220..1b36407 100644 (file)
@@ -42,7 +42,7 @@
 #define __LIBCFS_USER_BITOPS_H__
 
 /* test if bit nr is set in bitmap addr; returns previous value of bit nr */
-static __inline__ int test_and_set_bit(int nr, unsigned long *addr)
+static __inline__ int cfs_test_and_set_bit(int nr, unsigned long *addr)
 {
         unsigned long mask;
 
@@ -53,10 +53,10 @@ static __inline__ int test_and_set_bit(int nr, unsigned long *addr)
         return nr;
 }
 
-#define set_bit(n, a) test_and_set_bit(n, a)
+#define cfs_set_bit(n, a) cfs_test_and_set_bit(n, a)
 
 /* clear bit nr in bitmap addr; returns previous value of bit nr*/
-static __inline__ int test_and_clear_bit(int nr, unsigned long *addr)
+static __inline__ int cfs_test_and_clear_bit(int nr, unsigned long *addr)
 {
         unsigned long mask;
 
@@ -67,16 +67,16 @@ static __inline__ int test_and_clear_bit(int nr, unsigned long *addr)
         return nr;
 }
 
-#define clear_bit(n, a) test_and_clear_bit(n, a)
+#define cfs_clear_bit(n, a) cfs_test_and_clear_bit(n, a)
 
-static __inline__ int test_bit(int nr, const unsigned long *addr)
+static __inline__ int cfs_test_bit(int nr, const unsigned long *addr)
 {
         return ((1UL << (nr & (BITS_PER_LONG - 1))) &
                 ((addr)[nr / BITS_PER_LONG])) != 0;
 }
 
 /* using binary seach */
-static __inline__ unsigned long __fls(long data)
+static __inline__ unsigned long __cfs_fls(long data)
 {
        int pos = 32;
 
@@ -115,7 +115,7 @@ static __inline__ unsigned long __fls(long data)
        return pos;
 }
 
-static __inline__ unsigned long __ffs(long data)
+static __inline__ unsigned long __cfs_ffs(long data)
 {
         int pos = 0;
 
@@ -147,16 +147,17 @@ static __inline__ unsigned long __ffs(long data)
         return pos;
 }
 
-#define __ffz(x)       __ffs(~(x))
-#define __flz(x)       __fls(~(x))
+#define __cfs_ffz(x)   __cfs_ffs(~(x))
+#define __cfs_flz(x)   __cfs_fls(~(x))
 
-unsigned long find_next_bit(unsigned long *addr,
-                            unsigned long size, unsigned long offset);
+unsigned long cfs_find_next_bit(unsigned long *addr,
+                                unsigned long size, unsigned long offset);
 
-unsigned long find_next_zero_bit(unsigned long *addr,
-                                 unsigned long size, unsigned long offset);
+unsigned long cfs_find_next_zero_bit(unsigned long *addr,
+                                     unsigned long size, unsigned long offset);
 
-#define find_first_bit(addr,size)       (find_next_bit((addr),(size),0))
-#define find_first_zero_bit(addr,size)  (find_next_zero_bit((addr),(size),0))
+#define cfs_find_first_bit(addr,size)     (cfs_find_next_bit((addr),(size),0))
+#define cfs_find_first_zero_bit(addr,size)  \
+        (cfs_find_next_zero_bit((addr),(size),0))
 
 #endif
index 958519e..7c7a80c 100644 (file)
  */
 
 /*
- * spin_lock
+ * cfs_spin_lock
  *
- * - spin_lock_init(x)
- * - spin_lock(x)
- * - spin_unlock(x)
- * - spin_trylock(x)
+ * - cfs_spin_lock_init(x)
+ * - cfs_spin_lock(x)
+ * - cfs_spin_unlock(x)
+ * - cfs_spin_trylock(x)
+ * - cfs_spin_lock_bh_init(x)
+ * - cfs_spin_lock_bh(x)
+ * - cfs_spin_unlock_bh(x)
  *
- * - spin_lock_irqsave(x, f)
- * - spin_unlock_irqrestore(x, f)
+ * - cfs_spin_is_locked(x)
+ * - cfs_spin_lock_irqsave(x, f)
+ * - cfs_spin_unlock_irqrestore(x, f)
  *
  * No-op implementation.
  */
-struct spin_lock {int foo;};
+struct cfs_spin_lock {int foo;};
 
-typedef struct spin_lock spinlock_t;
+typedef struct cfs_spin_lock cfs_spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
+#define CFS_SPIN_LOCK_UNLOCKED (cfs_spinlock_t) { }
 #define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
 #define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
 #define LASSERT_SEM_LOCKED(sem) do {(void)sizeof(sem);} while(0)
 
-void spin_lock_init(spinlock_t *lock);
-void spin_lock(spinlock_t *lock);
-void spin_unlock(spinlock_t *lock);
-int spin_trylock(spinlock_t *lock);
-void spin_lock_bh_init(spinlock_t *lock);
-void spin_lock_bh(spinlock_t *lock);
-void spin_unlock_bh(spinlock_t *lock);
+void cfs_spin_lock_init(cfs_spinlock_t *lock);
+void cfs_spin_lock(cfs_spinlock_t *lock);
+void cfs_spin_unlock(cfs_spinlock_t *lock);
+int cfs_spin_trylock(cfs_spinlock_t *lock);
+void cfs_spin_lock_bh_init(cfs_spinlock_t *lock);
+void cfs_spin_lock_bh(cfs_spinlock_t *lock);
+void cfs_spin_unlock_bh(cfs_spinlock_t *lock);
 
-static inline int spin_is_locked(spinlock_t *l) {return 1;}
-static inline void spin_lock_irqsave(spinlock_t *l, unsigned long f){}
-static inline void spin_unlock_irqrestore(spinlock_t *l, unsigned long f){}
+static inline int cfs_spin_is_locked(cfs_spinlock_t *l) {return 1;}
+static inline void cfs_spin_lock_irqsave(cfs_spinlock_t *l, unsigned long f){}
+static inline void cfs_spin_unlock_irqrestore(cfs_spinlock_t *l,
+                                              unsigned long f){}
 
 /*
  * Semaphore
  *
- * - sema_init(x, v)
+ * - cfs_sema_init(x, v)
  * - __down(x)
  * - __up(x)
  */
-typedef struct semaphore {
+typedef struct cfs_semaphore {
     int foo;
-} mutex_t;
+} cfs_semaphore_t;
 
-void sema_init(struct semaphore *s, int val);
-void __down(struct semaphore *s);
-void __up(struct semaphore *s);
-
-/*
- * Mutex:
- *
- * - init_mutex(x)
- * - init_mutex_locked(x)
- * - mutex_up(x)
- * - mutex_down(x)
- */
-#define DECLARE_MUTEX(name)     \
-        struct semaphore name = { 1 }
-
-#define mutex_up(s)                     __up(s)
-#define up(s)                           mutex_up(s)
-#define mutex_down(s)                   __down(s)
-#define down(s)                         mutex_down(s)
-
-#define init_MUTEX(x)                   sema_init(x, 1)
-#define init_MUTEX_LOCKED(x)            sema_init(x, 0)
-#define init_mutex(s)                   init_MUTEX(s)
+void cfs_sema_init(cfs_semaphore_t *s, int val);
+void __down(cfs_semaphore_t *s);
+void __up(cfs_semaphore_t *s);
 
 /*
  * Completion:
  *
- * - init_completion(c)
- * - complete(c)
- * - wait_for_completion(c)
+ * - cfs_init_completion_module(c)
+ * - cfs_call_wait_handler(t)
+ * - cfs_init_completion(c)
+ * - cfs_complete(c)
+ * - cfs_wait_for_completion(c)
+ * - cfs_wait_for_completion_interruptible(c)
  */
-struct completion {
+typedef struct {
         unsigned int done;
         cfs_waitq_t wait;
-};
+} cfs_completion_t;
+
 typedef int (*cfs_wait_handler_t) (int timeout);
-void init_completion_module(cfs_wait_handler_t handler);
-int  call_wait_handler(int timeout);
-void init_completion(struct completion *c);
-void complete(struct completion *c);
-void wait_for_completion(struct completion *c);
-int wait_for_completion_interruptible(struct completion *c);
-
-#define COMPLETION_INITIALIZER(work) \
+void cfs_init_completion_module(cfs_wait_handler_t handler);
+int  cfs_call_wait_handler(int timeout);
+void cfs_init_completion(cfs_completion_t *c);
+void cfs_complete(cfs_completion_t *c);
+void cfs_wait_for_completion(cfs_completion_t *c);
+int cfs_wait_for_completion_interruptible(cfs_completion_t *c);
+
+#define CFS_COMPLETION_INITIALIZER(work) \
         { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
 
-#define DECLARE_COMPLETION(work) \
-        struct completion work = COMPLETION_INITIALIZER(work)
+#define CFS_DECLARE_COMPLETION(work) \
+        cfs_completion_t work = CFS_COMPLETION_INITIALIZER(work)
 
-#define INIT_COMPLETION(x)      ((x).done = 0)
+#define CFS_INIT_COMPLETION(x)      ((x).done = 0)
 
 
 /*
- * rw_semaphore:
+ * cfs_rw_semaphore:
  *
- * - init_rwsem(x)
- * - down_read(x)
- * - up_read(x)
- * - down_write(x)
- * - up_write(x)
+ * - cfs_init_rwsem(x)
+ * - cfs_down_read(x)
+ * - cfs_down_read_trylock(x)
+ * - cfs_down_write(struct cfs_rw_semaphore *s);
+ * - cfs_down_write_trylock(struct cfs_rw_semaphore *s);
+ * - cfs_up_read(x)
+ * - cfs_up_write(x)
+ * - cfs_fini_rwsem(x)
  */
-struct rw_semaphore {
+typedef struct cfs_rw_semaphore {
         int foo;
-};
+} cfs_rw_semaphore_t;
 
-void init_rwsem(struct rw_semaphore *s);
-void down_read(struct rw_semaphore *s);
-int down_read_trylock(struct rw_semaphore *s);
-void down_write(struct rw_semaphore *s);
-int down_write_trylock(struct rw_semaphore *s);
-void up_read(struct rw_semaphore *s);
-void up_write(struct rw_semaphore *s);
-void fini_rwsem(struct rw_semaphore *s);
+void cfs_init_rwsem(cfs_rw_semaphore_t *s);
+void cfs_down_read(cfs_rw_semaphore_t *s);
+int cfs_down_read_trylock(cfs_rw_semaphore_t *s);
+void cfs_down_write(cfs_rw_semaphore_t *s);
+int cfs_down_write_trylock(cfs_rw_semaphore_t *s);
+void cfs_up_read(cfs_rw_semaphore_t *s);
+void cfs_up_write(cfs_rw_semaphore_t *s);
+void cfs_fini_rwsem(cfs_rw_semaphore_t *s);
 
 /*
  * read-write lock : Need to be investigated more!!
  * XXX nikita: for now, let rwlock_t to be identical to rw_semaphore
  *
- * - DECLARE_RWLOCK(l)
- * - rwlock_init(x)
- * - read_lock(x)
- * - read_unlock(x)
- * - write_lock(x)
- * - write_unlock(x)
+ * - cfs_rwlock_init(x)
+ * - cfs_read_lock(x)
+ * - cfs_read_unlock(x)
+ * - cfs_write_lock(x)
+ * - cfs_write_unlock(x)
+ * - cfs_write_lock_irqsave(x)
+ * - cfs_write_unlock_irqrestore(x)
+ * - cfs_read_lock_irqsave(x)
+ * - cfs_read_unlock_irqrestore(x)
  */
-typedef struct rw_semaphore rwlock_t;
-#define RW_LOCK_UNLOCKED        (rwlock_t) { }
+typedef cfs_rw_semaphore_t cfs_rwlock_t;
+#define CFS_RW_LOCK_UNLOCKED        (cfs_rwlock_t) { }
 
-#define rwlock_init(pl)         init_rwsem(pl)
+#define cfs_rwlock_init(pl)         cfs_init_rwsem(pl)
 
-#define read_lock(l)            down_read(l)
-#define read_unlock(l)          up_read(l)
-#define write_lock(l)           down_write(l)
-#define write_unlock(l)         up_write(l)
+#define cfs_read_lock(l)            cfs_down_read(l)
+#define cfs_read_unlock(l)          cfs_up_read(l)
+#define cfs_write_lock(l)           cfs_down_write(l)
+#define cfs_write_unlock(l)         cfs_up_write(l)
 
 static inline void
-write_lock_irqsave(rwlock_t *l, unsigned long f) { write_lock(l); }
+cfs_write_lock_irqsave(cfs_rwlock_t *l, unsigned long f) { cfs_write_lock(l); }
 static inline void
-write_unlock_irqrestore(rwlock_t *l, unsigned long f) { write_unlock(l); }
+cfs_write_unlock_irqrestore(cfs_rwlock_t *l, unsigned long f) { cfs_write_unlock(l); }
 
 static inline void
-read_lock_irqsave(rwlock_t *l, unsigned long f) { read_lock(l); }
+cfs_read_lock_irqsave(cfs_rwlock_t *l, unsigned long f) { cfs_read_lock(l); }
 static inline void
-read_unlock_irqrestore(rwlock_t *l, unsigned long f) { read_unlock(l); }
+cfs_read_unlock_irqrestore(cfs_rwlock_t *l, unsigned long f) { cfs_read_unlock(l); }
 
 /*
- * Atomic for user-space
- * Copied from liblustre
+ * Atomic for single-threaded user-space
  */
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#define atomic_read(a) ((a)->counter)
-#define atomic_set(a,b) do {(a)->counter = b; } while (0)
-#define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
-#define atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
-#define atomic_inc(a)  (((a)->counter)++)
-#define atomic_dec(a)  do { (a)->counter--; } while (0)
-#define atomic_add(b,a)  do {(a)->counter += b;} while (0)
-#define atomic_add_return(n,a) ((a)->counter += n)
-#define atomic_inc_return(a) atomic_add_return(1,a)
-#define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
-#define atomic_sub_return(n,a) ((a)->counter -= n)
-#define atomic_dec_return(a)  atomic_sub_return(1,a)
-#define atomic_add_unless(v, a, u) ((v)->counter != u ? (v)->counter += a : 0)
-#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+typedef struct { volatile int counter; } cfs_atomic_t;
 
+#define CFS_ATOMIC_INIT(i) { (i) }
+
+#define cfs_atomic_read(a) ((a)->counter)
+#define cfs_atomic_set(a,b) do {(a)->counter = b; } while (0)
+#define cfs_atomic_dec_and_test(a) ((--((a)->counter)) == 0)
+#define cfs_atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
+#define cfs_atomic_inc(a)  (((a)->counter)++)
+#define cfs_atomic_dec(a)  do { (a)->counter--; } while (0)
+#define cfs_atomic_add(b,a)  do {(a)->counter += b;} while (0)
+#define cfs_atomic_add_return(n,a) ((a)->counter += n)
+#define cfs_atomic_inc_return(a) cfs_atomic_add_return(1,a)
+#define cfs_atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
+#define cfs_atomic_sub_return(n,a) ((a)->counter -= n)
+#define cfs_atomic_dec_return(a)  cfs_atomic_sub_return(1,a)
+#define cfs_atomic_add_unless(v, a, u) \
+        ((v)->counter != u ? (v)->counter += a : 0)
+#define cfs_atomic_inc_not_zero(v) cfs_atomic_add_unless((v), 1, 0)
 
 #ifdef HAVE_LIBPTHREAD
 #include <pthread.h>
 
 /*
- * Completion
+ * Multi-threaded user space completion APIs
  */
 
-struct cfs_completion {
+typedef struct {
         int c_done;
         pthread_cond_t c_cond;
         pthread_mutex_t c_mut;
-};
+} cfs_mt_completion_t;
 
-void cfs_init_completion(struct cfs_completion *c);
-void cfs_fini_completion(struct cfs_completion *c);
-void cfs_complete(struct cfs_completion *c);
-void cfs_wait_for_completion(struct cfs_completion *c);
+void cfs_mt_init_completion(cfs_mt_completion_t *c);
+void cfs_mt_fini_completion(cfs_mt_completion_t *c);
+void cfs_mt_complete(cfs_mt_completion_t *c);
+void cfs_mt_wait_for_completion(cfs_mt_completion_t *c);
 
 /*
- * atomic.h
+ * Multi-threaded user space atomic APIs
  */
 
-typedef struct { volatile int counter; } cfs_atomic_t;
+typedef struct { volatile int counter; } cfs_mt_atomic_t;
 
-int cfs_atomic_read(cfs_atomic_t *a);
-void cfs_atomic_set(cfs_atomic_t *a, int b);
-int cfs_atomic_dec_and_test(cfs_atomic_t *a);
-void cfs_atomic_inc(cfs_atomic_t *a);
-void cfs_atomic_dec(cfs_atomic_t *a);
-void cfs_atomic_add(int b, cfs_atomic_t *a);
-void cfs_atomic_sub(int b, cfs_atomic_t *a);
+int cfs_mt_atomic_read(cfs_mt_atomic_t *a);
+void cfs_mt_atomic_set(cfs_mt_atomic_t *a, int b);
+int cfs_mt_atomic_dec_and_test(cfs_mt_atomic_t *a);
+void cfs_mt_atomic_inc(cfs_mt_atomic_t *a);
+void cfs_mt_atomic_dec(cfs_mt_atomic_t *a);
+void cfs_mt_atomic_add(int b, cfs_mt_atomic_t *a);
+void cfs_mt_atomic_sub(int b, cfs_mt_atomic_t *a);
 
 #endif /* HAVE_LIBPTHREAD */
 
@@ -280,26 +274,36 @@ void cfs_atomic_sub(int b, cfs_atomic_t *a);
  * Mutex interface.
  *
  **************************************************************************/
+#define CFS_DECLARE_MUTEX(name)     \
+        cfs_semaphore_t name = { 1 }
+
+#define cfs_mutex_up(s)                     __up(s)
+#define cfs_up(s)                           cfs_mutex_up(s)
+#define cfs_mutex_down(s)                   __down(s)
+#define cfs_down(s)                         cfs_mutex_down(s)
+
+#define cfs_init_mutex(x)                   cfs_sema_init(x, 1)
+#define cfs_init_mutex_locked(x)            cfs_sema_init(x, 0)
 
-struct mutex {
-        struct semaphore m_sem;
-};
+typedef struct cfs_mutex {
+        cfs_semaphore_t m_sem;
+} cfs_mutex_t;
 
-#define DEFINE_MUTEX(m) struct mutex m
+#define CFS_DEFINE_MUTEX(m) cfs_mutex_t m
 
-static inline void mutex_init(struct mutex *mutex)
+static inline void cfs_mutex_init(cfs_mutex_t *mutex)
 {
-        init_mutex(&mutex->m_sem);
+        cfs_init_mutex(&mutex->m_sem);
 }
 
-static inline void mutex_lock(struct mutex *mutex)
+static inline void cfs_mutex_lock(cfs_mutex_t *mutex)
 {
-        mutex_down(&mutex->m_sem);
+        cfs_mutex_down(&mutex->m_sem);
 }
 
-static inline void mutex_unlock(struct mutex *mutex)
+static inline void cfs_mutex_unlock(cfs_mutex_t *mutex)
 {
-        mutex_up(&mutex->m_sem);
+        cfs_mutex_up(&mutex->m_sem);
 }
 
 /**
@@ -309,7 +313,7 @@ static inline void mutex_unlock(struct mutex *mutex)
  * \retval 0 try-lock succeeded (lock acquired).
  * \retval errno indicates lock contention.
  */
-static inline int mutex_down_trylock(struct mutex *mutex)
+static inline int cfs_mutex_down_trylock(cfs_mutex_t *mutex)
 {
         return 0;
 }
@@ -323,12 +327,12 @@ static inline int mutex_down_trylock(struct mutex *mutex)
  * \retval 1 try-lock succeeded (lock acquired).
  * \retval 0 indicates lock contention.
  */
-static inline int mutex_trylock(struct mutex *mutex)
+static inline int cfs_mutex_trylock(cfs_mutex_t *mutex)
 {
-        return !mutex_down_trylock(mutex);
+        return !cfs_mutex_down_trylock(mutex);
 }
 
-static inline void mutex_destroy(struct mutex *lock)
+static inline void cfs_mutex_destroy(cfs_mutex_t *lock)
 {
 }
 
@@ -340,7 +344,7 @@ static inline void mutex_destroy(struct mutex *lock)
  *
  * \retval 0 mutex is not locked. This should never happen.
  */
-static inline int mutex_is_locked(struct mutex *lock)
+static inline int cfs_mutex_is_locked(cfs_mutex_t *lock)
 {
         return 1;
 }
@@ -352,28 +356,27 @@ static inline int mutex_is_locked(struct mutex *lock)
  *
  **************************************************************************/
 
-struct lock_class_key {
+typedef struct cfs_lock_class_key {
         int foo;
-};
+} cfs_lock_class_key_t;
 
-static inline void lockdep_set_class(void *lock, struct lock_class_key *key)
+static inline void cfs_lockdep_set_class(void *lock,
+                                         cfs_lock_class_key_t *key)
 {
 }
 
-static inline void lockdep_off(void)
+static inline void cfs_lockdep_off(void)
 {
 }
 
-static inline void lockdep_on(void)
+static inline void cfs_lockdep_on(void)
 {
 }
 
-/* This has to be a macro, so that can be undefined in kernels that do not
- * support lockdep. */
-#define mutex_lock_nested(mutex, subclass) mutex_lock(mutex)
-#define spin_lock_nested(lock, subclass) spin_lock(lock)
-#define down_read_nested(lock, subclass) down_read(lock)
-#define down_write_nested(lock, subclass) down_write(lock)
+#define cfs_mutex_lock_nested(mutex, subclass) cfs_mutex_lock(mutex)
+#define cfs_spin_lock_nested(lock, subclass) cfs_spin_lock(lock)
+#define cfs_down_read_nested(lock, subclass) cfs_down_read(lock)
+#define cfs_down_write_nested(lock, subclass) cfs_down_write(lock)
 
 
 /* !__KERNEL__ */
index ab501b8..3e72e20 100644 (file)
@@ -18,7 +18,7 @@
 typedef struct page {
         void   *addr;
         unsigned long index;
-        struct list_head list;
+        cfs_list_t list;
         unsigned long private;
 
         /* internally used by liblustre file i/o */
@@ -27,7 +27,7 @@ typedef struct page {
 #ifdef LIBLUSTRE_HANDLE_UNALIGNED_PAGE
         int     _managed;
 #endif
-        struct list_head _node;
+        cfs_list_t _node;
 } cfs_page_t;
 
 
@@ -77,10 +77,10 @@ typedef struct {
          int size;
 } cfs_mem_cache_t;
 
-#define SLAB_HWCACHE_ALIGN 0
-#define SLAB_DESTROY_BY_RCU 0
-#define SLAB_KERNEL 0
-#define SLAB_NOFS 0
+#define CFS_SLAB_HWCACHE_ALIGN 0
+#define CFS_SLAB_DESTROY_BY_RCU 0
+#define CFS_SLAB_KERNEL 0
+#define CFS_SLAB_NOFS 0
 
 cfs_mem_cache_t *
 cfs_mem_cache_create(const char *, size_t, size_t, unsigned long);
@@ -92,13 +92,13 @@ int cfs_mem_is_in_cache(const void *addr, const cfs_mem_cache_t *kmem);
 /*
  * Copy to/from user
  */
-static inline int copy_from_user(void *a,void *b, int c)
+static inline int cfs_copy_from_user(void *a,void *b, int c)
 {
         memcpy(a,b,c);
         return 0;
 }
 
-static inline int copy_to_user(void *a,void *b, int c)
+static inline int cfs_copy_to_user(void *a,void *b, int c)
 {
         memcpy(a,b,c);
         return 0;
index a5c4213..a39a4d7 100644 (file)
@@ -59,31 +59,34 @@ typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
  * Just present a single processor until will add thread support.
  */
 #ifndef smp_processor_id
-#define smp_processor_id() 0
+#define cfs_smp_processor_id() 0
+#else
+#define cfs_smp_processor_id() smp_processor_id()
 #endif
 #ifndef num_online_cpus
-#define num_online_cpus() 1
+#define cfs_num_online_cpus() 1
+#else
+#define cfs_num_online_cpus() num_online_cpus()
 #endif
 #ifndef num_possible_cpus
-#define num_possible_cpus() 1
+#define cfs_num_possible_cpus() 1
+#else
+#define cfs_num_possible_cpus() num_possible_cpus()
 #endif
 
 /*
- * Wait Queue. 
+ * Wait Queue.
  */
 
 typedef struct cfs_waitlink {
-        struct list_head sleeping;
+        cfs_list_t sleeping;
         void *process;
 } cfs_waitlink_t;
 
 typedef struct cfs_waitq {
-        struct list_head sleepers;
+        cfs_list_t sleepers;
 } cfs_waitq_t;
 
-/* XXX: need to replace wake_up with cfs_waitq_signal() */
-#define wake_up(q) cfs_waitq_signal(q)
-
 /*
  * Task states
  */
@@ -114,14 +117,14 @@ typedef sigset_t                        cfs_sigset_t;
  */
 
 typedef struct {
-        struct list_head tl_list;
+        cfs_list_t tl_list;
         void (*function)(ulong_ptr_t unused);
         ulong_ptr_t data;
         long expires;
 } cfs_timer_t;
 
 
-#define in_interrupt()    (0)
+#define cfs_in_interrupt()    (0)
 
 typedef void cfs_psdev_t;
 
@@ -136,7 +139,7 @@ static inline int cfs_psdev_deregister(cfs_psdev_t *foo)
 }
 
 #define cfs_lock_kernel()               do {} while (0)
-#define cfs_sigfillset(l) do {}         while (0)
+#define cfs_sigfillset(l)               do {} while (0)
 #define cfs_recalc_sigpending(l)        do {} while (0)
 #define cfs_kernel_thread(l,m,n)        LBUG()
 #define cfs_kthread_run(fn,d,fmt,...)   LBUG()
@@ -178,6 +181,13 @@ struct cfs_stack_trace {
         })
 #endif
 
+/*
+ * Groups
+ */
+typedef struct cfs_group_info {
+
+} cfs_group_info_t;
+
 #ifndef min
 # define min(x,y) ((x)<(y) ? (x) : (y))
 #endif
index 5a5cc3e..4f2bc8b 100644 (file)
@@ -99,11 +99,8 @@ typedef time_t cfs_fs_time_t;
 typedef time_t cfs_time_t;
 typedef time_t cfs_duration_t;
 
-/* looks like linux */
-#define time_after(a, b) ((long)(b) - (long)(a) < 0)
-#define time_before(a, b) time_after(b,a)
-#define time_after_eq(a,b)      ((long)(a) - (long)(b) >= 0)
-#define time_before_eq(a,b) time_after_eq(b,a)
+#define cfs_time_before(a, b) ((long)(a) - (long)(b) < 0)
+#define cfs_time_beforeq(a, b) ((long)(b) - (long)(a) >= 0)
 
 static inline cfs_time_t cfs_time_current(void)
 {
index 137dabe..8a17a83 100644 (file)
@@ -192,7 +192,7 @@ static inline void l_mutex_done(l_mutex_t *mutex)
 static inline void l_mutex_lock(l_mutex_t *mutex)
 {
 #if L_LOCK_DEBUG
-       printf("lock mutex  :%s\n", mutex->s_name);
+       printf("lock cfs_mutex  :%s\n", mutex->s_name);
 #endif
        sem_wait(mutex->s_sem);
 }
@@ -200,7 +200,7 @@ static inline void l_mutex_lock(l_mutex_t *mutex)
 static inline void l_mutex_unlock(l_mutex_t *mutex)
 {
 #if L_LOCK_DEBUG
-       printf("unlock mutex: %s\n", mutex->s_name);
+       printf("unlock cfs_mutex: %s\n", mutex->s_name);
 #endif
        sem_post(mutex->s_sem);
 }
index f2293ab..707f748 100644 (file)
@@ -44,9 +44,6 @@
 
 #define CFS_SYSFS_MODULE_PARM    0 /* no sysfs access to module parameters */
 
-#define cond_resched our_cond_resched
-void our_cond_resched();
-
 #define LASSERT_SPIN_LOCKED(lock) do {} while(0)
 #define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0)
 
@@ -93,7 +90,7 @@ void libcfs_unregister_panic_notifier();
 #define cfs_assert     _ASSERT
 
 #ifndef get_cpu
-#define cfs_get_cpu() smp_processor_id()
+#define cfs_get_cpu() cfs_smp_processor_id()
 #define cfs_put_cpu() do { } while (0)
 #else
 #define cfs_get_cpu() get_cpu()
index 0423fe9..19e72f9 100644 (file)
@@ -92,17 +92,17 @@ static inline __u32 query_stack_size()
 
 #endif /* __KERNEL__*/
 
-#ifndef THREAD_SIZE
-# define THREAD_SIZE query_stack_size()
+#ifndef CFS_THREAD_SIZE
+# define CFS_THREAD_SIZE query_stack_size()
 #endif
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
+#define LUSTRE_TRACE_SIZE (CFS_THREAD_SIZE >> 5)
 
 #ifdef __KERNEL__
-#define CDEBUG_STACK() (THREAD_SIZE - (__u32)IoGetRemainingStackSize())
-#define CHECK_STACK() do {} while(0)
+#define CDEBUG_STACK() (CFS_THREAD_SIZE - (__u32)IoGetRemainingStackSize())
+#define CFS_CHECK_STACK() do {} while(0)
 #else /* !__KERNEL__ */
-#define CHECK_STACK() do { } while(0)
+#define CFS_CHECK_STACK() do { } while(0)
 #define CDEBUG_STACK() (0L)
 #endif /* __KERNEL__ */
 
index cb60fe2..87ac31c 100644 (file)
@@ -77,24 +77,24 @@ char * ul2dstr(ulong_ptr_t address, char *buf, int len);
 
 unsigned long simple_strtoul(const char *cp,char **endp, unsigned int base);
 
-static inline int set_bit(int nr, void * addr)
+static inline int cfs_set_bit(int nr, void * addr)
 {
     (((volatile ULONG *) addr)[nr >> 5]) |= (1UL << (nr & 31));
     return *((int *) addr);
 }
 
-static inline int test_bit(int nr, void * addr)
+static inline int cfs_test_bit(int nr, void * addr)
 {
     return (int)(((1UL << (nr & 31)) & (((volatile ULONG *) addr)[nr >> 5])) != 0);
 }
 
-static inline int clear_bit(int nr, void * addr)
+static inline int cfs_clear_bit(int nr, void * addr)
 {
     (((volatile ULONG *) addr)[nr >> 5]) &= (~(1UL << (nr & 31)));
     return *((int *) addr);
 }
 
-static inline int test_and_set_bit(int nr, volatile void *addr)
+static inline int cfs_test_and_set_bit(int nr, volatile void *addr)
 {
     int rc;
     unsigned char  mask;
@@ -108,11 +108,11 @@ static inline int test_and_set_bit(int nr, volatile void *addr)
     return rc;
 }
 
-#define ext2_set_bit(nr,addr)   (set_bit(nr, addr), 0)
-#define ext2_clear_bit(nr,addr)        (clear_bit(nr, addr), 0)
-#define ext2_test_bit(nr,addr)  test_bit(nr, addr)
+#define ext2_set_bit(nr,addr)   (cfs_set_bit(nr, addr), 0)
+#define ext2_clear_bit(nr,addr)        (cfs_clear_bit(nr, addr), 0)
+#define ext2_test_bit(nr,addr)  cfs_test_bit(nr, addr)
 
-static inline int ffs(int x)
+static inline int cfs_ffs(int x)
 {
         int r = 1;
 
@@ -141,7 +141,7 @@ static inline int ffs(int x)
         return r;
 }
 
-static inline unsigned long __ffs(unsigned long word)
+static inline unsigned long __cfs_ffs(unsigned long word)
 {
         int num = 0;
 
@@ -180,7 +180,7 @@ static inline unsigned long __ffs(unsigned long word)
  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
  */
 static inline
-int fls(int x)
+int cfs_fls(int x)
 {
         int r = 32;
 
@@ -209,14 +209,15 @@ int fls(int x)
         return r;
 }
 
-static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
+static inline unsigned cfs_find_first_bit(const unsigned long *addr,
+                                          unsigned size)
 {
         unsigned x = 0;
 
         while (x < size) {
                 unsigned long val = *addr++;
                 if (val)
-                        return __ffs(val) + x;
+                        return __cfs_ffs(val) + x;
                 x += (sizeof(*addr)<<3);
         }
         return x;
@@ -239,7 +240,7 @@ static inline void read_random(char *buf, int len)
     }
 }
 
-#define get_random_bytes(buf, len)  read_random(buf, len)
+#define cfs_get_random_bytes(buf, len)  read_random(buf, len)
 
 /* do NOT use function or expression as parameters ... */
 
@@ -264,13 +265,13 @@ static inline void read_random(char *buf, int len)
        ((unsigned char *)&addr)[1],    \
        ((unsigned char *)&addr)[0]
 
-static int copy_from_user(void *to, void *from, int c) 
+static int cfs_copy_from_user(void *to, void *from, int c) 
 {
     memcpy(to, from, c);
     return 0;
 }
 
-static int copy_to_user(void *to, const void *from, int c) 
+static int cfs_copy_to_user(void *to, const void *from, int c) 
 {
     memcpy(to, from, c);
     return 0;
@@ -296,8 +297,8 @@ clear_user(void __user *to, unsigned long n)
     0                           \
 )
 
-#define num_physpages                  (64 * 1024)
-#define CFS_NUM_CACHEPAGES             num_physpages
+#define cfs_num_physpages               (64 * 1024)
+#define CFS_NUM_CACHEPAGES              cfs_num_physpages
 
 #else
 
index e3d52c0..5f6db90 100644 (file)
@@ -91,7 +91,7 @@
 
 struct file_operations
 {
-    struct module *owner;
+    cfs_module_t *owner;
     loff_t (*llseek)(struct file * file, loff_t offset, int origin);
     ssize_t (*read) (struct file * file, char * buf, size_t nbytes, loff_t *ppos);
     ssize_t (*write)(struct file * file, const char * buffer,
@@ -240,14 +240,14 @@ struct inode {
         int             i_uid;
         int             i_gid;
         __u32           i_flags;
-        mutex_t         i_sem;
+        cfs_mutex_t     i_sem;
         void *          i_priv;
 };
 
 #define I_FREEING       0x0001
 
 struct dentry {
-        atomic_t        d_count;
+        cfs_atomic_t    d_count;
         struct {
             int         len;
             char *      name;
@@ -276,7 +276,7 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
     inode->i_size = i_size;
 }
 
-struct kstatfs {
+typedef struct cfs_kstatfs {
         u64     f_type;
         long    f_bsize;
         u64     f_blocks;
@@ -288,7 +288,7 @@ struct kstatfs {
         long    f_namelen;
         long    f_frsize;
         long    f_spare[5];
-};
+} cfs_kstatfs_t;
 
 struct super_block {
         void *  s_fs_info;
@@ -370,14 +370,15 @@ VOID RadixInitTable(IN PRTL_GENERIC_TABLE Table);
 /* all radix tree routines should be protected by external locks */
 unsigned int
 radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
-                       unsigned long first_index, unsigned int max_items);
+                       unsigned long first_index, unsigned int max_items);
 void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index);
-int radix_tree_insert(struct radix_tree_root *root,unsigned long index, void *item);
+int radix_tree_insert(struct radix_tree_root *root, unsigned long index,
+                      void *item);
 void *radix_tree_delete(struct radix_tree_root *root, unsigned long index);
 
-struct rcu_head {
+typedef struct cfs_rcu_head {
     int     foo;
-};
+} cfs_rcu_head_t;
 
 #else  /* !__KERNEL__ */
 
index cbff12d..4c7bd5e 100644 (file)
  *  spinlock & event definitions
  */
 
-typedef struct spin_lock spinlock_t;
+typedef struct cfs_spin_lock cfs_spinlock_t;
 
 /* atomic */
 
-typedef struct { volatile int counter; } atomic_t;
+typedef struct { volatile int counter; } cfs_atomic_t;
 
-#define ATOMIC_INIT(i) { i }
+#define CFS_ATOMIC_INIT(i)     { i }
 
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v,i)                (((v)->counter) = (i))
+#define cfs_atomic_read(v)     ((v)->counter)
+#define cfs_atomic_set(v,i)    (((v)->counter) = (i))
 
-void FASTCALL atomic_add(int i, atomic_t *v);
-void FASTCALL atomic_sub(int i, atomic_t *v);
+void FASTCALL cfs_atomic_add(int i, cfs_atomic_t *v);
+void FASTCALL cfs_atomic_sub(int i, cfs_atomic_t *v);
 
-int FASTCALL atomic_sub_and_test(int i, atomic_t *v);
+int FASTCALL cfs_atomic_sub_and_test(int i, cfs_atomic_t *v);
 
-void FASTCALL atomic_inc(atomic_t *v);
-void FASTCALL atomic_dec(atomic_t *v);
+void FASTCALL cfs_atomic_inc(cfs_atomic_t *v);
+void FASTCALL cfs_atomic_dec(cfs_atomic_t *v);
 
-int FASTCALL atomic_dec_and_test(atomic_t *v);
-int FASTCALL atomic_inc_and_test(atomic_t *v);
+int FASTCALL cfs_atomic_dec_and_test(cfs_atomic_t *v);
+int FASTCALL cfs_atomic_inc_and_test(cfs_atomic_t *v);
 
-int FASTCALL atomic_add_return(int i, atomic_t *v);
-int FASTCALL atomic_sub_return(int i, atomic_t *v);
+int FASTCALL cfs_atomic_add_return(int i, cfs_atomic_t *v);
+int FASTCALL cfs_atomic_sub_return(int i, cfs_atomic_t *v);
 
-#define atomic_inc_return(v)  atomic_add_return(1, v)
-#define atomic_dec_return(v)  atomic_sub_return(1, v)
+#define cfs_atomic_inc_return(v)  cfs_atomic_add_return(1, v)
+#define cfs_atomic_dec_return(v)  cfs_atomic_sub_return(1, v)
 
-int FASTCALL atomic_dec_and_lock(atomic_t *v, spinlock_t *lock);
+int FASTCALL cfs_atomic_dec_and_lock(cfs_atomic_t *v, cfs_spinlock_t *lock);
 
 /* event */
 
@@ -113,7 +113,7 @@ typedef KEVENT          event_t;
  *   N/A
  */
 static inline void
-    cfs_init_event(event_t *event, int type, int status)
+cfs_init_event(event_t *event, int type, int status)
 {
     KeInitializeEvent(
             event,
@@ -144,7 +144,7 @@ cfs_wait_event_internal(event_t * event, int64_t timeout)
     NTSTATUS        Status;
     LARGE_INTEGER   TimeOut;
 
-    TimeOut.QuadPart = -1 * (10000000/HZ) * timeout;
+    TimeOut.QuadPart = -1 * (10000000/CFS_HZ) * timeout;
 
     Status = KeWaitForSingleObject(
                 event,
@@ -215,40 +215,43 @@ cfs_clear_event(event_t * event)
  *
  */
 
-struct spin_lock {
+struct cfs_spin_lock {
     KSPIN_LOCK lock;
     KIRQL      irql;
 };
 
-#define CFS_DECL_SPIN(name)  spinlock_t name;
-#define CFS_DECL_SPIN_EXTERN(name)  extern spinlock_t name;
+#define CFS_DECL_SPIN(name)  cfs_spinlock_t name;
+#define CFS_DECL_SPIN_EXTERN(name)  extern cfs_spinlock_t name;
 
-#define SPIN_LOCK_UNLOCKED {0}
+#define CFS_SPIN_LOCK_UNLOCKED {0}
 
-static inline void spin_lock_init(spinlock_t *lock)
+static inline void cfs_spin_lock_init(cfs_spinlock_t *lock)
 {
     KeInitializeSpinLock(&(lock->lock));
 }
 
-static inline void spin_lock(spinlock_t *lock)
+static inline void cfs_spin_lock(cfs_spinlock_t *lock)
 {
     KeAcquireSpinLock(&(lock->lock), &(lock->irql));
 }
 
-static inline void spin_lock_nested(spinlock_t *lock, unsigned subclass)
+static inline void cfs_spin_lock_nested(cfs_spinlock_t *lock, unsigned subclass)
 {
     KeAcquireSpinLock(&(lock->lock), &(lock->irql));
 }
 
-static inline void spin_unlock(spinlock_t *lock)
+static inline void cfs_spin_unlock(cfs_spinlock_t *lock)
 {
     KIRQL       irql = lock->irql;
     KeReleaseSpinLock(&(lock->lock), irql);
 }
 
 
-#define spin_lock_irqsave(lock, flags)         do {(flags) = 0; spin_lock(lock);} while(0)
-#define spin_unlock_irqrestore(lock, flags)    do {spin_unlock(lock);} while(0)
+#define cfs_spin_lock_irqsave(lock, flags)  \
+do {(flags) = 0; cfs_spin_lock(lock);} while(0)
+
+#define cfs_spin_unlock_irqrestore(lock, flags) \
+do {cfs_spin_unlock(lock);} while(0)
 
 
 /* There's no  corresponding routine in windows kernel.
@@ -258,7 +261,7 @@ static inline void spin_unlock(spinlock_t *lock)
 
 extern int libcfs_mp_system;
 
-static int spin_trylock(spinlock_t *lock)
+static int cfs_spin_trylock(cfs_spinlock_t *lock)
 {
     KIRQL   Irql;
     int     rc = 0;
@@ -295,7 +298,7 @@ static int spin_trylock(spinlock_t *lock)
     return rc;
 }
 
-static int spin_is_locked(spinlock_t *lock)
+static int cfs_spin_is_locked(cfs_spinlock_t *lock)
 {
 #if _WIN32_WINNT >= 0x502
     /* KeTestSpinLock only avalilable on 2k3 server or later */
@@ -307,30 +310,29 @@ static int spin_is_locked(spinlock_t *lock)
 
 /* synchronization between cpus: it will disable all DPCs
    kernel task scheduler on the CPU */
-#define spin_lock_bh(x)                    spin_lock(x)
-#define spin_unlock_bh(x)          spin_unlock(x)
-#define spin_lock_bh_init(x)   spin_lock_init(x)
+#define cfs_spin_lock_bh(x)                cfs_spin_lock(x)
+#define cfs_spin_unlock_bh(x)      cfs_spin_unlock(x)
+#define cfs_spin_lock_bh_init(x)       cfs_spin_lock_init(x)
 
 /*
- * rw_semaphore (using ERESOURCE)
+ * cfs_rw_semaphore (using ERESOURCE)
  */
 
 
-typedef struct rw_semaphore {
+typedef struct cfs_rw_semaphore {
     ERESOURCE   rwsem;
-} rw_semaphore_t;
+} cfs_rw_semaphore_t;
 
 
-#define CFS_DECL_RWSEM(name) rw_semaphore_t name
-#define CFS_DECL_RWSEM_EXTERN(name) extern rw_semaphore_t name
-#define DECLARE_RWSEM CFS_DECL_RWSEM
+#define CFS_DECLARE_RWSEM(name) cfs_rw_semaphore_t name
+#define CFS_DECLARE_RWSEM_EXTERN(name) extern cfs_rw_semaphore_t name
 
 /*
- * init_rwsem
- *   To initialize the the rw_semaphore_t structure
+ * cfs_init_rwsem
+ *   To initialize the the cfs_rw_semaphore_t structure
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -339,18 +341,18 @@ typedef struct rw_semaphore {
  *   N/A
  */
 
-static inline void init_rwsem(rw_semaphore_t *s)
+static inline void cfs_init_rwsem(cfs_rw_semaphore_t *s)
 {
        ExInitializeResourceLite(&s->rwsem);
 }
-#define rwsem_init init_rwsem
+#define rwsem_init cfs_init_rwsem
 
 /*
- * fini_rwsem
- *   To finilize/destroy the the rw_semaphore_t structure
+ * cfs_fini_rwsem
+ *   To finilize/destroy the the cfs_rw_semaphore_t structure
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -360,18 +362,17 @@ static inline void init_rwsem(rw_semaphore_t *s)
  *   Just define it NULL for other systems.
  */
 
-static inline void fini_rwsem(rw_semaphore_t *s)
+static inline void cfs_fini_rwsem(cfs_rw_semaphore_t *s)
 {
     ExDeleteResourceLite(&s->rwsem);
 }
-#define rwsem_fini fini_rwsem
 
 /*
- * down_read
- *   To acquire read-lock of the rw_semahore
+ * cfs_down_read
+ *   To acquire read-lock of the cfs_rw_semaphore
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -380,19 +381,19 @@ static inline void fini_rwsem(rw_semaphore_t *s)
  *   N/A
  */
 
-static inline void down_read(struct rw_semaphore *s)
+static inline void cfs_down_read(cfs_rw_semaphore_t *s)
 {
        ExAcquireResourceSharedLite(&s->rwsem, TRUE);
 }
-#define down_read_nested down_read
+#define cfs_down_read_nested cfs_down_read
 
 
 /*
- * down_read_trylock
- *   To acquire read-lock of the rw_semahore without blocking
+ * cfs_down_read_trylock
+ *   To acquire read-lock of the cfs_rw_semaphore without blocking
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   Zero: failed to acquire the read lock
@@ -402,18 +403,18 @@ static inline void down_read(struct rw_semaphore *s)
  *   This routine will return immediately without waiting.
  */
 
-static inline int down_read_trylock(struct rw_semaphore *s)
+static inline int cfs_down_read_trylock(cfs_rw_semaphore_t *s)
 {
        return ExAcquireResourceSharedLite(&s->rwsem, FALSE);
 }
 
 
 /*
- * down_write
- *   To acquire write-lock of the rw_semahore
+ * cfs_down_write
+ *   To acquire write-lock of the cfs_rw_semaphore
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -422,18 +423,18 @@ static inline int down_read_trylock(struct rw_semaphore *s)
  *   N/A
  */
 
-static inline void down_write(struct rw_semaphore *s)
+static inline void cfs_down_write(cfs_rw_semaphore_t *s)
 {
        ExAcquireResourceExclusiveLite(&(s->rwsem), TRUE);
 }
-#define down_write_nested down_write
+#define cfs_down_write_nested cfs_down_write
 
 /*
  * down_write_trylock
- *   To acquire write-lock of the rw_semahore without blocking
+ *   To acquire write-lock of the cfs_rw_semaphore without blocking
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   Zero: failed to acquire the write lock
@@ -443,18 +444,18 @@ static inline void down_write(struct rw_semaphore *s)
  *   This routine will return immediately without waiting.
  */
 
-static inline int down_write_trylock(struct rw_semaphore *s)
+static inline int cfs_down_write_trylock(cfs_rw_semaphore_t *s)
 {
     return ExAcquireResourceExclusiveLite(&(s->rwsem), FALSE);
 }
 
 
 /*
- * up_read
- *   To release read-lock of the rw_semahore
+ * cfs_up_read
+ *   To release read-lock of the cfs_rw_semaphore
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -463,7 +464,7 @@ static inline int down_write_trylock(struct rw_semaphore *s)
  *   N/A
  */
 
-static inline void up_read(struct rw_semaphore *s)
+static inline void cfs_up_read(cfs_rw_semaphore_t *s)
 {
     ExReleaseResourceForThreadLite(
             &(s->rwsem),
@@ -472,11 +473,11 @@ static inline void up_read(struct rw_semaphore *s)
 
 
 /*
- * up_write
- *   To release write-lock of the rw_semahore
+ * cfs_up_write
+ *   To release write-lock of the cfs_rw_semaphore
  *
  * Arguments:
- *   rwsem:  pointer to the rw_semaphore_t structure
+ *   rwsem:  pointer to the cfs_rw_semaphore_t structure
  *
  * Return Value:
  *   N/A
@@ -485,7 +486,7 @@ static inline void up_read(struct rw_semaphore *s)
  *   N/A
  */
 
-static inline void up_write(struct rw_semaphore *s)
+static inline void cfs_up_write(cfs_rw_semaphore_t *s)
 {
     ExReleaseResourceForThreadLite(
                 &(s->rwsem),
@@ -503,34 +504,37 @@ static inline void up_write(struct rw_semaphore *s)
  */
 
 typedef struct {
-    spinlock_t guard;
-    int        count;
-} rwlock_t;
+    cfs_spinlock_t guard;
+    int            count;
+} cfs_rwlock_t;
+
+void cfs_rwlock_init(cfs_rwlock_t * rwlock);
+void cfs_rwlock_fini(cfs_rwlock_t * rwlock);
 
-void rwlock_init(rwlock_t * rwlock);
-void rwlock_fini(rwlock_t * rwlock);
+void cfs_read_lock(cfs_rwlock_t * rwlock);
+void cfs_read_unlock(cfs_rwlock_t * rwlock);
+void cfs_write_lock(cfs_rwlock_t * rwlock);
+void cfs_write_unlock(cfs_rwlock_t * rwlock);
 
-void read_lock(rwlock_t * rwlock);
-void read_unlock(rwlock_t * rwlock);
-void write_lock(rwlock_t * rwlock);
-void write_unlock(rwlock_t * rwlock);
+#define cfs_write_lock_irqsave(l, f)     do {f = 0; cfs_write_lock(l);} while(0)
+#define cfs_write_unlock_irqrestore(l, f)   do {cfs_write_unlock(l);} while(0)
+#define cfs_read_lock_irqsave(l, f         do {f=0; cfs_read_lock(l);} while(0)
+#define cfs_read_unlock_irqrestore(l, f)    do {cfs_read_unlock(l);} while(0)
 
-#define write_lock_irqsave(l, f)        do {f = 0; write_lock(l);} while(0)
-#define write_unlock_irqrestore(l, f)   do {write_unlock(l);} while(0)
-#define read_lock_irqsave(l, f)                do {f=0; read_lock(l);} while(0)
-#define read_unlock_irqrestore(l, f)    do {read_unlock(l);} while(0)
+#define cfs_write_lock_bh   cfs_write_lock
+#define cfs_write_unlock_bh cfs_write_unlock
 
-#define write_lock_bh   write_lock
-#define write_unlock_bh write_unlock
+typedef struct cfs_lock_class_key {
+        int foo;
+} cfs_lock_class_key_t;
 
-struct lock_class_key {int foo;};
-#define lockdep_set_class(lock, class) do {} while(0)
+#define cfs_lockdep_set_class(lock, class) do {} while(0)
 
-static inline void lockdep_off(void)
+static inline void cfs_lockdep_off(void)
 {
 }
 
-static inline void lockdep_on(void)
+static inline void cfs_lockdep_on(void)
 {
 }
 
@@ -542,27 +546,27 @@ static inline void lockdep_on(void)
  * - __up(x)
  */
 
-struct semaphore{
+typedef struct cfs_semaphore {
        KSEMAPHORE sem;
-};
+} cfs_semaphore_t;
 
-static inline void sema_init(struct semaphore *s, int val)
+static inline void cfs_sema_init(cfs_semaphore_t *s, int val)
 {
        KeInitializeSemaphore(&s->sem, val, val);
 }
 
-static inline void __down(struct semaphore *s)
+static inline void __down(cfs_semaphore_t *s)
 {
    KeWaitForSingleObject( &(s->sem), Executive,
                           KernelMode, FALSE, NULL );
 
 }
-static inline void __up(struct semaphore *s)
+static inline void __up(cfs_semaphore_t *s)
 {
        KeReleaseSemaphore(&s->sem, 0, 1, FALSE);
 }
 
-static inline int down_trylock(struct semaphore * s)
+static inline int down_trylock(cfs_semaphore_t *s)
 {
     LARGE_INTEGER  timeout = {0};
     NTSTATUS status =
@@ -585,10 +589,9 @@ static inline int down_trylock(struct semaphore * s)
  * - mutex_down(x)
  */
 
-#define mutex semaphore
-typedef struct semaphore mutex_t;
+typedef struct cfs_semaphore cfs_mutex_t;
 
-#define DECLARE_MUTEX(x) mutex_t x
+#define CFS_DECLARE_MUTEX(x) cfs_mutex_t x
 
 /*
  * init_mutex
@@ -603,13 +606,12 @@ typedef struct semaphore mutex_t;
  * Notes:
  *   N/A
  */
-#define mutex_init init_mutex
-static inline void init_mutex(mutex_t *mutex)
+#define cfs_mutex_init cfs_init_mutex
+static inline void cfs_init_mutex(cfs_mutex_t *mutex)
 {
-    sema_init(mutex, 1);
+    cfs_sema_init(mutex, 1);
 }
 
-#define init_MUTEX init_mutex
 /*
  * mutex_down
  *   To acquire the mutex lock
@@ -624,15 +626,15 @@ static inline void init_mutex(mutex_t *mutex)
  *   N/A
  */
 
-static inline void mutex_down(mutex_t *mutex)
+static inline void cfs_mutex_down(cfs_mutex_t *mutex)
 {
     __down(mutex);
 }
 
-#define mutex_lock(m) mutex_down(m)
-#define mutex_trylock(s) down_trylock(s)
-#define mutex_lock_nested(m) mutex_down(m)
-#define down(m)       mutex_down(m)
+#define cfs_mutex_lock(m) cfs_mutex_down(m)
+#define cfs_mutex_trylock(s) down_trylock(s)
+#define cfs_mutex_lock_nested(m) cfs_mutex_down(m)
+#define cfs_down(m)       cfs_mutex_down(m)
 
 /*
  * mutex_up
@@ -648,13 +650,13 @@ static inline void mutex_down(mutex_t *mutex)
  *   N/A
  */
 
-static inline void mutex_up(mutex_t *mutex)
+static inline void cfs_mutex_up(cfs_mutex_t *mutex)
 {
     __up(mutex);
 }
 
-#define mutex_unlock(m) mutex_up(m)
-#define up(m)           mutex_up(m)
+#define cfs_mutex_unlock(m) cfs_mutex_up(m)
+#define cfs_up(m)           cfs_mutex_up(m)
 
 /*
  * init_mutex_locked
@@ -670,15 +672,13 @@ static inline void mutex_up(mutex_t *mutex)
  *   N/A
  */
 
-static inline void init_mutex_locked(mutex_t *mutex)
+static inline void cfs_init_mutex_locked(cfs_mutex_t *mutex)
 {
-    init_mutex(mutex);
-    mutex_down(mutex);
+    cfs_init_mutex(mutex);
+    cfs_mutex_down(mutex);
 }
 
-#define init_MUTEX_LOCKED init_mutex_locked
-
-static inline void mutex_destroy(mutex_t *mutex)
+static inline void cfs_mutex_destroy(cfs_mutex_t *mutex)
 {
 }
 
@@ -690,9 +690,9 @@ static inline void mutex_destroy(mutex_t *mutex)
  * - wait_for_completion(c)
  */
 
-struct completion {
+typedef struct {
        event_t  event;
-};
+} cfs_completion_t;
 
 
 /*
@@ -709,7 +709,7 @@ struct completion {
  *   N/A
  */
 
-static inline void init_completion(struct completion *c)
+static inline void cfs_init_completion(cfs_completion_t *c)
 {
        cfs_init_event(&(c->event), 1, FALSE);
 }
@@ -729,7 +729,7 @@ static inline void init_completion(struct completion *c)
  *   N/A
  */
 
-static inline void complete(struct completion *c)
+static inline void cfs_complete(cfs_completion_t *c)
 {
        cfs_wake_event(&(c->event));
 }
@@ -749,55 +749,17 @@ static inline void complete(struct completion *c)
  *   N/A
  */
 
-static inline void wait_for_completion(struct completion *c)
+static inline void cfs_wait_for_completion(cfs_completion_t *c)
 {
     cfs_wait_event_internal(&(c->event), 0);
 }
 
-static inline int wait_for_completion_interruptible(struct completion *c)
+static inline int cfs_wait_for_completion_interruptible(cfs_completion_t *c)
 {
     cfs_wait_event_internal(&(c->event), 0);
     return 0;
 }
 
-/*
- * spinlock "implementation"
- */
-
-typedef spinlock_t cfs_spinlock_t;
-
-#define cfs_spin_lock_init(lock) spin_lock_init(lock)
-#define cfs_spin_lock(lock)      spin_lock(lock)
-#define cfs_spin_lock_bh(lock)   spin_lock_bh(lock)
-#define cfs_spin_unlock(lock)    spin_unlock(lock)
-#define cfs_spin_unlock_bh(lock) spin_unlock_bh(lock)
-
-/*
- * rwlock "implementation"
- */
-
-typedef rwlock_t cfs_rwlock_t;
-
-#define cfs_rwlock_init(lock)      rwlock_init(lock)
-#define cfs_read_lock(lock)        read_lock(lock)
-#define cfs_read_unlock(lock)      read_unlock(lock)
-#define cfs_write_lock_bh(lock)    write_lock_bh(lock)
-#define cfs_write_unlock_bh(lock)  write_unlock_bh(lock)
-
-/*
- * atomic
- */
-
-typedef atomic_t cfs_atomic_t;
-
-#define cfs_atomic_read(atom)         atomic_read(atom)
-#define cfs_atomic_inc(atom)          atomic_inc(atom)
-#define cfs_atomic_dec(atom)          atomic_dec(atom)
-#define cfs_atomic_dec_and_test(atom) atomic_dec_and_test(atom)
-#define cfs_atomic_set(atom, value)   atomic_set(atom, value)
-#define cfs_atomic_add(value, atom)   atomic_add(value, atom)
-#define cfs_atomic_sub(value, atom)   atomic_sub(value, atom)
-
 #else  /* !__KERNEL__ */
 #endif /* !__KERNEL__ */
 #endif
index 7f3d7ae..407244f 100644 (file)
@@ -60,12 +60,12 @@ typedef struct cfs_mem_cache cfs_mem_cache_t;
 #define CFS_PAGE_MASK                   (~(PAGE_SIZE - 1))
 
 typedef struct cfs_page {
-    void *      addr;
-    atomic_t    count;
-    void *      private;
-    void *      mapping;
-    __u32       index;
-    __u32       flags;
+    void *          addr;
+    cfs_atomic_t    count;
+    void *          private;
+    void *          mapping;
+    __u32           index;
+    __u32           flags;
 } cfs_page_t;
 
 #define page cfs_page
@@ -108,42 +108,42 @@ typedef struct cfs_page {
 
 /* Make it prettier to test the above... */
 #define UnlockPage(page)        unlock_page(page)
-#define Page_Uptodate(page)     test_bit(PG_uptodate, &(page)->flags)
+#define Page_Uptodate(page)     cfs_test_bit(PG_uptodate, &(page)->flags)
 #define SetPageUptodate(page) \
        do {                                                            \
                arch_set_page_uptodate(page);                           \
-               set_bit(PG_uptodate, &(page)->flags);                   \
+               cfs_set_bit(PG_uptodate, &(page)->flags);               \
        } while (0)
-#define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags)
-#define PageDirty(page)         test_bit(PG_dirty, &(page)->flags)
-#define SetPageDirty(page)      set_bit(PG_dirty, &(page)->flags)
-#define ClearPageDirty(page)    clear_bit(PG_dirty, &(page)->flags)
-#define PageLocked(page)        test_bit(PG_locked, &(page)->flags)
-#define LockPage(page)          set_bit(PG_locked, &(page)->flags)
-#define TryLockPage(page)       test_and_set_bit(PG_locked, &(page)->flags)
-#define PageChecked(page)       test_bit(PG_checked, &(page)->flags)
-#define SetPageChecked(page)    set_bit(PG_checked, &(page)->flags)
-#define ClearPageChecked(page)  clear_bit(PG_checked, &(page)->flags)
-#define PageLaunder(page)       test_bit(PG_launder, &(page)->flags)
-#define SetPageLaunder(page)    set_bit(PG_launder, &(page)->flags)
-#define ClearPageLaunder(page)  clear_bit(PG_launder, &(page)->flags)
-#define ClearPageArch1(page)    clear_bit(PG_arch_1, &(page)->flags)
-
-#define PageError(page)                test_bit(PG_error, &(page)->flags)
-#define SetPageError(page)     set_bit(PG_error, &(page)->flags)
-#define ClearPageError(page)   clear_bit(PG_error, &(page)->flags)
-#define PageReferenced(page)    test_bit(PG_referenced, &(page)->flags)
-#define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
-#define ClearPageReferenced(page)       clear_bit(PG_referenced, &(page)->flags)
-
-#define PageActive(page)        test_bit(PG_active, &(page)->flags)
-#define SetPageActive(page)     set_bit(PG_active, &(page)->flags)
-#define ClearPageActive(page)   clear_bit(PG_active, &(page)->flags)
-
-#define PageWriteback(page)    test_bit(PG_writeback, &(page)->flags)
-#define TestSetPageWriteback(page) test_and_set_bit(PG_writeback,      \
+#define ClearPageUptodate(page) cfs_clear_bit(PG_uptodate, &(page)->flags)
+#define PageDirty(page)         cfs_test_bit(PG_dirty, &(page)->flags)
+#define SetPageDirty(page)      cfs_set_bit(PG_dirty, &(page)->flags)
+#define ClearPageDirty(page)    cfs_clear_bit(PG_dirty, &(page)->flags)
+#define PageLocked(page)        cfs_test_bit(PG_locked, &(page)->flags)
+#define LockPage(page)          cfs_set_bit(PG_locked, &(page)->flags)
+#define TryLockPage(page)       cfs_test_and_set_bit(PG_locked, &(page)->flags)
+#define PageChecked(page)       cfs_test_bit(PG_checked, &(page)->flags)
+#define SetPageChecked(page)    cfs_set_bit(PG_checked, &(page)->flags)
+#define ClearPageChecked(page)  cfs_clear_bit(PG_checked, &(page)->flags)
+#define PageLaunder(page)       cfs_test_bit(PG_launder, &(page)->flags)
+#define SetPageLaunder(page)    cfs_set_bit(PG_launder, &(page)->flags)
+#define ClearPageLaunder(page)  cfs_clear_bit(PG_launder, &(page)->flags)
+#define ClearPageArch1(page)    cfs_clear_bit(PG_arch_1, &(page)->flags)
+
+#define PageError(page)                cfs_test_bit(PG_error, &(page)->flags)
+#define SetPageError(page)     cfs_set_bit(PG_error, &(page)->flags)
+#define ClearPageError(page)   cfs_clear_bit(PG_error, &(page)->flags)
+#define PageReferenced(page)    cfs_test_bit(PG_referenced, &(page)->flags)
+#define SetPageReferenced(page) cfs_set_bit(PG_referenced, &(page)->flags)
+#define ClearPageReferenced(page) cfs_clear_bit(PG_referenced, &(page)->flags)
+
+#define PageActive(page)        cfs_test_bit(PG_active, &(page)->flags)
+#define SetPageActive(page)     cfs_set_bit(PG_active, &(page)->flags)
+#define ClearPageActive(page)   cfs_clear_bit(PG_active, &(page)->flags)
+
+#define PageWriteback(page)    cfs_test_bit(PG_writeback, &(page)->flags)
+#define TestSetPageWriteback(page) cfs_test_and_set_bit(PG_writeback,  \
                                                        &(page)->flags)
-#define TestClearPageWriteback(page) test_and_clear_bit(PG_writeback,  \
+#define TestClearPageWriteback(page) cfs_test_and_clear_bit(PG_writeback, \
                                                        &(page)->flags)
 
 #define __GFP_FS    (1)
@@ -178,17 +178,17 @@ static inline void cfs_kunmap(cfs_page_t *page)
 
 static inline void cfs_get_page(cfs_page_t *page)
 {
-    atomic_inc(&page->count);
+    cfs_atomic_inc(&page->count);
 }
 
 static inline void cfs_put_page(cfs_page_t *page)
 {
-    atomic_dec(&page->count);
+    cfs_atomic_dec(&page->count);
 }
 
 static inline int cfs_page_count(cfs_page_t *page)
 {
-    return atomic_read(&page->count);
+    return cfs_atomic_read(&page->count);
 }
 
 #define cfs_page_index(p)       ((p)->index)
@@ -210,7 +210,7 @@ extern void  cfs_free_large(void *addr);
  * SLAB allocator
  */
 
-#define SLAB_HWCACHE_ALIGN             0
+#define CFS_SLAB_HWCACHE_ALIGN         0
 
 /* The cache name is limited to 20 chars */
 
@@ -221,26 +221,27 @@ struct cfs_mem_cache {
 };
 
 
-extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long);
-extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
-extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
-extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
+extern cfs_mem_cache_t *cfs_mem_cache_create (const char *, size_t, size_t,
+                                              unsigned long);
+extern int cfs_mem_cache_destroy (cfs_mem_cache_t * );
+extern void *cfs_mem_cache_alloc (cfs_mem_cache_t *, int);
+extern void cfs_mem_cache_free (cfs_mem_cache_t *, void *);
 
 /*
  * shrinker 
  */
 typedef int (*shrink_callback)(int nr_to_scan, gfp_t gfp_mask);
-struct shrinker {
-    shrink_callback cb;
+struct cfs_shrinker {
+        shrink_callback cb;
        int seeks;      /* seeks to recreate an obj */
 
        /* These are for internal use */
-       struct list_head list;
+       cfs_list_t list;
        long nr;        /* objs pending delete */
 };
 
-struct shrinker * set_shrinker(int seeks, shrink_callback cb);
-void remove_shrinker(struct shrinker *s);
+struct cfs_shrinker *cfs_set_shrinker(int seeks, shrink_callback cb);
+void cfs_remove_shrinker(struct cfs_shrinker *s);
 
 int start_shrinker_timer();
 void stop_shrinker_timer();
@@ -258,16 +259,15 @@ extern cfs_mem_cache_t *cfs_page_p_slab;
 #define CFS_MMSPACE_CLOSE   do {} while(0)
 
 
-#define mb()     do {} while(0)
-#define rmb()    mb()
-#define wmb()    mb()
-#define cfs_mb() mb()
+#define cfs_mb()     do {} while(0)
+#define rmb()        cfs_mb()
+#define wmb()        cfs_mb()
 
 /*
  * MM defintions from (linux/mm.h)
  */
 
-#define DEFAULT_SEEKS 2 /* shrink seek */
+#define CFS_DEFAULT_SEEKS 2 /* shrink seek */
 
 #else  /* !__KERNEL__ */
 
index 3414023..a7432fb 100644 (file)
@@ -96,10 +96,10 @@ void cfs_enter_debugger(void);
 #define CFS_SYMBOL_LEN     64
 
 struct  cfs_symbol {
-       char    name[CFS_SYMBOL_LEN];
-       void    *value;
-       int     ref;
-       struct  list_head sym_list;
+       char       name[CFS_SYMBOL_LEN];
+       void      *value;
+       int        ref;
+       cfs_list_t sym_list;
 };
 
 extern int      cfs_symbol_register(const char *, const void *);
@@ -260,7 +260,7 @@ struct ctl_table
 struct ctl_table_header
 {
        cfs_sysctl_table_t *    ctl_table;
-       struct list_head        ctl_entry;
+       cfs_list_t              ctl_entry;
 };
 
 /* proc root entries, support routines */
@@ -321,7 +321,7 @@ struct seq_file {
        size_t count;
        loff_t index;
        u32    version;
-       mutex_t lock;
+       cfs_mutex_t lock;
        const struct seq_operations *op;
        void *private;
 };
@@ -358,12 +358,9 @@ int seq_release_private(struct inode *, struct file *);
  * Helpers for iteration over list_head-s in seq_files
  */
 
-extern struct list_head *seq_list_start(struct list_head *head,
-               loff_t pos);
-extern struct list_head *seq_list_start_head(struct list_head *head,
-               loff_t pos);
-extern struct list_head *seq_list_next(void *v, struct list_head *head,
-               loff_t *ppos);
+extern cfs_list_t *seq_list_start(cfs_list_t *head, loff_t pos);
+extern cfs_list_t *seq_list_start_head(cfs_list_t *head, loff_t pos);
+extern cfs_list_t *seq_list_next(void *v, cfs_list_t *head, loff_t *ppos);
 
 /*
  *  declaration of proc kernel process routines
@@ -405,9 +402,9 @@ lustre_write_file( cfs_file_t *    fh,
 
 typedef int cfs_task_state_t;
 
-#define CFS_TASK_INTERRUPTIBLE 0x00000001
-#define CFS_TASK_UNINT         0x00000002
-#define CFS_TASK_RUNNING        0x00000003
+#define CFS_TASK_INTERRUPTIBLE  0x00000001
+#define CFS_TASK_UNINT          0x00000002
+#define CFS_TASK_RUNNING         0x00000003
 #define CFS_TASK_UNINTERRUPTIBLE CFS_TASK_UNINT
 
 #define CFS_WAITQ_MAGIC     'CWQM'
@@ -415,11 +412,11 @@ typedef int cfs_task_state_t;
 
 typedef struct cfs_waitq {
 
-    unsigned int        magic;
-    unsigned int        flags;
-    
-    spinlock_t          guard;
-    struct list_head    waiters;
+    unsigned int            magic;
+    unsigned int            flags;
+
+    cfs_spinlock_t          guard;
+    cfs_list_t              waiters;
 
 } cfs_waitq_t;
 
@@ -434,7 +431,7 @@ typedef struct cfs_waitlink cfs_waitlink_t;
 
 
 typedef struct cfs_waitlink_channel {
-    struct list_head        link;
+    cfs_list_t              link;
     cfs_waitq_t *           waitq;
     cfs_waitlink_t *        waitl;
 } cfs_waitlink_channel_t;
@@ -444,7 +441,7 @@ struct cfs_waitlink {
     unsigned int            magic;
     int                     flags;
     event_t  *              event;
-    atomic_t *              hits;
+    cfs_atomic_t *          hits;
 
     cfs_waitlink_channel_t  waitq[CFS_WAITQ_CHANNELS];
 };
@@ -465,7 +462,6 @@ typedef struct _cfs_thread_context {
 } cfs_thread_context_t;
 
 int cfs_kernel_thread(int (*func)(void *), void *arg, int flag);
-#define kernel_thread cfs_kernel_thread
 
 /*
  * thread creation flags from Linux, not used in winnt
@@ -490,44 +486,52 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag);
  */
 #define NGROUPS_SMALL           32
 #define NGROUPS_PER_BLOCK       ((int)(PAGE_SIZE / sizeof(gid_t)))
-struct group_info {
+typedef struct cfs_group_info {
         int ngroups;
-        atomic_t usage;
+        cfs_atomic_t usage;
         gid_t small_block[NGROUPS_SMALL];
         int nblocks;
         gid_t *blocks[0];
-};
+} cfs_group_info_t;
 
-#define get_group_info(group_info) do { \
-        atomic_inc(&(group_info)->usage); \
+#define cfs_get_group_info(group_info) do { \
+        cfs_atomic_inc(&(group_info)->usage); \
 } while (0)
 
-#define put_group_info(group_info) do { \
-        if (atomic_dec_and_test(&(group_info)->usage)) \
-                groups_free(group_info); \
+#define cfs_put_group_info(group_info) do { \
+        if (cfs_atomic_dec_and_test(&(group_info)->usage)) \
+                cfs_groups_free(group_info); \
 } while (0)
 
-static __inline struct group_info *groups_alloc(int gidsetsize)
+static __inline cfs_group_info_t *cfs_groups_alloc(int gidsetsize)
 {
-    struct group_info * groupinfo;
+    cfs_group_info_t * groupinfo;
     KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
-    groupinfo = (struct group_info *)cfs_alloc(sizeof(struct group_info), 0);
+    groupinfo =
+        (cfs_group_info_t *)cfs_alloc(sizeof(cfs_group_info_t), 0);
+
     if (groupinfo) {
-        memset(groupinfo, 0, sizeof(struct group_info));
+        memset(groupinfo, 0, sizeof(cfs_group_info_t));
     }
     return groupinfo;
 }
-static __inline void groups_free(struct group_info *group_info)
+static __inline void cfs_groups_free(cfs_group_info_t *group_info)
 {
-    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
+            __FUNCTION__));
     cfs_free(group_info);
 }
-static __inline int set_current_groups(struct group_info *group_info) {
-    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+static __inline int
+cfs_set_current_groups(cfs_group_info_t *group_info)
+{
+    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
+             __FUNCTION__));
     return 0;
 }
-static __inline int groups_search(struct group_info *group_info, gid_t grp) {
-    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+static __inline int groups_search(cfs_group_info_t *group_info,
+                                  gid_t grp) {
+    KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
+            __FUNCTION__));
     return 0;
 }
 
@@ -564,34 +568,34 @@ typedef __u32 cfs_kernel_cap_t;
  * Task struct
  */
 
-#define CFS_MAX_SCHEDULE_TIMEOUT ((long_ptr_t)(~0UL>>12))
-#define schedule_timeout(t)      cfs_schedule_timeout(0, t)
+#define CFS_MAX_SCHEDULE_TIMEOUT     ((long_ptr_t)(~0UL>>12))
+#define cfs_schedule_timeout(t)      cfs_schedule_timeout_and_set_state(0, t)
 
 struct vfsmount;
 
 #define NGROUPS 1
 #define CFS_CURPROC_COMM_MAX (16)
 typedef struct task_sruct{
-    mode_t           umask;
-    sigset_t         blocked;
-
-    pid_t            pid;
-    pid_t            pgrp;
-
-    uid_t            uid,euid,suid,fsuid;
-    gid_t            gid,egid,sgid,fsgid;
-
-    int              ngroups;
-    int              cgroups;
-    gid_t            groups[NGROUPS];
-    struct group_info *group_info;
-    cfs_kernel_cap_t cap_effective,
-                     cap_inheritable,
-                     cap_permitted;
-
-    char             comm[CFS_CURPROC_COMM_MAX];
-    void            *journal_info;
-    struct vfsmount *fs;
+    mode_t                umask;
+    sigset_t              blocked;
+
+    pid_t                 pid;
+    pid_t                 pgrp;
+
+    uid_t                 uid,euid,suid,fsuid;
+    gid_t                 gid,egid,sgid,fsgid;
+
+    int                   ngroups;
+    int                   cgroups;
+    gid_t                 groups[NGROUPS];
+    cfs_group_info_t     *group_info;
+    cfs_kernel_cap_t      cap_effective,
+                          cap_inheritable,
+                          cap_permitted;
+
+    char                  comm[CFS_CURPROC_COMM_MAX];
+    void                 *journal_info;
+    struct vfsmount      *fs;
 }  cfs_task_t;
 
 static inline void task_lock(cfs_task_t *t)
@@ -611,46 +615,46 @@ static inline void task_unlock(cfs_task_t *t)
 
 typedef struct _TASK_MAN {
 
-    ULONG       Magic;      /* Magic and Flags */
-    ULONG       Flags;
+    ULONG           Magic;      /* Magic and Flags */
+    ULONG           Flags;
 
-    spinlock_t  Lock;       /* Protection lock */
+    cfs_spinlock_t  Lock;       /* Protection lock */
 
-    cfs_mem_cache_t * slab; /* Memory slab for task slot */
+    cfs_mem_cache_t *slab; /* Memory slab for task slot */
 
-    ULONG       NumOfTasks; /* Total tasks (threads) */
-    LIST_ENTRY  TaskList;   /* List of task slots */
+    ULONG           NumOfTasks; /* Total tasks (threads) */
+    LIST_ENTRY      TaskList;   /* List of task slots */
 
 } TASK_MAN, *PTASK_MAN;
 
 typedef struct _TASK_SLOT {
 
-    ULONG       Magic;      /* Magic and Flags */
-    ULONG       Flags;
+    ULONG           Magic;      /* Magic and Flags */
+    ULONG           Flags;
 
-    LIST_ENTRY  Link;       /* To be linked to TaskMan */
+    LIST_ENTRY      Link;       /* To be linked to TaskMan */
 
-    event_t     Event;      /* Schedule event */
+    event_t         Event;      /* Schedule event */
 
-    HANDLE      Pid;        /* Process id */
-    HANDLE      Tid;        /* Thread id */
-    PETHREAD    Tet;        /* Pointer to ethread */
+    HANDLE          Pid;        /* Process id */
+    HANDLE          Tid;        /* Thread id */
+    PETHREAD        Tet;        /* Pointer to ethread */
 
-    atomic_t    count;      /* refer count */
-    atomic_t    hits;       /* times of waken event singaled */
+    cfs_atomic_t    count;      /* refer count */
+    cfs_atomic_t    hits;       /* times of waken event singaled */
 
-    KIRQL       irql;       /* irql for rwlock ... */
+    KIRQL           irql;       /* irql for rwlock ... */
 
-    cfs_task_t  task;       /* linux task part */
+    cfs_task_t      task;       /* linux task part */
 
 } TASK_SLOT, *PTASK_SLOT;
 
 
 #define current                      cfs_current()
-#define set_current_state(s)         do {;} while (0)
-#define cfs_set_current_state(state) set_current_state(state)
+#define cfs_set_current_state(s)     do {;} while (0)
+#define cfs_set_current_state(state) cfs_set_current_state(state)
 
-#define wait_event(wq, condition)                               \
+#define cfs_wait_event(wq, condition)                           \
 do {                                                            \
         cfs_waitlink_t __wait;                                  \
                                                                 \
@@ -723,7 +727,7 @@ void    cleanup_task_manager();
 cfs_task_t * cfs_current();
 int     wake_up_process(cfs_task_t * task);
 void sleep_on(cfs_waitq_t *waitq);
-#define might_sleep() do {} while(0)
+#define cfs_might_sleep() do {} while(0)
 #define CFS_DECL_JOURNAL_DATA  
 #define CFS_PUSH_JOURNAL           do {;} while(0)
 #define CFS_POP_JOURNAL                    do {;} while(0)
@@ -738,14 +742,14 @@ void sleep_on(cfs_waitq_t *waitq);
 #define __init
 #endif
 
-struct module {
+typedef struct cfs_module {
     const char *name;
-};
+} cfs_module_t;
 
-extern struct module libcfs_global_module;
+extern cfs_module_t libcfs_global_module;
 #define THIS_MODULE  &libcfs_global_module
 
-#define request_module(x, y) (0)
+#define cfs_request_module(x, y) (0)
 #define EXPORT_SYMBOL(s)
 #define MODULE_AUTHOR(s)
 #define MODULE_DESCRIPTION(s)
@@ -768,9 +772,9 @@ extern struct module libcfs_global_module;
 
 /* Module interfaces */
 #define cfs_module(name, version, init, fini) \
-module_init(init);                            \
-module_exit(fini)
-#define module_refcount(x) (1)
+        module_init(init);                    \
+        module_exit(fini)
+#define cfs_module_refcount(x) (1)
 
 /*
  * typecheck
@@ -797,7 +801,7 @@ module_exit(fini)
 #define GOLDEN_RATIO_PRIME_32 0x9e370001UL
 
 #if 0 /* defined in libcfs/libcfs_hash.h */
-static inline u32 hash_long(u32 val, unsigned int bits)
+static inline u32 cfs_hash_long(u32 val, unsigned int bits)
 {
        /* On some cpus multiply is faster, on others gcc will do shifts */
        u32 hash = val * GOLDEN_RATIO_PRIME_32;
@@ -844,7 +848,7 @@ libcfs_arch_cleanup(void);
  *  cache alignment size
  */
 
-#define L1_CACHE_ALIGN(x) (x)
+#define CFS_L1_CACHE_ALIGN(x) (x)
 
 #define __cacheline_aligned
 
@@ -854,11 +858,11 @@ libcfs_arch_cleanup(void);
 
 
 #define SMP_CACHE_BYTES             128
-#define NR_CPUS                     (32)
+#define CFS_NR_CPUS                 (32)
 #define smp_num_cpus                ((CCHAR)KeNumberProcessors)
-#define num_possible_cpus()         smp_num_cpus
-#define num_online_cpus()           smp_num_cpus
-#define smp_processor_id()                 ((USHORT)KeGetCurrentProcessorNumber())
+#define cfs_num_possible_cpus()     smp_num_cpus
+#define cfs_num_online_cpus()       smp_num_cpus
+#define cfs_smp_processor_id()     ((USHORT)KeGetCurrentProcessorNumber())
 #define smp_call_function(f, a, n, w)          do {} while(0)
 #define smp_rmb()                   do {} while(0)
 
@@ -866,22 +870,21 @@ libcfs_arch_cleanup(void);
  *  Irp related
  */
 
-#define NR_IRQS                                        512
-#define in_interrupt()                     (0)
-#define cfs_in_interrupt()                  in_interrupt()
+#define CFS_NR_IRQS                 512
+#define cfs_in_interrupt()          (0)
 
 /*
  *  printk flags
  */
 
-#define KERN_EMERG      "<0>"   /* system is unusable                   */
-#define KERN_ALERT      "<1>"   /* action must be taken immediately     */
-#define KERN_CRIT       "<2>"   /* critical conditions                  */
-#define KERN_ERR        "<3>"   /* error conditions                     */
-#define KERN_WARNING    "<4>"   /* warning conditions                   */
-#define KERN_NOTICE     "<5>"   /* normal but significant condition     */
-#define KERN_INFO       "<6>"   /* informational                        */
-#define KERN_DEBUG      "<7>"   /* debug-level messages                 */
+#define CFS_KERN_EMERG      "<0>"   /* system is unusable                   */
+#define CFS_KERN_ALERT      "<1>"   /* action must be taken immediately     */
+#define CFS_KERN_CRIT       "<2>"   /* critical conditions                  */
+#define CFS_KERN_ERR        "<3>"   /* error conditions                     */
+#define CFS_KERN_WARNING    "<4>"   /* warning conditions                   */
+#define CFS_KERN_NOTICE     "<5>"   /* normal but significant condition     */
+#define CFS_KERN_INFO       "<6>"   /* informational                        */
+#define CFS_KERN_DEBUG      "<7>"   /* debug-level messages                 */
 
 /*
  * Misc
@@ -897,8 +900,8 @@ libcfs_arch_cleanup(void);
 #define unlikely(exp) (exp)
 #endif
 
-#define lock_kernel()               do {} while(0)
-#define unlock_kernel()             do {} while(0)
+#define cfs_lock_kernel()               do {} while(0)
+#define cfs_unlock_kernel()             do {} while(0)
 
 #define local_irq_save(x)
 #define local_irq_restore(x)
@@ -1106,16 +1109,16 @@ void globfree(glob_t *__pglog);
  *  module routines
  */
 
-static inline void __module_get(struct module *module)
+static inline void __cfs_module_get(cfs_module_t *module)
 {
 }
 
-static inline int try_module_get(struct module *module)
+static inline int cfs_try_module_get(cfs_module_t *module)
 {
     return 1;
 }
 
-static inline void module_put(struct module *module)
+static inline void cfs_module_put(cfs_module_t *module)
 {
 }
 
@@ -1323,7 +1326,7 @@ static __inline void   __cdecl set_getenv(const char *ENV, const char *value, in
 
 int setenv(const char *envname, const char *envval, int overwrite);
 
-struct utsname {
+typedef struct utsname {
          char sysname[64];
          char nodename[64];
          char release[128];
index 0fe6230..dee9b8a 100644 (file)
@@ -166,14 +166,14 @@ typedef VOID (*ks_schedule_cb)(struct socket*, int);
 
 typedef struct _KS_TSDU {
 
-    ULONG               Magic;          /* magic */
-    ULONG               Flags;          /* flags */
+    ULONG                 Magic;          /* magic */
+    ULONG                 Flags;          /* flags */
 
-    struct list_head    Link;           /* link list */
+    cfs_list_t            Link;           /* link list */
 
-    ULONG               TotalLength;    /* total size of KS_TSDU */
-    ULONG               StartOffset;    /* offset of the first Tsdu unit */
-    ULONG               LastOffset;     /* end offset of the last Tsdu unit */
+    ULONG                 TotalLength;    /* total size of KS_TSDU */
+    ULONG                 StartOffset;    /* offset of the first Tsdu unit */
+    ULONG                 LastOffset;     /* end offset of the last Tsdu unit */
 
 /*
     union {
@@ -234,35 +234,35 @@ typedef struct _KS_TSDU_MDL {
 } KS_TSDU_MDL, *PKS_TSDU_MDL;
 
 typedef struct ks_engine_mgr {
-    spinlock_t              lock;
+    cfs_spinlock_t          lock;
     int                     stop;
     event_t                 exit;
     event_t                 start;
-    struct list_head        list;
+    cfs_list_t              list;
 } ks_engine_mgr_t;
 
 typedef struct ks_engine_slot {
     ks_tconn_t *            tconn;
     void *                  tsdumgr;
-    struct list_head        link;
+    cfs_list_t              link;
     int                     queued;
     ks_engine_mgr_t *       emgr;
 } ks_engine_slot_t;
 
 typedef struct _KS_TSDUMGR {
-    struct list_head        TsduList;
+    cfs_list_t              TsduList;
     ULONG                   NumOfTsdu;
     ULONG                   TotalBytes;
     KEVENT                  Event;
-    spinlock_t              Lock;
+    cfs_spinlock_t          Lock;
     ks_engine_slot_t        Slot;
     ULONG                   Payload;
     int                     Busy:1;
     int                     OOB:1;
 } KS_TSDUMGR, *PKS_TSDUMGR;
 
-#define ks_lock_tsdumgr(mgr)   spin_lock(&((mgr)->Lock))
-#define ks_unlock_tsdumgr(mgr) spin_unlock(&((mgr)->Lock))
+#define ks_lock_tsdumgr(mgr)   cfs_spin_lock(&((mgr)->Lock))
+#define ks_unlock_tsdumgr(mgr) cfs_spin_unlock(&((mgr)->Lock))
 
 typedef struct _KS_CHAIN {
     KS_TSDUMGR          Normal;      /* normal queue */
@@ -353,19 +353,19 @@ typedef KS_DISCONNECT_WORKITEM      ks_disconnect_t;
 
 typedef struct ks_backlogs {
 
-        struct list_head    list;   /* list to link the backlog connections */
-        int                 num;    /* number of backlogs in the list */
+        cfs_list_t           list;   /* list to link the backlog connections */
+        int                  num;    /* number of backlogs in the list */
 
 } ks_backlogs_t;
 
 
 typedef struct ks_daemon {
 
-    ks_tconn_t *            tconn;         /* the listener connection object */
-    unsigned short          nbacklogs;     /* number of listening backlog conns */
-    unsigned short          port;          /* listening port number */ 
-    int                     shutdown;      /* daemon threads is to exit */
-    struct list_head        list;          /* to be attached into ks_nal_data_t */
+    ks_tconn_t *            tconn;       /* the listener connection object */
+    unsigned short          nbacklogs;   /* number of listening backlog conns */
+    unsigned short          port;        /* listening port number */ 
+    int                     shutdown;    /* daemon threads is to exit */
+    cfs_list_t              list;        /* to be attached into ks_nal_data_t */
 
 } ks_daemon_t;
 
@@ -425,7 +425,7 @@ struct socket {
         ulong                       kstc_magic;      /* Magic & Flags */
         ulong                       kstc_flags;
 
-        spinlock_t                  kstc_lock;       /* serialise lock*/
+        cfs_spinlock_t              kstc_lock;       /* serialise lock*/
         void *                      kstc_conn;       /* ks_conn_t */
 
         ks_tconn_type_t             kstc_type;          /* tdi connection Type */
@@ -435,9 +435,9 @@ struct socket {
 
         ks_tdi_addr_t               kstc_addr;       /* local address handlers / Objects */
 
-        atomic_t                    kstc_refcount;   /* reference count of ks_tconn_t */
+        cfs_atomic_t                kstc_refcount;   /* reference count of ks_tconn_t */
 
-        struct list_head            kstc_list;       /* linked to global ksocknal_data */
+        cfs_list_t                  kstc_list;       /* linked to global ksocknal_data */
 
         union {
 
@@ -451,19 +451,19 @@ struct socket {
             } listener; 
 
             struct  {
-                ks_tconn_info_t     kstc_info;      /* Connection Info if Connected */
-                ks_chain_t          kstc_recv;      /* tsdu engine for data receiving */
-                ks_chain_t          kstc_send;      /* tsdu engine for data sending */
+                ks_tconn_info_t       kstc_info;      /* Connection Info if Connected */
+                ks_chain_t            kstc_recv;      /* tsdu engine for data receiving */
+                ks_chain_t            kstc_send;      /* tsdu engine for data sending */
 
-                int                 kstc_queued;    /* Attached to Parent->ChildList ... */
-                int                 kstc_queueno;   /* 0: Attached to Listening list 
+                int                   kstc_queued;    /* Attached to Parent->ChildList ... */
+                int                   kstc_queueno;   /* 0: Attached to Listening list 
                                                        1: Attached to Accepted list */
 
-                int                 kstc_busy;      /* referred by ConnectEventCallback ? */
-                int                 kstc_accepted;  /* the connection is built ready ? */
+                int                   kstc_busy;      /* referred by ConnectEventCallback ? */
+                int                   kstc_accepted;  /* the connection is built ready ? */
 
-                struct list_head    kstc_link;      /* linked to parent tdi connection */
-                ks_tconn_t   *      kstc_parent;    /* pointers to it's listener parent */
+                cfs_list_t            kstc_link;      /* linked to parent tdi connection */
+                ks_tconn_t   *        kstc_parent;    /* pointers to it's listener parent */
             } child;
 
             struct {
@@ -621,39 +621,39 @@ typedef struct {
      * Tdi client information
      */
 
-    UNICODE_STRING    ksnd_client_name; /* tdi client module name */
-    HANDLE            ksnd_pnp_handle;  /* the handle for pnp changes */
+    UNICODE_STRING        ksnd_client_name; /* tdi client module name */
+    HANDLE                ksnd_pnp_handle;  /* the handle for pnp changes */
 
-    spinlock_t        ksnd_addrs_lock;  /* serialize ip address list access */
-    LIST_ENTRY        ksnd_addrs_list;  /* list of the ip addresses */
-    int               ksnd_naddrs;      /* number of the ip addresses */
+    cfs_spinlock_t        ksnd_addrs_lock;  /* serialize ip address list access */
+    LIST_ENTRY            ksnd_addrs_list;  /* list of the ip addresses */
+    int                   ksnd_naddrs;      /* number of the ip addresses */
 
     /*
      *  Tdilnd internal defintions
      */
 
-    int               ksnd_init;            /* initialisation state */
+    int                   ksnd_init;            /* initialisation state */
 
-    TDI_PROVIDER_INFO ksnd_provider;        /* tdi tcp/ip provider's information */
+    TDI_PROVIDER_INFO     ksnd_provider;        /* tdi tcp/ip provider's information */
 
-    spinlock_t        ksnd_tconn_lock;      /* tdi connections access serialise */
+    cfs_spinlock_t        ksnd_tconn_lock;      /* tdi connections access serialise */
 
-    int               ksnd_ntconns;         /* number of tconns attached in list */
-    struct list_head  ksnd_tconns;          /* tdi connections list */
-    cfs_mem_cache_t * ksnd_tconn_slab;      /* slabs for ks_tconn_t allocations */
-    event_t           ksnd_tconn_exit;      /* exit event to be signaled by the last tconn */
+    int                   ksnd_ntconns;         /* number of tconns attached in list */
+    cfs_list_t            ksnd_tconns;          /* tdi connections list */
+    cfs_mem_cache_t *     ksnd_tconn_slab;      /* slabs for ks_tconn_t allocations */
+    event_t               ksnd_tconn_exit;      /* exit event to be signaled by the last tconn */
 
-    spinlock_t        ksnd_tsdu_lock;       /* tsdu access serialise */
+    cfs_spinlock_t        ksnd_tsdu_lock;       /* tsdu access serialise */
         
-    int               ksnd_ntsdus;          /* number of tsdu buffers allocated */
-    ulong             ksnd_tsdu_size;       /* the size of a signel tsdu buffer */
-    cfs_mem_cache_t ksnd_tsdu_slab;       /* slab cache for tsdu buffer allocation */
+    int                   ksnd_ntsdus;          /* number of tsdu buffers allocated */
+    ulong                 ksnd_tsdu_size;       /* the size of a signel tsdu buffer */
+    cfs_mem_cache_t       *ksnd_tsdu_slab;       /* slab cache for tsdu buffer allocation */
 
-    int               ksnd_nfreetsdus;      /* number of tsdu buffers in the freed list */
-    struct list_head  ksnd_freetsdus;       /* List of the freed Tsdu buffer. */
+    int                   ksnd_nfreetsdus;      /* number of tsdu buffers in the freed list */
+    cfs_list_t            ksnd_freetsdus;       /* List of the freed Tsdu buffer. */
 
-    int               ksnd_engine_nums;     /* number of tcp sending engine threads */
-    ks_engine_mgr_t ksnd_engine_mgr;      /* tcp sending engine structure */
+    int                   ksnd_engine_nums;     /* number of tcp sending engine threads */
+    ks_engine_mgr_t       *ksnd_engine_mgr;      /* tcp sending engine structure */
 
 } ks_tdi_data_t;
 
index 0a376b7..8ce1927 100644 (file)
@@ -96,7 +96,7 @@ typedef time_t cfs_duration_t;
 
 #include <libcfs/winnt/portals_compat25.h>
 
-#define HZ (100)
+#define CFS_HZ (100)
 
 struct timespec {
     __u32   tv_sec;
@@ -115,7 +115,7 @@ typedef struct timeval cfs_fs_time_t;
 #define jiffies     (ULONG_PTR)JIFFIES()
 #define cfs_jiffies (ULONG_PTR)JIFFIES()
 
-static inline void do_gettimeofday(struct timeval *tv)
+static inline void cfs_gettimeofday(struct timeval *tv)
 {
     LARGE_INTEGER Time;
 
@@ -125,8 +125,6 @@ static inline void do_gettimeofday(struct timeval *tv)
     tv->tv_usec = (suseconds_t) (Time.QuadPart % 10000000) / 10;
 }
 
-#define cfs_do_gettimeofday(tv) do_gettimeofday(tv)
-
 static inline LONGLONG JIFFIES()
 {
     LARGE_INTEGER Tick;
@@ -135,7 +133,7 @@ static inline LONGLONG JIFFIES()
     KeQueryTickCount(&Tick);
 
     Elapse.QuadPart  = Tick.QuadPart * KeQueryTimeIncrement();
-    Elapse.QuadPart /= (10000000 / HZ);
+    Elapse.QuadPart /= (10000000 / CFS_HZ);
 
     return Elapse.QuadPart;
 }
@@ -147,11 +145,11 @@ static inline cfs_time_t cfs_time_current(void)
 
 static inline time_t cfs_time_current_sec(void)
 {
-    return (time_t)(JIFFIES() / HZ);
+    return (time_t)(JIFFIES() / CFS_HZ);
 }
 
-#define time_before(t1, t2) (((signed)(t1) - (signed)(t2)) < 0) 
-#define time_before_eq(t1, t2) (((signed)(t1) - (signed)(t2)) <= 0) 
+#define cfs_time_before(t1, t2) (((signed)(t1) - (signed)(t2)) < 0)
+#define cfs_time_beforeq(t1, t2) (((signed)(t1) - (signed)(t2)) <= 0)
 
 static inline void cfs_fs_time_current(cfs_fs_time_t *t)
 {
@@ -195,26 +193,26 @@ static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
 
 static inline cfs_duration_t cfs_time_seconds(cfs_duration_t seconds)
 {
-    return  (cfs_duration_t)(seconds * HZ);
+    return  (cfs_duration_t)(seconds * CFS_HZ);
 }
 
 static inline time_t cfs_duration_sec(cfs_duration_t d)
 {
-    return (time_t)(d / HZ);
+    return (time_t)(d / CFS_HZ);
 }
 
 static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
 {
-    s->tv_sec = (__u32)(d / HZ);
-    s->tv_usec = (__u32)((d - (cfs_duration_t)s->tv_sec * HZ) *
-                              ONE_MILLION / HZ);
+    s->tv_sec = (__u32)(d / CFS_HZ);
+    s->tv_usec = (__u32)((d - (cfs_duration_t)s->tv_sec * CFS_HZ) *
+                              ONE_MILLION / CFS_HZ);
 }
 
 static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
 {
-    s->tv_sec = (__u32) (d / HZ);
-    s->tv_nsec = (__u32)((d - (cfs_duration_t)s->tv_sec * HZ) *
-                           ONE_BILLION / HZ);
+    s->tv_sec = (__u32) (d / CFS_HZ);
+    s->tv_nsec = (__u32)((d - (cfs_duration_t)s->tv_sec * CFS_HZ) *
+                           ONE_BILLION / CFS_HZ);
 }
 
 static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
@@ -278,7 +276,7 @@ struct timespec {
 /* liblustre. time(2) based implementation. */
 int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
 void sleep(int time);
-void do_gettimeofday(struct timeval *tv);
+void cfs_gettimeofday(struct timeval *tv);
 int gettimeofday(struct timeval *tv, void * tz);
 
 #endif /* !__KERNEL__ */
index 95660e1..2161330 100644 (file)
@@ -130,13 +130,13 @@ typedef     __u32       suseconds_t;
 typedef     __u16       uid_t, gid_t;
 
 typedef     __u16       mode_t;
-typedef     __u16       umode_t;
+typedef     __u16       cfs_umode_t;
 
 typedef     __u32       sigset_t;
 
 typedef int64_t         loff_t;
 typedef void *          cfs_handle_t;
-typedef uint64_t        cycles_t;
+typedef uint64_t        cfs_cycles_t;
 
 #ifndef INVALID_HANDLE_VALUE
 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
index 0052094..74eb1e3 100644 (file)
@@ -162,7 +162,7 @@ int tcd_owns_tage(struct trace_cpu_data *tcd, struct trace_page *tage)
 
 void
 set_ptldebug_header(struct ptldebug_header *header, int subsys, int mask,
-                   const int line, unsigned long stack)
+                    const int line, unsigned long stack)
 {
        struct timeval tv;
        
index 8f0dbde..e637150 100644 (file)
@@ -110,16 +110,16 @@ CFS_MODULE_PARM(libcfs_panic_on_lbug, "i", uint, 0644,
                 "Lustre kernel panic on LBUG");
 EXPORT_SYMBOL(libcfs_panic_on_lbug);
 
-atomic_t libcfs_kmemory = ATOMIC_INIT(0);
+cfs_atomic_t libcfs_kmemory = CFS_ATOMIC_INIT(0);
 EXPORT_SYMBOL(libcfs_kmemory);
 
 static cfs_waitq_t debug_ctlwq;
 
-char debug_file_path_arr[1024] = DEBUG_FILE_PATH_DEFAULT;
+char libcfs_debug_file_path_arr[1024] = LIBCFS_DEBUG_FILE_PATH_DEFAULT;
 
 /* We need to pass a pointer here, but elsewhere this must be a const */
-char *debug_file_path = &debug_file_path_arr[0];
-CFS_MODULE_PARM(debug_file_path, "s", charp, 0644,
+char *libcfs_debug_file_path = &libcfs_debug_file_path_arr[0];
+CFS_MODULE_PARM(libcfs_debug_file_path, "s", charp, 0644,
                 "Path for dumping debug logs, "
                 "set 'NONE' to prevent log dumping");
 
@@ -333,13 +333,13 @@ void libcfs_debug_dumplog_internal(void *arg)
 
         CFS_PUSH_JOURNAL;
 
-        if (strncmp(debug_file_path_arr, "NONE", 4) != 0) {
+        if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) {
                 snprintf(debug_file_name, sizeof(debug_file_name) - 1,
-                         "%s.%ld." LPLD, debug_file_path_arr,
+                         "%s.%ld." LPLD, libcfs_debug_file_path_arr,
                          cfs_time_current_sec(), (long_ptr_t)arg);
-                printk(KERN_ALERT "LustreError: dumping log to %s\n",
+                printk(CFS_KERN_ALERT "LustreError: dumping log to %s\n",
                        debug_file_name);
-                tracefile_dump_all_pages(debug_file_name);
+                cfs_tracefile_dump_all_pages(debug_file_name);
                 libcfs_run_debug_log_upcall(debug_file_name);
         }
         CFS_POP_JOURNAL;
@@ -362,21 +362,21 @@ void libcfs_debug_dumplog(void)
          * able to set our state to running as it exits before we
          * get to schedule() */
         cfs_waitlink_init(&wait);
-        set_current_state(TASK_INTERRUPTIBLE);
+        cfs_set_current_state(CFS_TASK_INTERRUPTIBLE);
         cfs_waitq_add(&debug_ctlwq, &wait);
 
         dumper = cfs_kthread_run(libcfs_debug_dumplog_thread,
                                  (void*)(long)cfs_curproc_pid(),
                                  "libcfs_debug_dumper");
         if (IS_ERR(dumper))
-                printk(KERN_ERR "LustreError: cannot start log dump thread: "
-                       "%ld\n", PTR_ERR(dumper));
+                printk(CFS_KERN_ERR "LustreError: cannot start log dump thread:"
+                       " %ld\n", PTR_ERR(dumper));
         else
                 cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE);
 
-        /* be sure to teardown if kernel_thread() failed */
+        /* be sure to teardown if cfs_kernel_thread() failed */
         cfs_waitq_del(&debug_ctlwq, &wait);
-        set_current_state(TASK_RUNNING);
+        cfs_set_current_state(CFS_TASK_RUNNING);
 }
 
 int libcfs_debug_init(unsigned long bufsize)
@@ -395,13 +395,13 @@ int libcfs_debug_init(unsigned long bufsize)
 
         /* If libcfs_debug_mb is set to an invalid value or uninitialized
          * then just make the total buffers smp_num_cpus * TCD_MAX_PAGES */
-        if (max > trace_max_debug_mb() || max < num_possible_cpus()) {
+        if (max > cfs_trace_max_debug_mb() || max < cfs_num_possible_cpus()) {
                 max = TCD_MAX_PAGES;
         } else {
-                max = (max / num_possible_cpus());
+                max = (max / cfs_num_possible_cpus());
                 max = (max << (20 - CFS_PAGE_SHIFT));
         }
-        rc = tracefile_init(max);
+        rc = cfs_tracefile_init(max);
 
         if (rc == 0)
                 libcfs_register_panic_notifier();
@@ -412,13 +412,13 @@ int libcfs_debug_init(unsigned long bufsize)
 int libcfs_debug_cleanup(void)
 {
         libcfs_unregister_panic_notifier();
-        tracefile_exit();
+        cfs_tracefile_exit();
         return 0;
 }
 
 int libcfs_debug_clear_buffer(void)
 {
-        trace_flush_pages();
+        cfs_trace_flush_pages();
         return 0;
 }
 
@@ -439,7 +439,7 @@ int libcfs_debug_mark_buffer(const char *text)
 
 void libcfs_debug_set_level(unsigned int debug_level)
 {
-        printk(KERN_WARNING "Lustre: Setting portals debug level to %08x\n",
+        printk(CFS_KERN_WARNING "Lustre: Setting portals debug level to %08x\n",
                debug_level);
         libcfs_debug = debug_level;
 }
index 81e8b6d..6369ada 100644 (file)
@@ -61,28 +61,28 @@ static void
 cfs_hash_rlock(cfs_hash_t *hs)
 {
         if ((hs->hs_flags & CFS_HASH_REHASH) != 0)
-                read_lock(&hs->hs_rwlock);
+                cfs_read_lock(&hs->hs_rwlock);
 }
 
 static void
 cfs_hash_runlock(cfs_hash_t *hs)
 {
         if ((hs->hs_flags & CFS_HASH_REHASH) != 0)
-                read_unlock(&hs->hs_rwlock);
+                cfs_read_unlock(&hs->hs_rwlock);
 }
 
 static void
 cfs_hash_wlock(cfs_hash_t *hs)
 {
         if ((hs->hs_flags & CFS_HASH_REHASH) != 0)
-                write_lock(&hs->hs_rwlock);
+                cfs_write_lock(&hs->hs_rwlock);
 }
 
 static void
 cfs_hash_wunlock(cfs_hash_t *hs)
 {
         if ((hs->hs_flags & CFS_HASH_REHASH) != 0)
-                write_unlock(&hs->hs_rwlock);
+                cfs_write_unlock(&hs->hs_rwlock);
 }
 
 /**
@@ -116,9 +116,9 @@ cfs_hash_create(char *name, unsigned int cur_bits,
 
         strncpy(hs->hs_name, name, sizeof(hs->hs_name));
         hs->hs_name[sizeof(hs->hs_name) - 1] = '\0';
-        atomic_set(&hs->hs_rehash_count, 0);
-        atomic_set(&hs->hs_count, 0);
-        rwlock_init(&hs->hs_rwlock);
+        cfs_atomic_set(&hs->hs_rehash_count, 0);
+        cfs_atomic_set(&hs->hs_count, 0);
+        cfs_rwlock_init(&hs->hs_rwlock);
         hs->hs_cur_bits = cur_bits;
         hs->hs_cur_mask = (1 << cur_bits) - 1;
         hs->hs_min_bits = cur_bits;
@@ -148,8 +148,8 @@ cfs_hash_create(char *name, unsigned int cur_bits,
                 }
 
                 CFS_INIT_HLIST_HEAD(&hs->hs_buckets[i]->hsb_head);
-                rwlock_init(&hs->hs_buckets[i]->hsb_rwlock);
-                atomic_set(&hs->hs_buckets[i]->hsb_count, 0);
+                cfs_rwlock_init(&hs->hs_buckets[i]->hsb_rwlock);
+                cfs_atomic_set(&hs->hs_buckets[i]->hsb_count, 0);
         }
 
         return hs;
@@ -163,8 +163,8 @@ void
 cfs_hash_destroy(cfs_hash_t *hs)
 {
         cfs_hash_bucket_t    *hsb;
-        struct hlist_node    *hnode;
-        struct hlist_node    *pos;
+        cfs_hlist_node_t     *hnode;
+        cfs_hlist_node_t     *pos;
         int                   i;
         ENTRY;
 
@@ -176,20 +176,20 @@ cfs_hash_destroy(cfs_hash_t *hs)
                 if (hsb == NULL)
                         continue;
 
-                write_lock(&hsb->hsb_rwlock);
-                hlist_for_each_safe(hnode, pos, &(hsb->hsb_head)) {
+                cfs_write_lock(&hsb->hsb_rwlock);
+                cfs_hlist_for_each_safe(hnode, pos, &(hsb->hsb_head)) {
                         __cfs_hash_bucket_validate(hs, hsb, hnode);
                         __cfs_hash_bucket_del(hs, hsb, hnode);
                         cfs_hash_exit(hs, hnode);
                 }
 
-                LASSERT(hlist_empty(&(hsb->hsb_head)));
-                LASSERT(atomic_read(&hsb->hsb_count) == 0);
-                write_unlock(&hsb->hsb_rwlock);
+                LASSERT(cfs_hlist_empty(&(hsb->hsb_head)));
+                LASSERT(cfs_atomic_read(&hsb->hsb_count) == 0);
+                cfs_write_unlock(&hsb->hsb_rwlock);
                 CFS_FREE_PTR(hsb);
         }
 
-        LASSERT(atomic_read(&hs->hs_count) == 0);
+        LASSERT(cfs_atomic_read(&hs->hs_count) == 0);
         cfs_hash_wunlock(hs);
 
         LIBCFS_FREE(hs->hs_buckets,
@@ -223,7 +223,7 @@ cfs_hash_rehash_bits(cfs_hash_t *hs)
  * ops->hs_get function will be called when the item is added.
  */
 void
-cfs_hash_add(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
+cfs_hash_add(cfs_hash_t *hs, void *key, cfs_hlist_node_t *hnode)
 {
         cfs_hash_bucket_t    *hsb;
         int                   bits;
@@ -236,11 +236,11 @@ cfs_hash_add(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
         i = cfs_hash_id(hs, key, hs->hs_cur_mask);
         hsb = hs->hs_buckets[i];
         LASSERT(i <= hs->hs_cur_mask);
-        LASSERT(hlist_unhashed(hnode));
+        LASSERT(cfs_hlist_unhashed(hnode));
 
-        write_lock(&hsb->hsb_rwlock);
+        cfs_write_lock(&hsb->hsb_rwlock);
         __cfs_hash_bucket_add(hs, hsb, hnode);
-        write_unlock(&hsb->hsb_rwlock);
+        cfs_write_unlock(&hsb->hsb_rwlock);
 
         bits = cfs_hash_rehash_bits(hs);
         cfs_hash_runlock(hs);
@@ -251,12 +251,12 @@ cfs_hash_add(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
 }
 CFS_EXPORT_SYMBOL(cfs_hash_add);
 
-static struct hlist_node *
+static cfs_hlist_node_t *
 cfs_hash_findadd_unique_hnode(cfs_hash_t *hs, void *key,
-                              struct hlist_node *hnode)
+                              cfs_hlist_node_t *hnode)
 {
         int                   bits = 0;
-        struct hlist_node    *ehnode;
+        cfs_hlist_node_t     *ehnode;
         cfs_hash_bucket_t    *hsb;
         unsigned              i;
         ENTRY;
@@ -267,9 +267,9 @@ cfs_hash_findadd_unique_hnode(cfs_hash_t *hs, void *key,
         i = cfs_hash_id(hs, key, hs->hs_cur_mask);
         hsb = hs->hs_buckets[i];
         LASSERT(i <= hs->hs_cur_mask);
-        LASSERT(hlist_unhashed(hnode));
+        LASSERT(cfs_hlist_unhashed(hnode));
 
-        write_lock(&hsb->hsb_rwlock);
+        cfs_write_lock(&hsb->hsb_rwlock);
         ehnode = __cfs_hash_bucket_lookup(hs, hsb, key);
         if (ehnode) {
                 cfs_hash_get(hs, ehnode);
@@ -278,7 +278,7 @@ cfs_hash_findadd_unique_hnode(cfs_hash_t *hs, void *key,
                 ehnode = hnode;
                 bits = cfs_hash_rehash_bits(hs);
         }
-        write_unlock(&hsb->hsb_rwlock);
+        cfs_write_unlock(&hsb->hsb_rwlock);
         cfs_hash_runlock(hs);
         if (bits)
                 cfs_hash_rehash(hs, bits);
@@ -292,9 +292,9 @@ cfs_hash_findadd_unique_hnode(cfs_hash_t *hs, void *key,
  * Returns 0 on success or -EALREADY on key collisions.
  */
 int
-cfs_hash_add_unique(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
+cfs_hash_add_unique(cfs_hash_t *hs, void *key, cfs_hlist_node_t *hnode)
 {
-        struct hlist_node    *ehnode;
+        cfs_hlist_node_t    *ehnode;
         ENTRY;
 
         ehnode = cfs_hash_findadd_unique_hnode(hs, key, hnode);
@@ -314,9 +314,9 @@ CFS_EXPORT_SYMBOL(cfs_hash_add_unique);
  */
 void *
 cfs_hash_findadd_unique(cfs_hash_t *hs, void *key,
-                        struct hlist_node *hnode)
+                        cfs_hlist_node_t *hnode)
 {
-        struct hlist_node    *ehnode;
+        cfs_hlist_node_t     *ehnode;
         void                 *obj;
         ENTRY;
 
@@ -335,7 +335,7 @@ CFS_EXPORT_SYMBOL(cfs_hash_findadd_unique);
  * on the removed object.
  */
 void *
-cfs_hash_del(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
+cfs_hash_del(cfs_hash_t *hs, void *key, cfs_hlist_node_t *hnode)
 {
         cfs_hash_bucket_t    *hsb;
         void                 *obj;
@@ -348,11 +348,11 @@ cfs_hash_del(cfs_hash_t *hs, void *key, struct hlist_node *hnode)
         i = cfs_hash_id(hs, key, hs->hs_cur_mask);
         hsb = hs->hs_buckets[i];
         LASSERT(i <= hs->hs_cur_mask);
-        LASSERT(!hlist_unhashed(hnode));
+        LASSERT(!cfs_hlist_unhashed(hnode));
 
-        write_lock(&hsb->hsb_rwlock);
+        cfs_write_lock(&hsb->hsb_rwlock);
         obj = __cfs_hash_bucket_del(hs, hsb, hnode);
-        write_unlock(&hsb->hsb_rwlock);
+        cfs_write_unlock(&hsb->hsb_rwlock);
         cfs_hash_runlock(hs);
 
         RETURN(obj);
@@ -369,7 +369,7 @@ void *
 cfs_hash_del_key(cfs_hash_t *hs, void *key)
 {
         void                 *obj = NULL;
-        struct hlist_node    *hnode;
+        cfs_hlist_node_t     *hnode;
         cfs_hash_bucket_t    *hsb;
         unsigned              i;
         ENTRY;
@@ -379,12 +379,12 @@ cfs_hash_del_key(cfs_hash_t *hs, void *key)
         hsb = hs->hs_buckets[i];
         LASSERT(i <= hs->hs_cur_mask);
 
-        write_lock(&hsb->hsb_rwlock);
+        cfs_write_lock(&hsb->hsb_rwlock);
         hnode = __cfs_hash_bucket_lookup(hs, hsb, key);
         if (hnode)
                 obj = __cfs_hash_bucket_del(hs, hsb, hnode);
 
-