From: John L. Hammond Date: Tue, 12 Aug 2014 14:11:29 +0000 (-0500) Subject: LU-2675 build: remove Darwin "support" X-Git-Tag: 2.6.51~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=01def2b635ff0b7bacde158d9124334c42cd5d2b LU-2675 build: remove Darwin "support" Remove the Darwin "support" code. It's not maintained or used. Signed-off-by: John L. Hammond Change-Id: I56ee7788d55465495815c4f8655e986dd5a51d00 Reviewed-on: http://review.whamcloud.com/11423 Reviewed-by: frank zago Reviewed-by: Dmitry Eremin Tested-by: Jenkins Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/build/doxyfile.api b/build/doxyfile.api index 9df11fc..86f6b47 100644 --- a/build/doxyfile.api +++ b/build/doxyfile.api @@ -112,7 +112,7 @@ EXCLUDE = lnet/klnds/ciblnd/ \ lnet/klnds/ralnd/ \ lnet/klnds/viblnd/ EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = */darwin/* +EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXPORT_SYMBOL* EXAMPLE_PATH = EXAMPLE_PATTERNS = * diff --git a/build/doxyfile.ref b/build/doxyfile.ref index 4b0602a..70135dd 100644 --- a/build/doxyfile.ref +++ b/build/doxyfile.ref @@ -112,7 +112,7 @@ EXCLUDE = lnet/klnds/ciblnd/ \ lnet/klnds/ralnd/ \ lnet/klnds/viblnd/ EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = */darwin/* +EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXPORT_SYMBOL* EXAMPLE_PATH = EXAMPLE_PATTERNS = * diff --git a/build/osxpack/License.txt b/build/osxpack/License.txt deleted file mode 100644 index 3b8ff2b..0000000 --- a/build/osxpack/License.txt +++ /dev/null @@ -1,8 +0,0 @@ -Lustre(R) for OS X - -This software is a proprietary product of Sun Microsystems, Inc. which owns all intellectual property rights to this software. - -You must obtain a license from Sun Microsystems, Inc. and agree to its terms before using this software. Contact http://www.lustre.org/ - -This software is beta software modifying and running kernel code. Back up all systems before use. This software is provided to you without any warranty, without even the implied warranty of merchantability, or fitness for a particular purpose. Consult your license agreement for more details. - diff --git a/build/osxpack/ReadMe.txt b/build/osxpack/ReadMe.txt deleted file mode 100644 index 06555ba..0000000 --- a/build/osxpack/ReadMe.txt +++ /dev/null @@ -1,4 +0,0 @@ -This is release 0.9.2 Beta of the Lustre OS X client. - -This is not a production quality release, so use it with care, and on non-production systems. The installation will overwrite the OS X kernel on your system. Un-installing this package will restore your current kernel. - diff --git a/build/osxpack/Welcome.txt b/build/osxpack/Welcome.txt deleted file mode 100644 index f6fa0ce..0000000 --- a/build/osxpack/Welcome.txt +++ /dev/null @@ -1,4 +0,0 @@ -Welcome to the Lustre OS X client installation - -You will be guided through the steps necessary to install this software. During installation you will be required to reboot your Mac, so make sure you have saved all your data and closed applications before continuing the installation. - diff --git a/build/osxpack/packlustre.sh b/build/osxpack/packlustre.sh deleted file mode 100755 index 7392c0e..0000000 --- a/build/osxpack/packlustre.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# -# This script is used to create package directory tree used -# by PackageMaker in OS X. - -PREFIX=$1 -STAGE=$2 - -RESOURCE=$PWD/build/osxpack -if ! [ -d $RESOURCE ]; then - echo "Your tree seems to be missing $RESOURCE." >&2 -fi - -if [ "x$PREFIX" == "x" ]; then - PREFIX=/home/cfs/package -fi - -if [ "x$STAGE" == "x" ]; then - STAGE=/System/Library/Extensions -fi - -if ! [ -d $STAGE/llite.kext ]; then - echo "Sorry, cannot find stage files for package" - exit 1 -fi - -if ! [ -d $PREFIX ]; then - mkdir -p $PREFIX -fi - -if ! [ -d $PREFIX/Install_resources ]; then - mkdir -p $PREFIX/Install_resources -fi - -if ! [ -d $PREFIX/Package_contents ]; then - mkdir -p $PREFIX/Package_contents -fi - -CONTENTS=$PREFIX/Package_contents - -if ! [ -d $CONTENTS/System/Libraray/Extensions ]; then - mkdir -p $CONTENTS/System/Library/Extensions -fi -# IMPORTANT -# /etc is symlink of /private/etc in OS X, if we -# just use $CONTENTS/etc, it will OVERWRITE /etc in -# installation target, that means all files in /etc -# will be lost, the system will be corrupted. -if ! [ -d $CONTENTS/private/etc ]; then - mkdir -p $CONTENTS/private/etc -fi - -if ! [ -d $CONTENTS/sbin ]; then - mkdir -p $CONTENTS/sbin -fi - -cp -f $RESOURCE/*.txt $PREFIX/Install_resources/ -cp -f $RESOURCE/*flight $PREFIX/Install_resources/ -cp -f $RESOURCE/sysctl.conf $CONTENTS/private/etc -cp -f $RESOURCE/uninstall_lustre $CONTENTS/sbin -cp -f $RESOURCE/unload_lustre $CONTENTS/sbin -cp -rf $STAGE/llite.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/mdc.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/lov.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/osc.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/ptlrpc.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/ptlrpcs.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/obdclass.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/lvfs.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/ksocknal.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/portals.kext $CONTENTS/System/Library/Extensions -cp -rf $STAGE/libcfs.kext $CONTENTS/System/Library/Extensions diff --git a/build/osxpack/postflight b/build/osxpack/postflight deleted file mode 100755 index a4e6633..0000000 --- a/build/osxpack/postflight +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -/usr/sbin/nvram boot-args="debug=0xe zsize=256" - -# Delete cache files -if [ -f /System/Library/Extensions.kextcache ]; then - rm -f /System/Library/Extensions.kextcache -fi - -if [ -d /System/Library/Caches/com.apple.kernelcaches ]; then - rm -rf /System/Library/Caches/com.apple.kernelcaches -fi - -touch /System/Library diff --git a/build/osxpack/preflight b/build/osxpack/preflight deleted file mode 100755 index 582aea3..0000000 --- a/build/osxpack/preflight +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -date=`date +%Y%m%d_%H%M` - -backpath=/System/LustreBackup -if ! [ -d $backpath ]; then - mkdir -p $backpath -fi - -backdir=${backpath}/SystemBackup - -# If system has been backed up, just exit -if [ -d ${backdir} ]; then - exit 0 -fi - -mkdir $backdir -chmod 700 $backdir - -# create backup directory -mkdir -p $backdir/System/Library/Frameworks -mkdir -p $backdir/System/Library/Extensions -mkdir -p $backdir/usr/lib -mkdir -p $backdir/usr/include -mkdir -p $backdir/private/etc - -# backup the old system -cp /mach_kernel $backdir/ -cp -rf /System/Library/Frameworks/IOKit.framework $backdir/System/Library/Frameworks/ -cp -rf /System/Library/Frameworks/Kernel.framework $backdir/System/Library/Frameworks/ -cp -rf /System/Library/Frameworks/System.framework $backdir/System/Library/Frameworks/ -cp -rf /System/Library/Extensions/System.kext $backdir/System/Library/Extensions/ -cp -rf /usr/include/bsm $backdir/usr/include/bsm -cp -rf /usr/include/default_pager $backdir/usr/include/default_pager -cp -rf /usr/include/dev $backdir/usr/include/dev -cp -rf /usr/include/device $backdir/usr/include/device -cp -rf /usr/include/drivers $backdir/usr/include/drivers -cp -rf /usr/include/hfs $backdir/usr/include/hfs -cp -rf /usr/include/isofs $backdir/usr/include/isofs -cp -rf /usr/include/libkern $backdir/usr/include/libkern -cp -rf /usr/include/mach $backdir/usr/include/mach -cp -rf /usr/include/mach_debug $backdir/usr/include/mach_debug -cp -rf /usr/include/machine $backdir/usr/include/machine -cp -rf /usr/include/miscfs $backdir/usr/include/miscfs -cp -rf /usr/include/net $backdir/usr/include/net -cp -rf /usr/include/netat $backdir/usr/include/netat -cp -rf /usr/include/netinet $backdir/usr/include/netinet -cp -rf /usr/include/netinet6 $backdir/usr/include/netinet6 -cp -rf /usr/include/netkey $backdir/usr/include/netkey -cp -rf /usr/include/nfs $backdir/usr/include/nfs -cp -rf /usr/include/pexpert $backdir/usr/include/pexpert -cp -rf /usr/include/ppc $backdir/usr/include/ppc -cp -rf /usr/include/profile $backdir/usr/include/profile -cp -rf /usr/include/sys $backdir/usr/include/sys -cp -rf /usr/include/ufs $backdir/usr/include/ufs -cp -rf /usr/include/vfs $backdir/usr/include/vfs -cp -f /usr/lib/libIOKit.A.dylib $backdir/usr/lib/libIOKit.A.dylib -cp -f /usr/lib/libIOKit.dylib $backdir/usr/lib/libIOKit.dylib -cp -f /usr/lib/libkmod.a $backdir/usr/lib/libkmod.a -cp -f /usr/lib/libkmodc++.a $backdir/usr/lib/libkmodc++.a -if [ -f /private/etc/sysctl.conf ]; then - cp -f /private/etc/sysctl.conf $backdir/private/etc/sysctl.conf -fi - -# record sysctem backup path of current installation -# echo $backdir >> $backpath/lustre-current -# echo $date > $backdir/install_date diff --git a/build/osxpack/sysctl.conf b/build/osxpack/sysctl.conf deleted file mode 100644 index f8d2cc2..0000000 --- a/build/osxpack/sysctl.conf +++ /dev/null @@ -1,15 +0,0 @@ -# nmbclusters can not be modified by sysctl(it's read only) -# so we have to change it in kernel patch -## kern.ipc.nmbclusters=32768 - -# Keep a long enough reassembly queue. -net.inet.tcp.reass.maxsegments=4096 - -# max permited sockbuf -kern.ipc.maxsockbuf=8388608 - -# XXX -net.inet.tcp.sendspace=3217968 -net.inet.tcp.recvspace=3217968 - -kern.maxvnodes=65536 diff --git a/build/osxpack/uninstall_lustre b/build/osxpack/uninstall_lustre deleted file mode 100755 index d2624d2..0000000 --- a/build/osxpack/uninstall_lustre +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -# -# It's the uninstall programe of lustre - -mount | grep lustre > /dev/null -if [ $? -eq 0 ]; then - echo "Please unmount Lustre before uninstall Lustre." - exit 1 -fi - -echo "unloading modules......" -/sbin/unload_lustre 2 > /dev/null - -backdir=/System/LustreBackup/SystemBackup -if ! [ -d $backdir ]; then - echo "No backup directory is found, you have not installed lustre or uninstall failed!" - exit 1 -fi - -# if ! [ -f $backpath/lustre-current ]; then -# echo "No version information of Lustre installation, you have uninstalled or uninstall failed!" -# exit 2 -# fi -# -# get information of the the backup system -# -# backdir=`tail -1 $backpath/lustre-current` -# if ! [ -d $backdir ]; then -# echo "Miss backup directory, uninstall failed!" -# exit 3 -# fi - -# recover the old system -echo "recover orignal kernel......" -cp -f $backdir/mach_kernel /mach_kernel -echo "recover orignal frameworks......" -cp -rf $backdir/System/Library/Frameworks/IOKit.framework /System/Library/Frameworks/ -cp -rf $backdir/System/Library/Frameworks/Kernel.framework /System/Library/Frameworks/ -cp -rf $backdir/System/Library/Frameworks/System.framework /System/Library/Frameworks/ -echo "recover orignal kernel extensions......" -cp -rf $backdir/System/Library/Extensions/System.kext /System/Library/Extensions/ -echo "recover orignal system headers......" -cp -rf $backdir/usr/include/bsm /usr/include/bsm -cp -rf $backdir/usr/include/default_pager /usr/include/default_pager -cp -rf $backdir/usr/include/dev /usr/include/dev -cp -rf $backdir/usr/include/device /usr/include/device -cp -rf $backdir/usr/include/drivers /usr/include/drivers -cp -rf $backdir/usr/include/hfs /usr/include/hfs -cp -rf $backdir/usr/include/isofs /usr/include/isofs -cp -rf $backdir/usr/include/libkern /usr/include/libkern -cp -rf $backdir/usr/include/mach /usr/include/mach -cp -rf $backdir/usr/include/mach_debug /usr/include/mach_debug -cp -rf $backdir/usr/include/machine /usr/include/machine -cp -rf $backdir/usr/include/miscfs /usr/include/miscfs -cp -rf $backdir/usr/include/net /usr/include/net -cp -rf $backdir/usr/include/netat /usr/include/netat -cp -rf $backdir/usr/include/netinet /usr/include/netinet -cp -rf $backdir/usr/include/netinet6 /usr/include/netinet6 -cp -rf $backdir/usr/include/netkey /usr/include/netkey -cp -rf $backdir/usr/include/nfs /usr/include/nfs -cp -rf $backdir/usr/include/pexpert /usr/include/pexpert -cp -rf $backdir/usr/include/ppc /usr/include/ppc -cp -rf $backdir/usr/include/profile /usr/include/profile -cp -rf $backdir/usr/include/sys /usr/include/sys -cp -rf $backdir/usr/include/ufs /usr/include/ufs -cp -rf $backdir/usr/include/vfs /usr/include/vfs -echo "recover orignal system libraries......" -cp -f $backdir/usr/lib/libIOKit.A.dylib /usr/lib/libIOKit.A.dylib -cp -f $backdir/usr/lib/libIOKit.dylib /usr/lib/libIOKit.dylib -cp -f $backdir/usr/lib/libkmod.a /usr/lib/libkmod.a -cp -f $backdir/usr/lib/libkmodc++.a /usr/lib/libkmodc++.a -if [ -f $backdir/private/etc/sysctl.conf ]; then - cp -f $backdir/private/etc/sysctl.conf /private/etc/sysctl.conf -else - rm -f /private/etc/sysctl.conf -fi - -# -# cp $backpath/lustre-current /tmp/lustre-v -# count=`grep "SystemBackup" /tmp/lustre-v|wc -l` -# count=`expr $count - 1` -# if [ $count -gt 0 ]; then -# head -$count /tmp/lustre-v > $backpath/lustre-current -# else -# # The file should be empty now, it's the last uninstall -# rm -f $backpath/lustre-current -# fi -# rm -f /tmp/lustre-v - -# remove unused files -echo "uninstall lustre modules and utilities......" -rm -rf $backdir -rm -f /sbin/lctl -rm -f /sbin/mount_lustre -rm -f /sbin/unload_lustre -rm -rf /System/Library/Extensions/libcfs.kext -rm -rf /System/Library/Extensions/portals.kext -rm -rf /System/Library/Extensions/ksocknal.kext -rm -rf /System/Library/Extensions/lvfs.kext -rm -rf /System/Library/Extensions/obdclass.kext -rm -rf /System/Library/Extensions/ptlrpc.kext -rm -rf /System/Library/Extensions/ptlrpcs.kext -rm -rf /System/Library/Extensions/osc.kext -rm -rf /System/Library/Extensions/lov.kext -rm -rf /System/Library/Extensions/obdecho.kext -rm -rf /System/Library/Extensions/mdc.kext -rm -rf /System/Library/Extensions/llite.kext - -# disable kernel cache by touch /System/Library -touch /System/Library -echo "Uninstall Lustre successfully, please reboot your computer!" diff --git a/build/osxpack/unload_lustre b/build/osxpack/unload_lustre deleted file mode 100755 index 54404c1..0000000 --- a/build/osxpack/unload_lustre +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -mount | grep lustre > /dev/null -if [ $? -eq 0 ]; then - echo "Please unmount lustre before unload modules." - exit 1 -fi -kextunload /System/Library/Extensions/llite.kext -kextunload /System/Library/Extensions/mdc.kext -kextunload /System/Library/Extensions/lov.kext -kextunload /System/Library/Extensions/osc.kext -kextunload /System/Library/Extensions/ptlrpc.kext -kextunload /System/Library/Extensions/ptlrpcs.kext -kextunload /System/Library/Extensions/obdclass.kext -kextunload /System/Library/Extensions/lvfs.kext -kextunload /System/Library/Extensions/ksocknal.kext -kextunload /System/Library/Extensions/portals.kext -kextunload /System/Library/Extensions/libcfs.kext diff --git a/config/Makefile.am b/config/Makefile.am index 8822fe2..63804c6 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,2 +1,2 @@ -EXTRA_DIST = lustre-build.m4 lustre-build-linux.m4 lustre-build-darwin.m4 +EXTRA_DIST = lustre-build.m4 lustre-build-linux.m4 EXTRA_DIST += lustre-build-ldiskfs.m4 lustre-build-zfs.m4 diff --git a/config/lustre-build-darwin.m4 b/config/lustre-build-darwin.m4 deleted file mode 100644 index eeb9393..0000000 --- a/config/lustre-build-darwin.m4 +++ /dev/null @@ -1,106 +0,0 @@ -# -# LB_DARWIN_CHECK_FUNCS -# -# check for functions in the darwin kernel -# Note that this is broken for cross compiling -# -AC_DEFUN([LB_DARWIN_CHECK_FUNCS], -[AC_FOREACH([AC_Func], [$1], - [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func), - [Define to 1 if you have the `]AC_Func[' function.])])dnl -for ac_func in $1 -do -AC_MSG_CHECKING([for $1]) -AS_IF([AC_TRY_COMMAND(nm /mach | grep "[$1]" >/dev/null 2>/dev/null)],[ - AC_MSG_RESULT([yes]) - AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2 -],[ - AC_MSG_RESULT([no]) $3 -]) -done -]) - -# -# LB_DARWIN_CONDITIONALS -# -# AM_CONDITIONALs for darwin -# -AC_DEFUN([LB_DARWIN_CONDITIONALS], -[ -]) - -# -# LB_PROG_DARWIN -# -# darwin tests -# -AC_DEFUN([LB_PROG_DARWIN], -[kernel_framework="/System/Library/Frameworks/Kernel.framework" -# -# FIXME: there should be a better way to get these than hard coding them -# -case $target_cpu in - powerpc*) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch ppc -mtune=G4 -mlong-branch" - EXTRA_KLDFLAGS="-arch ppc" - ;; - i?86 | x86_64) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch i386" - EXTRA_KLDFLAGS="-arch i386" - ;; -esac - -# Kernel of OS X is not 64bits(even in Tiger), but -m64 can be taken by gcc in Tiger -# (Tiger can support 64bits applications), so we have to eliminate -m64 while -# building kextensions for and OS X. -CC=`echo $CC | sed -e "s/\-m64//g"` -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -x c -pipe -Wno-trigraphs -fasm-blocks -g -O0" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-four-char-constants -Wmost -O0" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fmessage-length=0" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers/bsd" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/PrivateHeaders" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fno-common -nostdinc -fno-builtin" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -finline -fno-keep-inline-functions" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -force_cpusubtype_ALL -fno-exceptions" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -msoft-float -static" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DKERNEL -DKERNEL_PRIVATE" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DDRIVER_PRIVATE -DAPPLE -DNeXT" -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__KERNEL__ -D__DARWIN__" -# -# C flags for Panther/Tiger -# -case $target_os in - darwin8*) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__DARWIN8__" - ;; - darwin7*) - EXTRA_KCFLAGS="$EXTRA_KCFLAGS -ffix-and-continue" - ;; -esac - -# -# Debugging flags. Remove! -# -EXTRA_KCFLAGS="$EXTRA_KCFLAGS -O0 -DMACH_ASSERT=1" -EXTRA_KLDFLAGS="$EXTRA_KLDFLAGS -static -nostdlib -r" -EXTRA_KLIBS="-lkmodc++ -lkmod -lcc_kext" -KMODEXT="" - -AC_SUBST(EXTRA_KLDFLAGS) -AC_SUBST(EXTRA_KLIBS) - -kextdir='/System/Library/Extensions/$(firstword $(macos_PROGRAMS)).kext' -plistdir='$(kextdir)/Contents' -macosdir='$(plistdir)/MacOS' - -AC_SUBST(kextdir) -AC_SUBST(plistdir) -AC_SUBST(macosdir) - -LN_PROG_DARWIN - -LP_PROG_DARWIN - -LC_PROG_DARWIN -]) diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index aa75c04..32b3861 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -18,12 +18,6 @@ case $target_os in linux*) lb_target_os="linux" ;; - darwin*) - lb_target_os="darwin" - ;; - solaris*) - lb_target_os="SunOS" - ;; esac AC_SUBST(lb_target_os) ]) # LB_CANONICAL_SYSTEM @@ -239,9 +233,6 @@ AS_IF([test "x$enable_modules" = xyes], [ LN_PROG_LINUX AS_IF([test "x$enable_server" != xno], [LB_EXT4_SRC_DIR]) LC_PROG_LINUX - ], [darwin*], [ - LB_PROG_DARWIN - LIBCFS_PROG_DARWIN ], [*], [ # This is strange - Lustre supports a target we don't AC_MSG_ERROR([Modules are not supported on $target_os]) @@ -433,8 +424,6 @@ AM_CONDITIONAL([TESTS], [test x$enable_tests = xyes]) AM_CONDITIONAL([DOC], [test x$ENABLE_DOC = x1]) AM_CONDITIONAL([INIT_SCRIPTS], [test x$ENABLE_INIT_SCRIPTS = x1]) AM_CONDITIONAL([LINUX], [test x$lb_target_os = xlinux]) -AM_CONDITIONAL([DARWIN], [test x$lb_target_os = xdarwin]) -AM_CONDITIONAL([SUNOS], [test x$lb_target_os = xSunOS]) AM_CONDITIONAL([USES_DPKG], [test x$uses_dpkg = xyes]) AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes]) @@ -447,8 +436,6 @@ AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"], [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])]) -LB_DARWIN_CONDITIONALS - LIBCFS_CONDITIONALS LN_CONDITIONALS LC_CONDITIONALS diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 1889814..90bb1c1 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -340,15 +340,6 @@ LIBCFS_SHRINKER_COUNT ]) # LIBCFS_PROG_LINUX # -# LIBCFS_PROG_DARWIN -# -# Darwin checks -# -AC_DEFUN([LIBCFS_PROG_DARWIN], [ -LB_DARWIN_CHECK_FUNCS([get_preemption_level]) -]) # LIBCFS_PROG_DARWIN - -# # LIBCFS_PATH_DEFAULTS # # default paths for installed files @@ -460,7 +451,5 @@ libcfs/libcfs/autoMakefile libcfs/libcfs/linux/Makefile libcfs/libcfs/posix/Makefile libcfs/libcfs/util/Makefile -libcfs/include/libcfs/darwin/Makefile -libcfs/libcfs/darwin/Makefile ]) ]) # LIBCFS_CONFIG_FILES diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index edae41a..2244baa 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -1,8 +1,5 @@ SUBDIRS = linux posix util -if DARWIN -SUBDIRS += darwin -endif -DIST_SUBDIRS = linux posix util darwin +DIST_SUBDIRS = linux posix util libcfsdir = $(includedir)/libcfs diff --git a/libcfs/include/libcfs/darwin/.gitignore b/libcfs/include/libcfs/darwin/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/libcfs/include/libcfs/darwin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/libcfs/include/libcfs/darwin/Makefile.am b/libcfs/include/libcfs/darwin/Makefile.am deleted file mode 100644 index 3ccd204..0000000 --- a/libcfs/include/libcfs/darwin/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -EXTRA_DIST = darwin-mem.h darwin-types.h libcfs.h \ - darwin-fs.h darwin-prim.h darwin-utils.h \ - darwin-lock.h darwin-sync.h darwin-tcpip.h kp30.h diff --git a/libcfs/include/libcfs/darwin/darwin-fs.h b/libcfs/include/libcfs/darwin/darwin-fs.h deleted file mode 100644 index e88ceae..0000000 --- a/libcfs/include/libcfs/darwin/darwin-fs.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/darwin/darwin-fs.h - * - * Implementation of standard file system interfaces for XNU kernel. - */ - -#ifndef __LIBCFS_DARWIN_FS_H__ -#define __LIBCFS_DARWIN_FS_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* - * File operating APIs in kernel - */ -#ifdef __DARWIN8__ -/* - * Kernel file descriptor - */ -struct file { - unsigned f_flags; - vnode_t f_vp; - vfs_context_t f_ctxt; -}; -#endif - -int kern_file_size(struct file *fp, off_t *size); -#define filp_size(fp) \ - ({ \ - off_t __size; \ - kern_file_size((fp), &__size); \ - __size; \ - }) -#define filp_poff(fp) (NULL) - -struct file *kern_file_open(const char *name, int flags, int mode); -int kern_file_close(struct file *fp); -int kern_file_read(struct file *fp, void *buf, size_t nbytes, off_t *pos); -int kern_file_write(struct file *fp, void *buf, size_t nbytes, off_t *pos); -int kern_file_sync(struct file *fp); - -#define filp_open(n, f, m) kern_file_open(n, f, m) -#define filp_close(f, i) kern_file_close(f) -#define filp_read(f, b, n, p) kern_file_read(f, b, n, p) -#define filp_write(f, b, n, p) kern_file_write(f, b, n, p) -#define filp_fsync(f, s, e) kern_file_sync(f) - -int ref_file(struct file *fp); -int rele_file(struct file *fp); -int file_count(struct file *fp); -#define get_file(f) ref_file(f) -#define fput(f) rele_file(f) - -#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) -#define OFFSET_MAX INT_LIMIT(loff_t) - -#define file_lock flock -#define flock_type(fl) ((fl)->l_type) -#define flock_set_type(fl, type) do { (fl)->l_type = (type); } while (0) -#define flock_pid(fl) ((fl)->l_pid) -#define flock_set_pid(fl, pid) do { (fl)->l_pid = (pid); } while (0) -#define flock_start(fl) ((fl)->l_start) -#define flock_set_start(fl, st) do { (fl)->l_start = (st); } while (0) - -static inline loff_t flock_end(struct file_lock *fl) -{ - return (fl->l_len == 0 ? OFFSET_MAX : (fl->l_start + fl->l_len)); -} - -static inline void flock_set_end(struct file_lock *fl, loff_t end) -{ - if (end == OFFSET_MAX) - fl->l_len = 0; - else - fl->l_len = end - fl->l_start; -} - -#define ATTR_MODE 0x0001 -#define ATTR_UID 0x0002 -#define ATTR_GID 0x0004 -#define ATTR_SIZE 0x0008 -#define ATTR_ATIME 0x0010 -#define ATTR_MTIME 0x0020 -#define ATTR_CTIME 0x0040 -#define ATTR_ATIME_SET 0x0080 -#define ATTR_MTIME_SET 0x0100 -#define ATTR_FORCE 0x0200 /* Not a change, but a change it */ -#define ATTR_ATTR_FLAG 0x0400 -#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */ -#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */ -#define ATTR_CTIME_SET 0x2000 -#define ATTR_BLOCKS 0x4000 -#define ATTR_KILL_SUID 0 -#define ATTR_KILL_SGID 0 - -#define in_group_p(x) (0) - -struct posix_acl_entry { - short e_tag; - unsigned short e_perm; - unsigned int e_id; -}; - -struct posix_acl { - atomic_t a_refcount; - unsigned int a_count; - struct posix_acl_entry a_entries[0]; -}; - -struct posix_acl *posix_acl_alloc(int count, int flags); -static inline struct posix_acl *posix_acl_from_xattr(const void *value, - size_t size) -{ - return posix_acl_alloc(0, 0); -} -#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c) - -static inline void posix_acl_release(struct posix_acl *acl) {}; -static inline int posix_acl_valid(const struct posix_acl *acl) { return 0; } -static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl) -{ - return acl; -} -#endif /* END __KERNEL__ */ - -struct dentry { - void *d; -}; - -#ifndef O_SYNC -#define O_SYNC 0 -#endif -#ifndef O_DIRECTORY -#define O_DIRECTORY 0 -#endif -#ifndef O_LARGEFILE -#define O_LARGEFILE 0 -#endif - -#endif diff --git a/libcfs/include/libcfs/darwin/darwin-lock.h b/libcfs/include/libcfs/darwin/darwin-lock.h deleted file mode 100644 index ac80e7a..0000000 --- a/libcfs/include/libcfs/darwin/darwin-lock.h +++ /dev/null @@ -1,320 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_CFS_LOCK_H__ -#define __LIBCFS_DARWIN_CFS_LOCK_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ -#include -#include -#include -#include -#include - -#include -#include - -/* - * spin_lock (use Linux kernel's primitives) - * - * - spin_lock_init(x) - * - spin_lock(x) - * - spin_unlock(x) - * - spin_trylock(x) - * - * - spin_lock_irqsave(x, f) - * - spin_unlock_irqrestore(x, f) - */ -struct spin_lock { - struct kspin spin; -}; - -typedef struct spin_lock spinlock_t; - -static inline void spin_lock_init(spinlock_t *lock) -{ - kspin_init(&lock->spin); -} - -static inline void spin_lock(spinlock_t *lock) -{ - kspin_lock(&lock->spin); -} - -static inline void spin_unlock(spinlock_t *lock) -{ - kspin_unlock(&lock->spin); -} - -static inline int spin_trylock(spinlock_t *lock) -{ - return kspin_trylock(&lock->spin); -} - -static inline void spin_lock_done(spinlock_t *lock) -{ - kspin_done(&lock->spin); -} - -#error "does this lock out timer callbacks?" -#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) - -extern boolean_t ml_set_interrupts_enabled(boolean_t enable); -#define __disable_irq() ml_set_interrupts_enabled(FALSE) -#define __enable_irq(x) (void) ml_set_interrupts_enabled(x) - -#define spin_lock_irqsave(s, f) do{ \ - f = __disable_irq(); \ - spin_lock(s); }while(0) - -#define spin_unlock_irqrestore(s, f) do{ \ - spin_unlock(s); \ - __enable_irq(f);}while(0) - -/* - * Semaphore - * - * - sema_init(x, v) - * - __down(x) - * - __up(x) - */ -struct semaphore { - struct ksem sem; -}; - -static inline void sema_init(struct semaphore *s, int val) -{ - ksem_init(&s->sem, val); -} - -static inline void __down(struct semaphore *s) -{ - ksem_down(&s->sem, 1); -} - -static inline void __up(struct semaphore *s) -{ - ksem_up(&s->sem, 1); -} - -/* - * Mutex: - * - * - init_mutex(x) - * - init_mutex_locked(x) - * - mutex_up(x) - * - mutex_down(x) - */ - -#define mutex_up(s) __up(s) -#define mutex_down(s) __down(s) - -#define init_mutex(x) sema_init(x, 1) -#define init_mutex_locked(x) sema_init(x, 0) - -/* - * Completion: - * - * - init_completion(c) - * - complete(c) - * - wait_for_completion(c) - */ -struct completion { - /* - * Emulate completion by semaphore for now. - * - * XXX nikita: this is not safe if completion is used to synchronize - * exit from kernel daemon thread and kext unloading. In this case - * some core function (a la complete_and_exit()) is needed. - */ - struct ksem sem; -}; - -static inline void init_completion(struct completion *c) -{ - ksem_init(&c->sem, 0); -} - -static inline void complete(struct completion *c) -{ - ksem_up(&c->sem, 1); -} - -static inline void wait_for_completion(struct completion *c) -{ - ksem_down(&c->sem, 1); -} - -/* - * rw_semaphore: - * - * - DECLARE_RWSEM(x) - * - init_rwsem(x) - * - down_read(x) - * - up_read(x) - * - down_write(x) - * - up_write(x) - */ -struct rw_semaphore { - struct krw_sem s; -}; - -static inline void init_rwsem(struct rw_semaphore *s) -{ - krw_sem_init(&s->s); -} - -static inline void fini_rwsem(struct rw_semaphore *s) -{ - krw_sem_done(&s->s); -} - -static inline void down_read(struct rw_semaphore *s) -{ - krw_sem_down_r(&s->s); -} - -static inline int down_read_trylock(struct rw_semaphore *s) -{ - int ret = krw_sem_down_r_try(&s->s); - return ret == 0; -} - -static inline void down_write(struct rw_semaphore *s) -{ - krw_sem_down_w(&s->s); -} - -static inline int down_write_trylock(struct rw_semaphore *s) -{ - int ret = krw_sem_down_w_try(&s->s); - return ret == 0; -} - -static inline void up_read(struct rw_semaphore *s) -{ - krw_sem_up_r(&s->s); -} - -static inline void up_write(struct rw_semaphore *s) -{ - krw_sem_up_w(&s->s); -} - -/* - * read-write lock : Need to be investigated more!! - * - * - DECLARE_RWLOCK(l) - * - rwlock_init(x) - * - read_lock(x) - * - read_unlock(x) - * - write_lock(x) - * - write_unlock(x) - */ -typedef struct krw_spin rwlock_t; - -#define rwlock_init(pl) krw_spin_init(pl) - -#define read_lock(l) krw_spin_down_r(l) -#define read_unlock(l) krw_spin_up_r(l) -#define write_lock(l) krw_spin_down_w(l) -#define write_unlock(l) krw_spin_up_w(l) - -#define write_lock_irqsave(l, f) do{ \ - f = __disable_irq(); \ - write_lock(l); }while(0) - -#define write_unlock_irqrestore(l, f) do{ \ - write_unlock(l); \ - __enable_irq(f);}while(0) - -#define read_lock_irqsave(l, f) do{ \ - f = __disable_irq(); \ - read_lock(l); }while(0) - -#define read_unlock_irqrestore(l, f) do{ \ - read_unlock(l); \ - __enable_irq(f);}while(0) -/* - * Funnel: - * - * Safe funnel in/out - */ -#ifdef __DARWIN8__ - -#define CFS_DECL_FUNNEL_DATA -#define CFS_DECL_CONE_DATA DECLARE_FUNNEL_DATA -#define CFS_DECL_NET_DATA DECLARE_FUNNEL_DATA -#define CFS_CONE_IN do {} while(0) -#define CFS_CONE_EX do {} while(0) - -#define CFS_NET_IN do {} while(0) -#define CFS_NET_EX do {} while(0) - -#else - -#define CFS_DECL_FUNNEL_DATA \ - boolean_t __funnel_state = FALSE; \ - funnel_t *__funnel -#define CFS_DECL_CONE_DATA CFS_DECL_FUNNEL_DATA -#define CFS_DECL_NET_DATA CFS_DECL_FUNNEL_DATA - -void lustre_cone_in(boolean_t *state, funnel_t **cone); -void lustre_cone_ex(boolean_t state, funnel_t *cone); - -#define CFS_CONE_IN lustre_cone_in(&__funnel_state, &__funnel) -#define CFS_CONE_EX lustre_cone_ex(__funnel_state, __funnel) - -void lustre_net_in(boolean_t *state, funnel_t **cone); -void lustre_net_ex(boolean_t state, funnel_t *cone); - -#define CFS_NET_IN lustre_net_in(&__funnel_state, &__funnel) -#define CFS_NET_EX lustre_net_ex(__funnel_state, __funnel) - -#endif - -#else -#include -#endif /* __KERNEL__ */ - -/* __XNU_CFS_LOCK_H */ -#endif diff --git a/libcfs/include/libcfs/darwin/darwin-mem.h b/libcfs/include/libcfs/darwin/darwin-mem.h deleted file mode 100644 index b1a6cd5..0000000 --- a/libcfs/include/libcfs/darwin/darwin-mem.h +++ /dev/null @@ -1,305 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_CFS_MEM_H__ -#define __LIBCFS_DARWIN_CFS_MEM_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* - * Basic xnu_page struct, should be binary compatibility with - * all page types in xnu (we have only xnu_raw_page, xll_page now) - */ - -/* Variable sized pages are not supported */ - -#ifdef PAGE_SHIFT -#define PAGE_CACHE_SHIFT PAGE_SHIFT -#else -#define PAGE_CACHE_SHIFT 12 -#endif - -#define PAGE_CACHE_SIZE (1UL << PAGE_CACHE_SHIFT) - -#define CFS_PAGE_MASK (~((__u64)PAGE_CACHE_SIZE - 1)) - -enum { - XNU_PAGE_RAW, - XNU_PAGE_XLL, - XNU_PAGE_NTYPES -}; - -typedef __u32 page_off_t; - -/* - * For XNU we have our own page cache built on top of underlying BSD/MACH - * infrastructure. In particular, we have two disjoint types of pages: - * - * - "raw" pages (XNU_PAGE_RAW): these are just buffers mapped into KVM, - * based on UPLs, and - * - * - "xll" pages (XNU_PAGE_XLL): these are used by file system to cache - * file data, owned by file system objects, hashed, lrued, etc. - * - * struct page has to cover both of them, because core Lustre code is based on - * the Linux assumption that page is _both_ memory buffer and file system - * caching entity. - * - * To achieve this, all types of pages supported on XNU has to start from - * common header that contains only "page type". Common struct page operations - * dispatch through operation vector based on page type. - * - */ -typedef struct xnu_page { - int type; -} struct page; - -struct xnu_page_ops { - void *(*page_map) (struct page *); - void (*page_unmap) (struct page *); - void *(*page_address) (struct page *); -}; - -void xnu_page_ops_register(int type, struct xnu_page_ops *ops); -void xnu_page_ops_unregister(int type); - -/* - * raw page, no cache object, just like buffer - */ -struct xnu_raw_page { - struct xnu_page header; - void *virtual; - atomic_t count; - struct list_head link; -}; - -/* - * Public interface to lustre - * - * - alloc_page(f) - * - __free_page(p) - * - kmap(p) - * - kunmap(p) - * - page_address(p) - */ - -/* - * Of all functions above only kmap(), kunmap(), and - * page_address() can be called on file system pages. The rest is for raw - * pages only. - */ - -struct page *alloc_page(u_int32_t flags); -void __free_page(struct page *page); -void get_page(struct page *page); -int cfs_put_page_testzero(struct page *page); -int page_count(struct page *page); -#define page_index(pg) (0) - -void *page_address(struct page *pg); -void *kmap(struct page *pg); -void kunmap(struct page *pg); - -/* - * Memory allocator - */ - -void *kmalloc(size_t nr_bytes, u_int32_t flags); -void kfree(void *addr); - -void *vmalloc(size_t nr_bytes); -void vfree(void *addr); - -extern int get_preemption_level(void); - -/* - * Universal memory allocator API - */ -enum cfs_alloc_flags { - /* allocation is not allowed to block */ - GFP_ATOMIC = 0x1, - /* allocation is allowed to block */ - __GFP_WAIT = 0x2, - /* allocation should return zeroed memory */ - __GFP_ZERO = 0x4, - /* allocation is allowed to call file-system code to free/clean - * memory */ - __GFP_FS = 0x8, - /* allocation is allowed to do io to free/clean memory */ - __GFP_IO = 0x10, - /* don't report allocation failure to the console */ - __GFP_NOWARN = 0x20, - /* standard allocator flag combination */ - GFP_IOFS = __GFP_FS | __GFP_IO, - GFP_USER = __GFP_WAIT | __GFP_FS | __GFP_IO, - GFP_NOFS = __GFP_WAIT | __GFP_IO, - GFP_KERNEL = __GFP_WAIT | __GFP_IO | __GFP_FS, -}; - -/* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */ -enum cfs_alloc_page_flags { - /* allow to return page beyond KVM. It has to be mapped into KVM by - * kmap() and unmapped with kunmap(). */ - __GFP_HIGHMEM = 0x40, - GFP_HIGHUSER = __GFP_WAIT | __GFP_FS | __GFP_IO | - __GFP_HIGHMEM, -}; - -#define ALLOC_ATOMIC_TRY \ - (get_preemption_level() != 0 ? GFP_ATOMIC : 0) - -#define memory_pressure_get() (0) -#define memory_pressure_set() do {} while (0) -#define memory_pressure_clr() do {} while (0) - -/* - * Slab: - * - * No slab in OSX, use zone allocator to simulate slab - */ -#define SLAB_HWCACHE_ALIGN 0 - -#ifdef __DARWIN8__ -/* - * In Darwin8, we cannot use zalloc_noblock(not exported by kernel), - * also, direct using of zone allocator is not recommended. - */ -#define CFS_INDIVIDUAL_ZONE (0) - -#if !CFS_INDIVIDUAL_ZONE -#include -typedef OSMallocTag mem_cache_t; -#else -typedef void* zone_t; -typedef zone_t mem_cache_t; -#endif - -#else /* !__DARWIN8__ */ - -#define CFS_INDIVIDUAL_ZONE (1) - -typedef zone_t mem_cache_t; - -#endif /* !__DARWIN8__ */ - -#define MC_NAME_MAX_LEN 64 - -struct kmem_cache { - int mc_size; - mem_cache_t mc_cache; - struct list_head mc_link; - char mc_name [MC_NAME_MAX_LEN]; -}; - -#define KMEM_CACHE_MAX_COUNT 64 -#define KMEM_MAX_ZONE 8192 - -struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, - unsigned long, void *); -void kmem_cache_destroy(struct kmem_cache *); -void *kmem_cache_alloc(struct kmem_cache *, int); -void kmem_cache_free(struct kmem_cache *, void *); - -/* - * Misc - */ -/* XXX Liang: totalram_pages... fix me */ -#define totalram_pages (64 * 1024) -#define NUM_CACHEPAGES totalram_pages - -#define DECL_MMSPACE -#define MMSPACE_OPEN do {} while (0) -#define MMSPACE_CLOSE do {} while (0) - -#define copy_from_user(kaddr, uaddr, size) copyin(CAST_USER_ADDR_T(uaddr), (caddr_t)kaddr, size) -#define copy_to_user(uaddr, kaddr, size) copyout((caddr_t)kaddr, CAST_USER_ADDR_T(uaddr), size) - -#if 0 -static inline int strncpy_from_user(char *kaddr, char *uaddr, int size) -{ - size_t count; - return copyinstr((const user_addr_t)uaddr, (void *)kaddr, size, &count); -} -#endif - -#if defined (__ppc__) -#define mb() __asm__ __volatile__ ("sync" : : : "memory") -#define rmb() __asm__ __volatile__ ("sync" : : : "memory") -#define wmb() __asm__ __volatile__ ("eieio" : : : "memory") -#elif defined (__i386__) -#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory") -#define rmb() mb() -#define wmb() __asm__ __volatile__ ("": : :"memory") -#else -#error architecture not supported -#endif - -#else /* !__KERNEL__ */ - -#define CFS_CACHE_SHIFT 12 -#define PAGE_CACHE_SIZE (1 << CFS_CACHE_SHIFT) -#include - -#endif /* __KERNEL__ */ - -#endif /* __XNU_CFS_MEM_H__ */ diff --git a/libcfs/include/libcfs/darwin/darwin-prim.h b/libcfs/include/libcfs/darwin/darwin-prim.h deleted file mode 100644 index c456e3f..0000000 --- a/libcfs/include/libcfs/darwin/darwin-prim.h +++ /dev/null @@ -1,541 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_CFS_PRIM_H__ -#define __LIBCFS_DARWIN_CFS_PRIM_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifndef EXPORT_SYMBOL -# define EXPORT_SYMBOL(s) -#endif - -#ifdef __KERNEL__ -#include -#include - -#ifndef __DARWIN8__ -# ifndef __APPLE_API_PRIVATE -# define __APPLE_API_PRIVATE -# include -# undef __APPLE_API_PRIVATE -# else -# include -# endif -# include -# include -# include -#endif /* !__DARWIN8__ */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* - * Symbol functions for libcfs - * - * OSX has no facility for use to register symbol. - * So we have to implement it. - */ -#define CFS_SYMBOL_LEN 64 - -struct cfs_symbol { - char name[CFS_SYMBOL_LEN]; - void *value; - int ref; - struct list_head sym_list; -}; - -extern kern_return_t cfs_symbol_register(const char *, const void *); -extern kern_return_t cfs_symbol_unregister(const char *); -extern void * cfs_symbol_get(const char *); -extern kern_return_t cfs_symbol_put(const char *); - -/* - * sysctl typedef - * - * User can register/unregister a list of sysctl_oids - * sysctl_oid is data struct of osx's sysctl-entry - */ -#define CONFIG_SYSCTL 1 - -#define ctl_table sysctl_oid -struct ctl_table *register_sysctl_table(struct ctl_table *table); -void unregister_sysctl_table(struct ctl_table *table); - -/* - * Proc file system APIs, no /proc fs support in OSX - */ -typedef struct cfs_proc_dir_entry { - void *data; -} cfs_proc_dir_entry_t; - -cfs_proc_dir_entry_t * cfs_create_proc_entry(char *name, int mod, - cfs_proc_dir_entry_t *parent); -void cfs_free_proc_entry(cfs_proc_dir_entry_t *de); -void cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry); - -typedef int (read_proc_t)(char *page, char **start, off_t off, - int count, int *eof, void *data); -typedef int (write_proc_t)(struct file *file, const char *buffer, - unsigned long count, void *data); - -/* - * cfs pseudo device - * - * struct miscdevice - * misc_register: - * misc_deregister: - */ -struct miscdevice{ - int index; - void *handle; - const char *name; - struct cdevsw *devsw; - void *private; -}; - -extern kern_return_t misc_register(struct miscdevice *); -extern kern_return_t misc_deregister(struct miscdevice *); - -/* - * Task struct and ... - * - * Using BSD current_proc in Darwin - */ -extern boolean_t assert_wait_possible(void); -extern void *get_bsdtask_info(task_t); - -#ifdef __DARWIN8__ - -typedef struct task_struct {}; -#define current ((struct task_struct *)current_thread()) -#else /* !__DARWIN8__ */ - -#define task_struct uthread - -#define current_uthread() ((struct uthread *)get_bsdthread_info(current_act())) -#define current current_uthread() - -#endif /* !__DARWIN8__ */ - -#define task_lock(t) do {;} while (0) -#define task_unlock(t) do {;} while (0) - -#define set_current_state(s) do {;} while (0) - -#define DECL_JOURNAL_DATA -#define PUSH_JOURNAL do {;} while(0) -#define POP_JOURNAL do {;} while(0) - -/* - * Kernel thread: - * - * OSX kernel thread can not be created with args, - * so we have to implement new APIs to create thread with args - */ - -typedef int (*cfs_thread_t)(void *); - -extern task_t kernel_task; - -/* - * cloning flags, no use in OSX, just copy them from Linux - */ -#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ -#define CLONE_VM 0x00000100 /* set if VM shared between processes */ -#define CLONE_FS 0x00000200 /* set if fs info shared between processes */ -#define CLONE_FILES 0x00000400 /* set if open files shared between processes */ -#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ -#define CLONE_PID 0x00001000 /* set if pid shared */ -#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ -#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ -#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ -#define CLONE_THREAD 0x00010000 /* Same thread group? */ -#define CLONE_NEWNS 0x00020000 /* New namespace group? */ - -#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD) - -extern struct task_struct kthread_run(cfs_thread_t func, void *arg, - const char namefmt[], ...); - -/* - * Wait Queue implementation - * - * Like wait_queue in Linux - */ -typedef struct cfs_waitq { - struct ksleep_chan wq_ksleep_chan; -} wait_queue_head_t; - -typedef struct cfs_waitlink { - struct cfs_waitq *wl_waitq; - struct ksleep_link wl_ksleep_link; -} wait_queue_t; - -#define TASK_INTERRUPTIBLE THREAD_ABORTSAFE -#define TASK_UNINTERRUPTIBLE THREAD_UNINT - -void init_waitqueue_head(struct cfs_waitq *waitq); -void init_waitqueue_entry_current(struct cfs_waitlink *link); - -void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link); -void add_wait_queue_exclusive(struct cfs_waitq *waitq, - struct cfs_waitlink *link); -void remove_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link); -int waitqueue_active(struct cfs_waitq *waitq); - -void wake_up(struct cfs_waitq *waitq); -void wake_up_nr(struct cfs_waitq *waitq, int nr); -void wake_up_all(struct cfs_waitq *waitq); - -void waitq_wait(struct cfs_waitlink *link, long state); -cfs_duration_t waitq_timedwait(struct cfs_waitlink *link, - long state, - cfs_duration_t timeout); - -/* - * Thread schedule APIs. - */ -#define MAX_SCHEDULE_TIMEOUT ((long)(~0UL>>12)) -extern void thread_set_timer_deadline(__u64 deadline); -extern void thread_cancel_timer(void); - -static inline int schedule_timeout(int state, int64_t timeout) -{ - int result; - -#ifdef __DARWIN8__ - result = assert_wait((event_t)current_thread(), state); -#else - result = assert_wait((event_t)current_uthread(), state); -#endif - if (timeout > 0) { - __u64 expire; - nanoseconds_to_absolutetime(timeout, &expire); - clock_absolutetime_interval_to_deadline(expire, &expire); - thread_set_timer_deadline(expire); - } - if (result == THREAD_WAITING) - result = thread_block(THREAD_CONTINUE_NULL); - if (timeout > 0) - thread_cancel_timer(); - if (result == THREAD_TIMED_OUT) - result = 0; - else - result = 1; - return result; -} - -#define schedule() schedule_timeout(TASK_UNINTERRUPTIBLE, CFS_TICK) -#define cfs_pause(tick) schedule_timeout(TASK_UNINTERRUPTIBLE, tick) - -#define __wait_event(wq, condition) \ -do { \ - struct cfs_waitlink __wait; \ - \ - init_waitqueue_entry_current(&__wait); \ - for (;;) { \ - add_wait_queue(&wq, &__wait); \ - if (condition) \ - break; \ - waitq_wait(&__wait, TASK_UNINTERRUPTIBLE); \ - remove_wait_queue(&wq, &__wait); \ - } \ - remove_wait_queue(&wq, &__wait); \ -} while (0) - -#define wait_event(wq, condition) \ -do { \ - if (condition) \ - break; \ - __wait_event(wq, condition); \ -} while (0) - -#define __wait_event_interruptible(wq, condition, ex, ret) \ -do { \ - struct cfs_waitlink __wait; \ - \ - init_waitqueue_entry_current(&__wait); \ - for (;;) { \ - if (ex == 0) \ - add_wait_queue(&wq, &__wait); \ - else \ - add_wait_queue_exclusive(&wq, &__wait); \ - if (condition) \ - break; \ - if (!cfs_signal_pending()) { \ - waitq_wait(&__wait, \ - TASK_INTERRUPTIBLE); \ - remove_wait_queue(&wq, &__wait); \ - continue; \ - } \ - ret = -ERESTARTSYS; \ - break; \ - } \ - remove_wait_queue(&wq, &__wait); \ -} while (0) - -#define wait_event_interruptible(wq, condition) \ -({ \ - int __ret = 0; \ - if (!condition) \ - __wait_event_interruptible(wq, condition, \ - 0, __ret); \ - __ret; \ -}) - -#define wait_event_interruptible_exclusive(wq, condition) \ -({ \ - int __ret = 0; \ - if (!condition) \ - __wait_event_interruptible(wq, condition, \ - 1, __ret); \ - __ret; \ -}) - -#ifndef __DARWIN8__ -extern void wakeup_one __P((void * chan)); -#endif -/* only used in tests */ -#define wake_up_process(p) \ - do { \ - wakeup_one((caddr_t)p); \ - } while (0) - -/* used in couple of places */ -static inline void sleep_on(wait_queue_head_t *waitq) -{ - wait_queue_t link; - - init_waitqueue_entry_current(&link); - add_wait_queue(waitq, &link); - waitq_wait(&link, TASK_UNINTERRUPTIBLE); - remove_wait_queue(waitq, &link); -} - -/* - * Signal - */ - -/* - * Timer - */ -struct timer_list { - struct ktimer t; -}; - -#define cfs_init_timer(t) do {} while(0) -void cfs_timer_init(struct timer_list *t, void (*func)(unsigned long), void *arg); -void cfs_timer_done(struct timer_list *t); -void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline); -void cfs_timer_disarm(struct timer_list *t); -int cfs_timer_is_armed(struct timer_list *t); - -cfs_time_t cfs_timer_deadline(struct timer_list *t); - -/* - * Ioctl - * We don't need to copy out everything in osx - */ -#define cfs_ioctl_data_out(a, d, l) \ - ({ \ - int __size; \ - int __rc = 0; \ - assert((l) >= sizeof(*d)); \ - __size = (l) - sizeof(*d); \ - if (__size > 0) \ - __rc = copy_to_user((void *)a + __size, \ - (void *)d + __size, \ - __size); \ - __rc; \ - }) - -/* - * CPU - */ -/* Run in PowerG5 who is PPC64 */ -#define SMP_CACHE_BYTES 128 -#define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) -#define NR_CPUS 2 - -/* - * XXX Liang: patch xnu and export current_processor()? - * - * #define smp_processor_id() current_processor() - */ -#define smp_processor_id() 0 -/* XXX smp_call_function is not supported in xnu */ -#define smp_call_function(f, a, n, w) do {} while(0) -int cfs_online_cpus(void); - -/* - * Misc - */ -extern int is_suser(void); - -#ifndef likely -#define likely(exp) (exp) -#endif -#ifndef unlikely -#define unlikely(exp) (exp) -#endif - -#define lock_kernel() do {} while(0) -#define unlock_kernel() do {} while(0) - -#define call_usermodehelper(path, argv, envp, 1) (0) - -#define cfs_module(name, version, init, fini) \ -extern kern_return_t _start(kmod_info_t *ki, void *data); \ -extern kern_return_t _stop(kmod_info_t *ki, void *data); \ -__private_extern__ kern_return_t name##_start(kmod_info_t *ki, void *data); \ -__private_extern__ kern_return_t name##_stop(kmod_info_t *ki, void *data); \ - \ -kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1, \ - { "com.clusterfs.lustre." #name }, { version }, \ - -1, 0, 0, 0, 0, name##_start, name##_stop }; \ - \ -__private_extern__ kmod_start_func_t *_realmain = name##_start; \ -__private_extern__ kmod_stop_func_t *_antimain = name##_stop; \ -__private_extern__ int _kext_apple_cc = __APPLE_CC__ ; \ - \ -kern_return_t name##_start(kmod_info_t *ki, void *d) \ -{ \ - return init(); \ -} \ - \ -kern_return_t name##_stop(kmod_info_t *ki, void *d) \ -{ \ - fini(); \ - return KERN_SUCCESS; \ -} \ - \ -/* \ - * to allow semicolon after cfs_module(...) \ - */ \ -struct __dummy_ ## name ## _struct {} - -#define inter_module_get(n) cfs_symbol_get(n) -#define inter_module_put(n) cfs_symbol_put(n) - -static inline int request_module(const char *name, ...) -{ - return (-EINVAL); -} - -#ifndef __exit -#define __exit -#endif -#ifndef __init -#define __init -#endif - -#define MODULE_AUTHOR(s) -#define MODULE_DESCRIPTION(s) -#define MODULE_LICENSE(s) -#define MODULE_PARM(a, b) -#define MODULE_PARM_DESC(a, b) - -#define NR_IRQS 512 -#define in_interrupt() ml_at_interrupt_context() - -#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 */ - -#else /* !__KERNEL__ */ - -typedef struct cfs_proc_dir_entry { - void *data; -} cfs_proc_dir_entry_t; - -#include -#define __WORDSIZE 32 - -#endif /* END __KERNEL__ */ -/* - * Error number - */ -#ifndef EPROTO -#define EPROTO EPROTOTYPE -#endif -#ifndef EBADR -#define EBADR EBADRPC -#endif -#ifndef ERESTARTSYS -#define ERESTARTSYS 512 -#endif -#ifndef EDEADLOCK -#define EDEADLOCK EDEADLK -#endif -#ifndef ECOMM -#define ECOMM EINVAL -#endif -#ifndef ENODATA -#define ENODATA EINVAL -#endif -#ifndef ENOTSUPP -#define ENOTSUPP EINVAL -#endif - -#if BYTE_ORDER == BIG_ENDIAN -# define __BIG_ENDIAN -#else -# define __LITTLE_ENDIAN -#endif - -#endif /* __LIBCFS_DARWIN_CFS_PRIM_H__ */ diff --git a/libcfs/include/libcfs/darwin/darwin-sync.h b/libcfs/include/libcfs/darwin/darwin-sync.h deleted file mode 100644 index 10e471a..0000000 --- a/libcfs/include/libcfs/darwin/darwin-sync.h +++ /dev/null @@ -1,341 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/darwin/darwin-sync.h - * - * Prototypes of XNU synchronization primitives. - */ - -#ifndef __LIBCFS_DARWIN_XNU_SYNC_H__ -#define __LIBCFS_DARWIN_XNU_SYNC_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#define XNU_SYNC_DEBUG (1) - -#if XNU_SYNC_DEBUG -#define ON_SYNC_DEBUG(e) e -#else -#define ON_SYNC_DEBUG(e) -#endif - -enum { - /* "egrep -i '^(o?x)?[abcdeflo]*$' /usr/dict/words" is your friend */ - KMUT_MAGIC = 0x0bac0cab, /* [a, [b, c]] = b (a, c) - c (a, b) */ - KSEM_MAGIC = 0x1abe11ed, - KCOND_MAGIC = 0xb01dface, - KRW_MAGIC = 0xdabb1edd, - KSPIN_MAGIC = 0xca11ab1e, - KRW_SPIN_MAGIC = 0xbabeface, - KSLEEP_CHAN_MAGIC = 0x0debac1e, - KSLEEP_LINK_MAGIC = 0xacc01ade, - KTIMER_MAGIC = 0xbefadd1e -}; - -/* ------------------------- spin lock ------------------------- */ - -/* - * XXX nikita: don't use NCPUS it's hardcoded to (1) in cpus.h - */ -#define SMP (1) - -#include - -#ifdef __DARWIN8__ - -#include -#include -#include -#include - -/* - * hw_lock is not available in Darwin8 (hw_lock_* are not exported at all), - * so use lck_spin_t. we can hack out lck_spin_t easily, it's the only - * hacking in Darwin8.x. We did so because it'll take a lot of time to - * add lock_done for all locks, maybe it should be done in the future. - * If lock_done for all locks were added, we can: - * - * typedef lck_spin_t *xnu_spin_t; - */ -#if defined (__ppc__) -typedef struct { - unsigned int opaque[3]; -} xnu_spin_t; -#elif defined (__i386__) -typedef struct { - unsigned int opaque[10]; -} xnu_spin_t; -#endif - -/* - * wait_queue is not available in Darwin8 (wait_queue_* are not exported), - * use assert_wait/wakeup/wake_one (wait_queue in kernel hash). - */ -typedef void * xnu_wait_queue_t; - -/* DARWIN8 */ -#else - -#include -#include -#include - -typedef hw_lock_data_t xnu_spin_t; -typedef struct wait_queue xnu_wait_queue_t; - -/* DARWIN8 */ -#endif - -struct kspin { -#if SMP - xnu_spin_t lock; -#endif -#if XNU_SYNC_DEBUG - unsigned magic; - thread_t owner; -#endif -}; - -void kspin_init(struct kspin *spin); -void kspin_done(struct kspin *spin); -void kspin_lock(struct kspin *spin); -void kspin_unlock(struct kspin *spin); -int kspin_trylock(struct kspin *spin); - -#if XNU_SYNC_DEBUG -/* - * two functions below are for use in assertions - */ -/* true, iff spin-lock is locked by the current thread */ -int kspin_islocked(struct kspin *spin); -/* true, iff spin-lock is not locked by the current thread */ -int kspin_isnotlocked(struct kspin *spin); -#else -#define kspin_islocked(s) (1) -#define kspin_isnotlocked(s) (1) -#endif - -/* ------------------------- rw spinlock ----------------------- */ -struct krw_spin { - struct kspin guard; - int count; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -void krw_spin_init(struct krw_spin *sem); -void krw_spin_done(struct krw_spin *sem); -void krw_spin_down_r(struct krw_spin *sem); -void krw_spin_down_w(struct krw_spin *sem); -void krw_spin_up_r(struct krw_spin *sem); -void krw_spin_up_w(struct krw_spin *sem); - -/* ------------------------- semaphore ------------------------- */ - -struct ksem { - struct kspin guard; - xnu_wait_queue_t q; - int value; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -void ksem_init(struct ksem *sem, int value); -void ksem_done(struct ksem *sem); -int ksem_up (struct ksem *sem, int value); -void ksem_down(struct ksem *sem, int value); -int ksem_trydown(struct ksem *sem, int value); - -/* ------------------------- mutex ------------------------- */ - -struct kmut { - struct ksem s; -#if XNU_SYNC_DEBUG - unsigned magic; - thread_t owner; -#endif -}; - -void kmut_init(struct kmut *mut); -void kmut_done(struct kmut *mut); - -void kmut_lock (struct kmut *mut); -void kmut_unlock (struct kmut *mut); -int kmut_trylock(struct kmut *mut); - -#if XNU_SYNC_DEBUG -/* - * two functions below are for use in assertions - */ -/* true, iff mutex is locked by the current thread */ -int kmut_islocked(struct kmut *mut); -/* true, iff mutex is not locked by the current thread */ -int kmut_isnotlocked(struct kmut *mut); -#else -#define kmut_islocked(m) (1) -#define kmut_isnotlocked(m) (1) -#endif - -/* ------------------------- condition variable ------------------------- */ - -struct kcond_link { - struct kcond_link *next; - struct ksem sem; -}; - -struct kcond { - struct kspin guard; - struct kcond_link *waiters; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -void kcond_init(struct kcond *cond); -void kcond_done(struct kcond *cond); -void kcond_wait(struct kcond *cond, struct kspin *lock); -void kcond_signal(struct kcond *cond); -void kcond_broadcast(struct kcond *cond); - -void kcond_wait_guard(struct kcond *cond); -void kcond_signal_guard(struct kcond *cond); -void kcond_broadcast_guard(struct kcond *cond); - -/* ------------------------- read-write semaphore ------------------------- */ - -struct krw_sem { - int count; - struct kcond cond; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -void krw_sem_init(struct krw_sem *sem); -void krw_sem_done(struct krw_sem *sem); -void krw_sem_down_r(struct krw_sem *sem); -int krw_sem_down_r_try(struct krw_sem *sem); -void krw_sem_down_w(struct krw_sem *sem); -int krw_sem_down_w_try(struct krw_sem *sem); -void krw_sem_up_r(struct krw_sem *sem); -void krw_sem_up_w(struct krw_sem *sem); - -/* ------------------------- sleep-channel ------------------------- */ - -struct ksleep_chan { - struct kspin guard; - struct list_head waiters; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -#define KSLEEP_CHAN_INITIALIZER {{{0}}} - -struct ksleep_link { - int flags; - event_t event; - int hits; - struct ksleep_chan *forward; - struct list_head linkage; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -enum { - KSLEEP_EXCLUSIVE = 1 -}; - -void ksleep_chan_init(struct ksleep_chan *chan); -void ksleep_chan_done(struct ksleep_chan *chan); - -void ksleep_link_init(struct ksleep_link *link); -void ksleep_link_done(struct ksleep_link *link); - -void ksleep_add(struct ksleep_chan *chan, struct ksleep_link *link); -void ksleep_del(struct ksleep_chan *chan, struct ksleep_link *link); - -void ksleep_wait(struct ksleep_chan *chan, int state); -int64_t ksleep_timedwait(struct ksleep_chan *chan, int state, __u64 timeout); - -void ksleep_wake(struct ksleep_chan *chan); -void ksleep_wake_all(struct ksleep_chan *chan); -void ksleep_wake_nr(struct ksleep_chan *chan, int nr); - -#define KSLEEP_LINK_DECLARE(name) \ -{ \ - .flags = 0, \ - .event = 0, \ - .hits = 0, \ - .linkage = LIST_HEAD_INIT(name.linkage),\ - .magic = KSLEEP_LINK_MAGIC \ -} - -/* ------------------------- timer ------------------------- */ - -struct ktimer { - struct kspin guard; - void (*func)(void *); - void *arg; - u_int64_t deadline; /* timer deadline in absolute nanoseconds */ - int armed; -#if XNU_SYNC_DEBUG - unsigned magic; -#endif -}; - -void ktimer_init(struct ktimer *t, void (*func)(void *), void *arg); -void ktimer_done(struct ktimer *t); -void ktimer_arm(struct ktimer *t, u_int64_t deadline); -void ktimer_disarm(struct ktimer *t); -int ktimer_is_armed(struct ktimer *t); - -u_int64_t ktimer_deadline(struct ktimer *t); - -/* __XNU_SYNC_H__ */ -#endif - -/* - * Local variables: - * c-indentation-style: "K&R" - * c-basic-offset: 8 - * tab-width: 8 - * fill-column: 80 - * scroll-step: 1 - * End: - */ diff --git a/libcfs/include/libcfs/darwin/darwin-tcpip.h b/libcfs/include/libcfs/darwin/darwin-tcpip.h deleted file mode 100644 index 49c21f0..0000000 --- a/libcfs/include/libcfs/darwin/darwin-tcpip.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/darwin/darwin-tcpip.h - * - * Basic library routines. - */ - -#ifndef __LIBCFS_DARWIN_TCPIP_H__ -#define __LIBCFS_DARWIN_TCPIP_H__ - -#ifdef __KERNEL__ -#include - -#ifdef __DARWIN8__ - -struct socket; - -typedef void (*so_upcall)(socket_t sock, void* arg, int waitf); - -#define CFS_SOCK_UPCALL 0x1 -#define CFS_SOCK_DOWN 0x2 - -#define CFS_SOCK_MAGIC 0xbabeface - -typedef struct cfs_socket { - socket_t s_so; - int s_magic; - int s_flags; - so_upcall s_upcall; - void *s_upcallarg; -} cfs_socket_t; - - -/* cfs_socket_t to bsd socket */ -#define C2B_SOCK(s) ((s)->s_so) - -static inline int get_sock_intopt(socket_t so, int opt) -{ - int val, len; - int rc; - - /* - * sock_getsockopt will take a lock(mutex) for socket, - * so it can be blocked. So be careful while using - * them. - */ - len = sizeof(val); - rc = sock_getsockopt(so, SOL_SOCKET, opt, &val, &len); - assert(rc == 0); - return val; -} - -#define SOCK_ERROR(s) get_sock_intopt(C2B_SOCK(s), SO_ERROR) -/* #define SOCK_WMEM_QUEUED(s) (0) */ -#define SOCK_WMEM_QUEUED(s) get_sock_intopt(C2B_SOCK(s), SO_NWRITE) -/* XXX Liang: no reliable way to get it in Darwin8.x */ -#define SOCK_TEST_NOSPACE(s) (0) - -void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg); -void libcfs_sock_reset_cb(cfs_socket_t *sock); - -#else /* !__DARWIN8__ */ - -#define SOCK_WMEM_QUEUED(so) ((so)->so_snd.sb_cc) -#define SOCK_ERROR(so) ((so)->so_error) - -#define SOCK_TEST_NOSPACE(so) (sbspace(&(so)->so_snd) < (so)->so_snd.sb_lowat) - -#endif /* !__DARWIN8__ */ - -#endif /* __KERNEL END */ - -#endif /* __XNU_CFS_TYPES_H__ */ diff --git a/libcfs/include/libcfs/darwin/darwin-time.h b/libcfs/include/libcfs/darwin/darwin-time.h deleted file mode 100644 index c22b138..0000000 --- a/libcfs/include/libcfs/darwin/darwin-time.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/darwin/darwin-time.h - * - * Implementation of portable time API for XNU kernel - * - * Author: Nikita Danilov - */ - -#ifndef __LIBCFS_DARWIN_DARWIN_TIME_H__ -#define __LIBCFS_DARWIN_DARWIN_TIME_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -/* Portable time API */ - -/* - * Platform provides three opaque data-types: - * - * cfs_time_t represents point in time. This is internal kernel - * time rather than "wall clock". This time bears no - * relation to gettimeofday(). - * - * cfs_duration_t represents time interval with resolution of internal - * platform clock - * - * cfs_fs_time_t represents instance in world-visible time. This is - * used in file-system time-stamps - * - * 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); - * - * cfs_duration_t cfs_duration_build(int64_t); - * - * time_t cfs_duration_sec (cfs_duration_t); - * void cfs_duration_usec(cfs_duration_t, struct timeval *); - * void cfs_duration_nsec(cfs_duration_t, struct timespec *); - * - * void cfs_fs_time_current(cfs_fs_time_t *); - * time_t cfs_fs_time_sec (cfs_fs_time_t *); - * void cfs_fs_time_usec (cfs_fs_time_t *, struct timeval *); - * void cfs_fs_time_nsec (cfs_fs_time_t *, struct timespec *); - * int cfs_fs_time_before (cfs_fs_time_t *, cfs_fs_time_t *); - * int cfs_fs_time_beforeq(cfs_fs_time_t *, cfs_fs_time_t *); - * - * CFS_TIME_FORMAT - * CFS_DURATION_FORMAT - * - */ - -#define ONE_BILLION ((u_int64_t)1000000000) -#define ONE_MILLION 1000000 - -#ifdef __KERNEL__ -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -/* - * There are three way to measure time in OS X: - * 1. nanoseconds - * 2. absolute time (abstime unit equal to the length of one bus cycle), - * schedule of thread/timer are counted by absolute time, but abstime - * in different mac can be different also, so we wouldn't use it. - * 3. clock interval (1sec = 100hz). But clock interval only taken by KPI - * like tsleep(). - * - * We use nanoseconds (uptime, not calendar time) - * - * clock_get_uptime() :get absolute time since bootup. - * nanouptime() :get nanoseconds since bootup - * microuptime() :get microseonds since bootup - * nanotime() :get nanoseconds since epoch - * microtime() :get microseconds since epoch - */ -typedef u_int64_t cfs_time_t; /* nanoseconds */ -typedef int64_t cfs_duration_t; - -#define CFS_TIME_T "%llu" -#define CFS_DURATION_T "%lld" - -typedef struct timeval cfs_fs_time_t; - -static inline cfs_time_t cfs_time_current(void) -{ - struct timespec instant; - - nanouptime(&instant); - return ((u_int64_t)instant.tv_sec) * NSEC_PER_SEC + instant.tv_nsec; -} - -static inline time_t cfs_time_current_sec(void) -{ - struct timespec instant; - - nanouptime(&instant); - return instant.tv_sec; -} - -static inline cfs_time_t cfs_time_add(cfs_time_t t, cfs_duration_t d) -{ - return t + d; -} - -static inline cfs_duration_t cfs_time_sub(cfs_time_t t1, cfs_time_t t2) -{ - return t1 - t2; -} - -static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2) -{ - return (int64_t)t1 - (int64_t)t2 < 0; -} - -static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2) -{ - return (int64_t)t1 - (int64_t)t2 <= 0; -} - -static inline void cfs_fs_time_current(cfs_fs_time_t *t) -{ - microtime((struct timeval *)t); -} - -static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t) -{ - return t->tv_sec; -} - -static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v) -{ - *v = *t; -} - -static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s) -{ - s->tv_sec = t->tv_sec; - s->tv_nsec = t->tv_usec * NSEC_PER_USEC; -} - -static inline cfs_duration_t cfs_time_seconds(int seconds) -{ - return (NSEC_PER_SEC * (int64_t)seconds); -} - -/* - * internal helper function used by cfs_fs_time_before*() - */ -static inline int64_t __cfs_fs_time_flat(cfs_fs_time_t *t) -{ - return ((int64_t)t->tv_sec)*NSEC_PER_SEC + t->tv_usec*NSEC_PER_USEC; -} - -static inline int cfs_fs_time_before(cfs_fs_time_t *t1, cfs_fs_time_t *t2) -{ - return __cfs_fs_time_flat(t1) - __cfs_fs_time_flat(t2) < 0; -} - -static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2) -{ - return __cfs_fs_time_flat(t1) - __cfs_fs_time_flat(t2) <= 0; -} - -static inline time_t cfs_duration_sec(cfs_duration_t d) -{ - return d / NSEC_PER_SEC; -} - -static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s) -{ - s->tv_sec = d / NSEC_PER_SEC; - s->tv_usec = (d - ((int64_t)s->tv_sec) * NSEC_PER_SEC) / NSEC_PER_USEC; -} - -static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s) -{ - s->tv_sec = d / NSEC_PER_SEC; - s->tv_nsec = d - ((int64_t)s->tv_sec) * NSEC_PER_SEC; -} - -#define cfs_time_current_64 cfs_time_current -#define cfs_time_add_64 cfs_time_add -#define cfs_time_shift_64 cfs_time_shift -#define cfs_time_before_64 cfs_time_before -#define cfs_time_beforeq_64 cfs_time_beforeq - -/* - * One jiffy (in nanoseconds) - * - * osfmk/kern/sched_prim.c - * #define DEFAULT_PREEMPTION_RATE 100 - */ -#define CFS_TICK (NSEC_PER_SEC / (u_int64_t)100) - -#define LTIME_S(t) (t) - -/* __KERNEL__ */ -#else - -/* - * User level - */ -#include - -/* __KERNEL__ */ -#endif - -/* __LIBCFS_DARWIN_DARWIN_TIME_H__ */ -#endif -/* - * Local variables: - * c-indentation-style: "K&R" - * c-basic-offset: 8 - * tab-width: 8 - * fill-column: 80 - * scroll-step: 1 - * End: - */ diff --git a/libcfs/include/libcfs/darwin/darwin-types.h b/libcfs/include/libcfs/darwin/darwin-types.h deleted file mode 100644 index 4a11fdd..0000000 --- a/libcfs/include/libcfs/darwin/darwin-types.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/darwin/darwin-types.h - * - * Basic library routines. - */ - -#ifndef __LIBCFS_DARWIN_XNU_TYPES_H__ -#define __LIBCFS_DARWIN_XNU_TYPES_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#include -#include - -#ifndef _BLKID_TYPES_H -#define _BLKID_TYPES_H -#endif - -typedef u_int8_t __u8; -typedef u_int16_t __u16; -typedef u_int32_t __u32; -typedef u_int64_t __u64; -typedef int8_t __s8; -typedef int16_t __s16; -typedef int32_t __s32; -typedef int64_t __s64; - -/* long integer with size equal to pointer */ -typedef unsigned long ulong_ptr_t; -typedef long long_ptr_t; - -#ifdef __KERNEL__ - -#include - - -typedef struct { int e; } event_chan_t; - -/* - * Atmoic define - */ -#include - -typedef struct { volatile uint32_t counter; } atomic_t; - -#define ATOMIC_INIT(i) { (i) } -#define atomic_read(a) ((a)->counter) -#define atomic_set(a, v) (((a)->counter) = (v)) -#ifdef __DARWIN8__ -/* OS*Atomic return the value before the operation */ -#define atomic_add(v, a) OSAddAtomic(v, (SInt32 *)&((a)->counter)) -#define atomic_sub(v, a) OSAddAtomic(-(v), (SInt32 *)&((a)->counter)) -#define atomic_inc(a) OSIncrementAtomic((SInt32 *)&((a)->counter)) -#define atomic_dec(a) OSDecrementAtomic((SInt32 *)&((a)->counter)) -#else /* !__DARWIN8__ */ -#define atomic_add(v, a) hw_atomic_add((__u32 *)&((a)->counter), v) -#define atomic_sub(v, a) hw_atomic_sub((__u32 *)&((a)->counter), v) -#define atomic_inc(a) atomic_add(1, a) -#define atomic_dec(a) atomic_sub(1, a) -#endif /* !__DARWIN8__ */ -#define atomic_sub_and_test(v, a) (atomic_sub(v, a) == (v)) -#define atomic_dec_and_test(a) (atomic_dec(a) == 1) -#define atomic_inc_return(a) (atomic_inc(a) + 1) -#define atomic_dec_return(a) (atomic_dec(a) - 1) - -#include -typedef off_t loff_t; - -#else /* !__KERNEL__ */ - -#include - -typedef off_t loff_t; - -#endif /* __KERNEL END */ -typedef unsigned short umode_t; - -#endif /* __XNU_CFS_TYPES_H__ */ diff --git a/libcfs/include/libcfs/darwin/darwin-utils.h b/libcfs/include/libcfs/darwin/darwin-utils.h deleted file mode 100644 index 98e0cc8..0000000 --- a/libcfs/include/libcfs/darwin/darwin-utils.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_UTILS_H__ -#define __LIBCFS_DARWIN_UTILS_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#include - -#ifdef __KERNEL__ -inline int isspace(char c); -char *strpbrk(const char *cs, const char *ct); -char * strsep(char **s, const char *ct); -size_t strnlen(const char * s, size_t count); -char * strstr(const char *in, const char *str); -char * strrchr(const char *p, int ch); -char * ul2dstr(unsigned long address, char *buf, int len); - -#define simple_strtol(a1, a2, a3) strtol(a1, a2, a3) -#define simple_strtoul(a1, a2, a3) strtoul(a1, a2, a3) -#define simple_strtoll(a1, a2, a3) strtoq(a1, a2, a3) -#define simple_strtoull(a1, a2, a3) strtouq(a1, a2, a3) - -#define test_bit(i, a) isset(a, i) -#define set_bit(i, a) setbit(a, i) -#define clear_bit(i, a) clrbit(a, i) - -#define get_random_bytes(buf, len) read_random(buf, len) - -#endif /* __KERNEL__ */ - -#ifndef min_t -#define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#endif -#ifndef max_t -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) -#endif - -#define do_div(n,base) \ - ({ \ - __u64 __n = (n); \ - __u32 __base = (base); \ - __u32 __mod; \ - \ - __mod = __n % __base; \ - n = __n / __base; \ - __mod; \ - }) - -#define NIPQUAD(addr) \ - ((unsigned char *)&addr)[0], \ - ((unsigned char *)&addr)[1], \ - ((unsigned char *)&addr)[2], \ - ((unsigned char *)&addr)[3] - -#define HIPQUAD NIPQUAD - -#ifndef LIST_CIRCLE -#define LIST_CIRCLE(elm, field) \ - do { \ - (elm)->field.le_prev = &(elm)->field.le_next; \ - } while (0) -#endif - -#endif /* __XNU_UTILS_H__ */ diff --git a/libcfs/include/libcfs/darwin/kp30.h b/libcfs/include/libcfs/darwin/kp30.h deleted file mode 100644 index 3484df6..0000000 --- a/libcfs/include/libcfs/darwin/kp30.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_KP30__ -#define __LIBCFS_DARWIN_KP30__ - -#ifdef __KERNEL__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#error libcfs_register_panic_notifier() missing -#error libcfs_unregister_panic_notifier() missing - -/* --------------------------------------------------------------------- */ -#define num_online_cpus() cfs_online_cpus() - -/******************************************************************************/ -/* XXX Liang: There is no module parameter supporting in OSX */ -#define CFS_MODULE_PARM(name, t, type, perm, desc) - -#define CFS_SYSFS_MODULE_PARM 0 /* no sysfs access to module parameters */ -/******************************************************************************/ - -#else /* !__KERNEL__ */ -# include -# include -# include -# include -# include -# include -# include -#endif - -#define BITS_PER_LONG LONG_BIT - -#define IOCTL_LIBCFS_TYPE struct libcfs_ioctl_data - -#define LPO64 "%#llo" -#define LPU64 "%llu" -#define LPD64 "%lld" -#define LPX64 "%#llx" -# define LI_POISON ((int)0x5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a) - -/* - * long_ptr_t & ulong_ptr_t, same to "long" for gcc - */ -# define LPLU "%lu" -# define LPLD "%ld" -# define LPLX "%#lx" - -/* - * pid_t - */ -# define LPPID "%d" - -#endif diff --git a/libcfs/include/libcfs/darwin/libcfs.h b/libcfs/include/libcfs/darwin/libcfs.h deleted file mode 100644 index 37e0710..0000000 --- a/libcfs/include/libcfs/darwin/libcfs.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_LIBCFS_H__ -#define __LIBCFS_DARWIN_LIBCFS_H__ - -#ifndef __LIBCFS_LIBCFS_H__ -#error Do not #include this file directly. #include instead -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __KERNEL__ -# include -# include -# define do_gettimeofday(tv) microuptime(tv) -#else -# include -# define do_gettimeofday(tv) gettimeofday(tv, NULL); -typedef unsigned long long cycles_t; -#endif - -#define __cpu_to_le64(x) OSSwapHostToLittleInt64(x) -#define __cpu_to_le32(x) OSSwapHostToLittleInt32(x) -#define __cpu_to_le16(x) OSSwapHostToLittleInt16(x) - -#define __le16_to_cpu(x) OSSwapLittleToHostInt16(x) -#define __le32_to_cpu(x) OSSwapLittleToHostInt32(x) -#define __le64_to_cpu(x) OSSwapLittleToHostInt64(x) - -#define cpu_to_le64(x) __cpu_to_le64(x) -#define cpu_to_le32(x) __cpu_to_le32(x) -#define cpu_to_le16(x) __cpu_to_le16(x) - -#define le64_to_cpu(x) __le64_to_cpu(x) -#define le32_to_cpu(x) __le32_to_cpu(x) -#define le16_to_cpu(x) __le16_to_cpu(x) - -#define __swab16(x) OSSwapInt16(x) -#define __swab32(x) OSSwapInt32(x) -#define __swab64(x) OSSwapInt64(x) -#define __swab16s(x) do { *(x) = __swab16(*(x)); } while (0) -#define __swab32s(x) do { *(x) = __swab32(*(x)); } while (0) -#define __swab64s(x) do { *(x) = __swab64(*(x)); } while (0) - - -#ifdef __KERNEL__ -# include -# include -/* Fix me */ -# define THREAD_SIZE 8192 -#else -# define THREAD_SIZE 8192 -#endif - -#define CHECK_STACK(msgdata, mask, cdls) do {} while(0) -#define CDEBUG_STACK() (0L) - -/* Darwin has defined RETURN, so we have to undef it in lustre */ -#ifdef RETURN -#undef RETURN -#endif - -/* - * When this is enabled debugging messages are indented according to the - * current "nesting level". Nesting level in increased when ENTRY macro - * is executed, and decreased on EXIT and RETURN. - */ -#ifdef __KERNEL__ -#define ENTRY_NESTING_SUPPORT (0) -#endif - -#if ENTRY_NESTING_SUPPORT - -/* - * Currently ENTRY_NESTING_SUPPORT is only supported for XNU port. Basic - * idea is to keep per-thread pointer to small data structure (struct - * cfs_debug_data) describing current nesting level. In XNU unused - * proc->p_wmegs field in hijacked for this. On Linux - * current->journal_info can be used. In user space - * pthread_{g,s}etspecific(). - * - * ENTRY macro allocates new cfs_debug_data on stack, and installs it as - * a current nesting level, storing old data in cfs_debug_data it just - * created. - * - * EXIT pops old value back. - * - */ - -/* - * One problem with this approach is that there is a lot of code that - * does ENTRY and then escapes scope without doing EXIT/RETURN. In this - * case per-thread current nesting level pointer is dangling (it points - * to the stack area that is possible already overridden). To detect - * such cases, we add two magic fields to the cfs_debug_data and check - * them whenever current nesting level pointer is dereferenced. While - * looking flaky this works because stack is always consumed - * "continously". - */ -enum { - CDD_MAGIC1 = 0x02128506, - CDD_MAGIC2 = 0x42424242 -}; - -struct cfs_debug_data { - unsigned int magic1; - struct cfs_debug_data *parent; - int nesting_level; - unsigned int magic2; -}; - -void __entry_nesting(struct cfs_debug_data *child); -void __exit_nesting(struct cfs_debug_data *child); -unsigned int __current_nesting_level(void); - -#define ENTRY_NESTING \ -struct cfs_debug_data __cdd = { .magic1 = CDD_MAGIC1, \ - .parent = NULL, \ - .nesting_level = 0, \ - .magic2 = CDD_MAGIC2 }; \ -__entry_nesting(&__cdd); - -#define EXIT_NESTING __exit_nesting(&__cdd) - -/* ENTRY_NESTING_SUPPORT */ -#else - -#define ENTRY_NESTING do {;} while (0) -#define EXIT_NESTING do {;} while (0) -#define __current_nesting_level() (0) - -/* ENTRY_NESTING_SUPPORT */ -#endif - -#define LUSTRE_LNET_PID 12345 - -#define _XNU_LIBCFS_H - -/* - * Platform specific declarations for cfs_curproc API (libcfs/curproc.h) - * - * Implementation is in darwin-curproc.c - */ -#define CFS_CURPROC_COMM_MAX MAXCOMLEN -/* - * XNU has no capabilities - */ -typedef __u32 kernel_cap_t; - -#ifdef __KERNEL__ -enum { - /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */ - CFS_STACK_TRACE_DEPTH = 16 -}; - -struct cfs_stack_trace { - void *frame[CFS_STACK_TRACE_DEPTH]; -}; - -#define printk(format, args...) printf(format, ## args) - -#ifdef WITH_WATCHDOG -#undef WITH_WATCHDOG -#endif - -/* - * Portable API to access common characteristics of "current" UNIX process. - */ -uid_t current_uid(void); -gid_t current_gid(void); -uid_t current_euid(void); -gid_t current_egid(void); -uid_t current_fsuid(void); -gid_t current_fsgid(void); -pid_t current_pid(void); -int in_group_p(gid_t group); -mode_t current_umask(void); -char *current_comm(void); - -/* check if task is running in compat mode.*/ -int current_is_32bit(void); - -#endif /* __KERNEL__ */ - -#endif /* _XNU_LIBCFS_H */ diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index e85731d..2fbab09 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -47,8 +47,6 @@ #include #elif defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 28c7c57..009e63a 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -299,10 +299,6 @@ do { \ goto label; \ } while (0) -/* - * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise - * there will be a warning in osx. - */ #if defined(__GNUC__) long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); diff --git a/libcfs/include/libcfs/posix/libcfs.h b/libcfs/include/libcfs/posix/libcfs.h index da04cfd..d19d12f 100644 --- a/libcfs/include/libcfs/posix/libcfs.h +++ b/libcfs/include/libcfs/posix/libcfs.h @@ -162,29 +162,6 @@ typedef unsigned long long cfs_cycles_t; # error "Unknown byte order" # endif /* __BIG_ENDIAN */ # endif /* __LITTLE_ENDIAN */ -#elif __APPLE__ -#define __cpu_to_le64(x) OSSwapHostToLittleInt64(x) -#define __cpu_to_le32(x) OSSwapHostToLittleInt32(x) -#define __cpu_to_le16(x) OSSwapHostToLittleInt16(x) - -#define __le16_to_cpu(x) OSSwapLittleToHostInt16(x) -#define __le32_to_cpu(x) OSSwapLittleToHostInt32(x) -#define __le64_to_cpu(x) OSSwapLittleToHostInt64(x) - -#define cpu_to_le64(x) __cpu_to_le64(x) -#define cpu_to_le32(x) __cpu_to_le32(x) -#define cpu_to_le16(x) __cpu_to_le16(x) - -#define le64_to_cpu(x) __le64_to_cpu(x) -#define le32_to_cpu(x) __le32_to_cpu(x) -#define le16_to_cpu(x) __le16_to_cpu(x) - -#define __swab16(x) OSSwapInt16(x) -#define __swab32(x) OSSwapInt32(x) -#define __swab64(x) OSSwapInt64(x) -#define __swab16s(x) do { *(x) = __swab16(*(x)); } while (0) -#define __swab32s(x) do { *(x) = __swab32(*(x)); } while (0) -#define __swab64s(x) do { *(x) = __swab64(*(x)); } while (0) #endif # ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */ diff --git a/libcfs/include/libcfs/util/platform.h b/libcfs/include/libcfs/util/platform.h index cd8556309..c2154e1 100644 --- a/libcfs/include/libcfs/util/platform.h +++ b/libcfs/include/libcfs/util/platform.h @@ -73,171 +73,6 @@ typedef pthread_cond_t l_cond_t; #define l_cond_wait(c, s) pthread_cond_wait(c, s) #endif -#elif __APPLE__ - -#ifdef HAVE_LIBREADLINE -#define READLINE_LIBRARY -#include -typedef VFunction rl_vintfunc_t; -typedef VFunction rl_voidfunc_t; -#endif /* HAVE_LIBREADLINE */ - -#include -#include -#include -#include -#include -#include -#include - -/* - * POSIX compliant inter-process synchronization aren't supported well - * in Darwin, pthread_mutex_t and pthread_cond_t can only work as - * inter-thread synchronization, they wouldn't work even being put in - * shared memory for multi-process. PTHREAD_PROCESS_SHARED is not - * supported by Darwin also (pthread_mutexattr_setpshared() with the - * PTHREAD_PROCESS_SHARED attribute will return EINVAL). - * - * The only inter-process sychronization mechanism can be used in Darwin - * is POSIX NAMED semaphores and file lock, here we use NAMED semaphore - * to implement mutex and condition. - * - * XXX Liang: - * They are just proto-type now, more tests are needed. - */ -#define L_LOCK_DEBUG (0) - -#define L_SEM_NAMESIZE 32 - -typedef struct { - sem_t *s_sem; -#if L_LOCK_DEBUG - char s_name[L_SEM_NAMESIZE]; -#endif -} l_sem_t; - -typedef l_sem_t l_mutex_t; - -typedef struct { - l_mutex_t c_guard; - int c_count; - l_sem_t c_waiter; -} l_cond_t; - -static inline int l_sem_init(l_sem_t *sem, int val) -{ - char *s_name; -#if L_LOCK_DEBUG - s_name = sem->s_name; -#else - char buf[L_SEM_NAMESIZE]; - s_name = buf; -#endif - /* get an unique name for named semaphore */ - snprintf(s_name, L_SEM_NAMESIZE, "%d-%p", (int)getpid(), sem); - sem->s_sem = sem_open(s_name, O_CREAT, 0600, val); - if ((int)sem->s_sem == SEM_FAILED) { - fprintf(stderr, "lock %s creating fail: %d, %d!\n", - s_name, (int)sem->s_sem, errno); - return -1; - } else { -#if L_LOCK_DEBUG - printf("open lock: %s\n", s_name); -#endif - } - return 0; -} - -static inline void l_sem_done(l_sem_t *sem) -{ -#if L_LOCK_DEBUG - printf("close lock: %s.\n", sem->s_name); -#endif - sem_close(sem->s_sem); -} - -static inline void l_sem_down(l_sem_t *sem) -{ -#if L_LOCK_DEBUG - printf("sem down :%s\n", sem->s_name); -#endif - sem_wait(sem->s_sem); -} - -static inline void l_sem_up(l_sem_t *sem) -{ -#if L_LOCK_DEBUG - printf("sem up :%s\n", sem->s_name); -#endif - sem_post(sem->s_sem); -} - -static inline void l_mutex_init(l_mutex_t *mutex) -{ - l_sem_init((l_sem_t *)mutex, 1); -} - -static inline void l_mutex_init_locked(l_mutex_t *mutex) -{ - l_sem_init((l_sem_t *)mutex, 0); -} - -static inline void l_mutex_done(l_mutex_t *mutex) -{ - l_sem_done((l_sem_t *)mutex); -} - -static inline void l_mutex_lock(l_mutex_t *mutex) -{ -#if L_LOCK_DEBUG - printf("lock cfs_mutex :%s\n", mutex->s_name); -#endif - sem_wait(mutex->s_sem); -} - -static inline void l_mutex_unlock(l_mutex_t *mutex) -{ -#if L_LOCK_DEBUG - printf("unlock cfs_mutex: %s\n", mutex->s_name); -#endif - sem_post(mutex->s_sem); -} - -static inline void l_cond_init(l_cond_t *cond) -{ - l_mutex_init(&cond->c_guard); - l_sem_init(&cond->c_waiter, 0); - cond->c_count = 0; -} - -static inline void l_cond_done(l_cond_t *cond) -{ - if (cond->c_count != 0) - fprintf(stderr, "your waiter list is not empty: %d!\n", cond->c_count); - l_mutex_done(&cond->c_guard); - l_sem_done(&cond->c_waiter); -} - -static inline void l_cond_wait(l_cond_t *cond, l_mutex_t *lock) -{ - l_mutex_lock(&cond->c_guard); - cond->c_count --; - l_mutex_unlock(&cond->c_guard); - l_mutex_unlock(lock); - l_sem_down(&cond->c_waiter); - l_mutex_lock(lock); -} - -static inline void l_cond_broadcast(l_cond_t *cond) -{ - l_mutex_lock(&cond->c_guard); - while (cond->c_count < 0) { - l_sem_up(&cond->c_waiter); - cond->c_count ++; - } - l_mutex_unlock(&cond->c_guard); -} - #else /* other platform */ #ifdef HAVE_LIBREADLINE diff --git a/libcfs/libcfs/Info.plist b/libcfs/libcfs/Info.plist deleted file mode 100644 index aaf9b2f..0000000 --- a/libcfs/libcfs/Info.plist +++ /dev/null @@ -1,35 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - libcfs - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.libcfs - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - - - diff --git a/libcfs/libcfs/autoMakefile.am b/libcfs/libcfs/autoMakefile.am index 82e903e..252a199 100644 --- a/libcfs/libcfs/autoMakefile.am +++ b/libcfs/libcfs/autoMakefile.am @@ -37,10 +37,7 @@ # SUBDIRS = linux util posix -if DARWIN -SUBDIRS += darwin -endif -DIST_SUBDIRS = linux util posix darwin +DIST_SUBDIRS = linux util posix noinst_LIBRARIES= libcfs.a libcfs_a_SOURCES= posix/posix-debug.c user-prim.c user-lock.c user-tcpip.c \ @@ -70,33 +67,10 @@ if LINUX modulenet_DATA := libcfs$(KMODEXT) endif -if DARWIN -macos_PROGRAMS = libcfs - -nodist_libcfs_SOURCES = darwin/darwin-sync.c darwin/darwin-mem.c \ - darwin/darwin-prim.c darwin/darwin-fs.c darwin/darwin-curproc.c \ - darwin/darwin-tcpip.c darwin/darwin-utils.c \ - darwin/darwin-debug.c darwin/darwin-proc.c \ - darwin/darwin-tracefile.c darwin/darwin-module.c \ - posix/posix-debug.c module.c tracefile.c nidstrings.c watchdog.c \ - kernel_user_comm.c hash.c posix/rbtree.c heap.c - -libcfs_CFLAGS := $(EXTRA_KCFLAGS) -libcfs_LDFLAGS := $(EXTRA_KLDFLAGS) -libcfs_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif - endif -install-data-hook: $(install_data_hook) - -MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o darwin/*.o libcfs -EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) Info.plist tracefile.h prng.c \ +MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o libcfs +EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) tracefile.h prng.c \ user-lock.c user-tcpip.c user-bitops.c user-prim.c workitem.c \ user-mem.c kernel_user_comm.c fail.c libcfs_cpu.c heap.c \ libcfs_mem.c libcfs_lock.c user-string.c linux/linux-tracefile.h diff --git a/libcfs/libcfs/darwin/.gitignore b/libcfs/libcfs/darwin/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/libcfs/libcfs/darwin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/libcfs/libcfs/darwin/Makefile.am b/libcfs/libcfs/darwin/Makefile.am deleted file mode 100644 index a389486..0000000 --- a/libcfs/libcfs/darwin/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -EXTRA_DIST = \ - darwin-mem.c \ - darwin-proc.c \ - darwin-utils.c \ - darwin-debug.c \ - darwin-module.c \ - darwin-sync.c \ - darwin-fs.c \ - darwin-prim.c \ - darwin-tracefile.c \ - darwin-curproc.c \ - darwin-tcpip.c diff --git a/libcfs/libcfs/darwin/darwin-curproc.c b/libcfs/libcfs/darwin/darwin-curproc.c deleted file mode 100644 index b0ac7ad..0000000 --- a/libcfs/libcfs/darwin/darwin-curproc.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-curproc.c - * - * Lustre curproc API implementation for XNU kernel - * - * Author: Nikita Danilov - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include - -/* - * Implementation of cfs_curproc API (see lnet/include/libcfs/curproc.h) - * for XNU kernel. - */ - -static inline struct ucred *curproc_ucred(void) -{ -#ifdef __DARWIN8__ - return proc_ucred(current_proc()); -#else - return current_proc()->p_cred->pc_ucred; -#endif -} - -uid_t current_uid(void) -{ - return curproc_ucred()->cr_uid; -} - -gid_t current_gid(void) -{ - LASSERT(curproc_ucred()->cr_ngroups > 0); - return curproc_ucred()->cr_groups[0]; -} - -uid_t current_fsuid(void) -{ -#ifdef __DARWIN8__ - return curproc_ucred()->cr_ruid; -#else - return current_proc()->p_cred->p_ruid; -#endif -} - -gid_t current_fsgid(void) -{ -#ifdef __DARWIN8__ - return curproc_ucred()->cr_rgid; -#else - return current_proc()->p_cred->p_rgid; -#endif -} - -pid_t current_pid(void) -{ -#ifdef __DARWIN8__ - /* no pid for each thread, return address of thread struct */ - return (pid_t)current_thread(); -#else - return current_proc()->p_pid; -#endif -} - -int in_group_p(gid_t gid) -{ - int i; - struct ucred *cr; - - cr = curproc_ucred(); - LASSERT(cr != NULL); - - for (i = 0; i < cr->cr_ngroups; ++ i) { - if (cr->cr_groups[i] == gid) - return 1; - } - return 0; -} - -mode_t current_umask(void) -{ -#ifdef __DARWIN8__ - /* - * XXX Liang: - * - * fd_cmask is not available in kexts, so we just assume - * verything is permited. - */ - return -1; -#else - return current_proc()->p_fd->fd_cmask; -#endif -} - -char *current_comm(void) -{ -#ifdef __DARWIN8__ - /* - * Writing to proc->p_comm is not permited in Darwin8, - * because proc_selfname() only return a copy of proc->p_comm, - * so this function is not really working while user try to - * change comm of current process. - */ - static char pcomm[MAXCOMLEN+1]; - - proc_selfname(pcomm, MAXCOMLEN+1); - return pcomm; -#else - return current_proc()->p_comm; -#endif -} - -struct user_namespace init_user_ns __read_mostly; -EXPORT_SYMBOL(init_user_ns); - -void cfs_cap_raise(cfs_cap_t cap) {} -void cfs_cap_lower(cfs_cap_t cap) {} - -int cfs_cap_raised(cfs_cap_t cap) -{ - return 1; -} - -cfs_cap_t cfs_curproc_cap_pack(void) { - return -1; -} - -void cfs_curproc_cap_unpack(cfs_cap_t cap) { -} - -int cfs_capable(cfs_cap_t cap) -{ - return cap == CFS_CAP_SYS_BOOT ? is_suser(): is_suser1(); -} - -/* - * Local variables: - * c-indentation-style: "K&R" - * c-basic-offset: 8 - * tab-width: 8 - * fill-column: 80 - * scroll-step: 1 - * End: - */ diff --git a/libcfs/libcfs/darwin/darwin-debug.c b/libcfs/libcfs/darwin/darwin-debug.c deleted file mode 100644 index 9b1894a..0000000 --- a/libcfs/libcfs/darwin/darwin-debug.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -# define DEBUG_SUBSYSTEM S_LNET - -#include -#include "tracefile.h" - -void libcfs_debug_dumpstack(struct task_struct *tsk) -{ - return; -} - -void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) -{ -} - -void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) -{ - libcfs_catastrophe = 1; - CEMERG("LBUG: pid: %u thread: %#x\n", - (unsigned)current_pid(), (unsigned)current_thread()); - libcfs_debug_dumplog(); - libcfs_run_lbug_upcall(msgdata); - while (1) - schedule(); - - /* panic("lbug_with_loc(%s, %s, %d)", file, func, line) */ -} - -#if ENTRY_NESTING_SUPPORT - -static inline struct cfs_debug_data *__current_cdd(void) -{ - struct cfs_debug_data *cdd; - - cdd = (struct cfs_debug_data *)current_uthread()->uu_nlminfo; - if (cdd != NULL && - cdd->magic1 == CDD_MAGIC1 && cdd->magic2 == CDD_MAGIC2 && - cdd->nesting_level < 1000) - return cdd; - else - return NULL; -} - -static inline void __current_cdd_set(struct cfs_debug_data *cdd) -{ - current_uthread()->uu_nlminfo = (void *)cdd; -} - -void __entry_nesting(struct cfs_debug_data *child) -{ - struct cfs_debug_data *parent; - - parent = __current_cdd(); - if (parent != NULL) { - child->parent = parent; - child->nesting_level = parent->nesting_level + 1; - } - __current_cdd_set(child); -} - -void __exit_nesting(struct cfs_debug_data *child) -{ - __current_cdd_set(child->parent); -} - -unsigned int __current_nesting_level(void) -{ - struct cfs_debug_data *cdd; - - cdd = __current_cdd(); - if (cdd != NULL) - return cdd->nesting_level; - else - return 0; -} -/* ENTRY_NESTING_SUPPORT */ -#endif diff --git a/libcfs/libcfs/darwin/darwin-fs.c b/libcfs/libcfs/darwin/darwin-fs.c deleted file mode 100644 index 09b103b..0000000 --- a/libcfs/libcfs/darwin/darwin-fs.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-fs.c - * - * Darwin porting library - * Make things easy to port - * - * Author: Phil Schwan - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LNET - -#include - -/* - * Kernel APIs for file system in xnu - * - * Public functions - */ - -#ifdef __DARWIN8__ -#include - -extern int vn_rdwr(enum uio_rw, vnode_t, caddr_t, int, off_t, enum uio_seg, int, kauth_cred_t, int *, proc_t); - -/* vnode_size() is not exported */ -static errno_t -vnode_size(vnode_t vp, off_t *sizep, vfs_context_t ctx) -{ - struct vnode_attr va; - int error; - - VATTR_INIT(&va); - VATTR_WANTED(&va, va_data_size); - error = vnode_getattr(vp, &va, ctx); - if (!error) - *sizep = va.va_data_size; - return(error); -} - -/* - * XXX Liang: - * - * kern_file_*() are not safe for multi-threads now, - * however, we need them only for tracefiled, so it's - * not so important to implement for MT. - */ -int -kern_file_size(struct cfs_kern_file *fp, off_t *psize) -{ - int error; - off_t size; - - error = vnode_size(fp->f_vp, &size, fp->f_ctxt); - if (error) - return error; - - if (psize) - *psize = size; - return 0; -} - -struct cfs_kern_file * -kern_file_open(const char *filename, int uflags, int mode) -{ - struct cfs_kern_file *fp; - vnode_t vp; - int error; - - fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file), - M_TEMP, M_WAITOK); - if (fp == NULL) - return ERR_PTR(-ENOMEM); - - fp->f_flags = FFLAGS(uflags); - fp->f_ctxt = vfs_context_create(NULL); - - error = vnode_open(filename, fp->f_flags, mode, 0, &vp, fp->f_ctxt); - if (error != 0) { - _FREE(fp, M_TEMP); - return ERR_PTR(-error); - } else { - fp->f_vp = vp; - } - - return fp; -} - -int -kern_file_close(struct cfs_kern_file *fp) -{ - vnode_close(fp->f_vp, fp->f_flags, fp->f_ctxt); - vfs_context_rele(fp->f_ctxt); - _FREE(fp, M_TEMP); - - return 0; -} - -int -kern_file_read(struct cfs_kern_file *fp, void *buf, size_t nbytes, loff_t *pos) -{ - struct proc *p = current_proc(); - int resid; - int error; - - assert(buf != NULL); - assert(fp != NULL && fp->f_vp != NULL); - - error = vn_rdwr(UIO_READ, fp->f_vp, buf, nbytes, *pos, - UIO_SYSSPACE32, 0, vfs_context_ucred(fp->f_ctxt), &resid, p); - if ((error) || (nbytes == resid)) { - if (!error) - error = -EINVAL; - return error; - } - *pos += nbytes - resid; - - return (int)(nbytes - resid); -} - -int -kern_file_write(struct cfs_kern_file *fp, void *buf, size_t nbytes, loff_t *pos) -{ - struct proc *p = current_proc(); - int resid; - int error; - - assert(buf != NULL); - assert(fp != NULL && fp->f_vp != NULL); - - error = vn_rdwr(UIO_WRITE, fp->f_vp, buf, nbytes, *pos, - UIO_SYSSPACE32, 0, vfs_context_ucred(fp->f_ctxt), &resid, p); - if ((error) || (nbytes == resid)) { - if (!error) - error = -EINVAL; - return error; - } - *pos += nbytes - resid; - - return (int)(nbytes - resid); - -} - -int -kern_file_sync (struct cfs_kern_file *fp) -{ - return VNOP_FSYNC(fp->f_vp, MNT_WAIT, fp->f_ctxt); -} - -#else /* !__DARWIN8__ */ - -int -kern_file_size(struct file *fp, off_t *size) -{ - struct vnode *vp = (struct vnode *)fp->f_data; - struct stat sb; - int rc; - - rc = vn_stat(vp, &sb, current_proc()); - if (rc) { - *size = 0; - return rc; - } - *size = sb.st_size; - return 0; -} - -struct file * -kern_file_open(const char *filename, int flags, int mode) -{ - struct nameidata nd; - struct file *fp; - register struct vnode *vp; - int rc; - extern struct fileops vnops; - extern int nfiles; - CFS_DECL_CONE_DATA; - - CFS_CONE_IN; - nfiles++; - MALLOC_ZONE(fp, struct file *, sizeof(file_t), M_FILE, M_WAITOK|M_ZERO); - bzero(fp, sizeof(*fp)); - fp->f_count = 1; - LIST_CIRCLE(fp, f_list); - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)filename, current_proc()); - if ((rc = vn_open(&nd, flags, mode)) != 0){ - printf("filp_open failed at (%d)\n", rc); - FREE_ZONE(fp, sizeof(*fp), M_FILE); - CFS_CONE_EX; - return ERR_PTR(rc); - } - vp = nd.ni_vp; - fp->f_flag = flags & FMASK; - fp->f_type = DTYPE_VNODE; - fp->f_ops = &vnops; - fp->f_data = (caddr_t)vp; - fp->f_cred = current_proc()->p_ucred; - /* - * Hold cred to increase reference - */ - crhold(fp->f_cred); - /* - * vnode is locked inside vn_open for lookup, - * we should release the lock before return - */ - VOP_UNLOCK(vp, 0, current_proc()); - CFS_CONE_EX; - - return fp; -} - -static int -frele_internal(struct file *fp) -{ - if (fp->f_count == (short)0xffff) - panic("frele of lustre: stale"); - if (--fp->f_count < 0) - panic("frele of lustre: count < 0"); - return ((int)fp->f_count); -} - -int -kern_file_close(struct file *fp) -{ - struct vnode *vp; - CFS_DECL_CONE_DATA; - - if (fp == NULL) - return 0; - - CFS_CONE_IN; - if (frele_internal(fp) > 0) - goto out; - vp = (struct vnode *)fp->f_data; - (void )vn_close(vp, fp->f_flag, fp->f_cred, current_proc()); - /* - * ffree(fp); - * Dont use ffree to release fp!!!! - * ffree will call LIST_REMOVE(fp), - * but fp is not in any list, this will - * cause kernel panic - */ - struct ucred *cred; - cred = fp->f_cred; - if (cred != NOCRED) { - fp->f_cred = NOCRED; - crfree(cred); - } - extern int nfiles; - nfiles--; - memset(fp, 0xff, sizeof *fp); - fp->f_count = (short)0xffff; - FREE_ZONE(fp, sizeof *fp, M_FILE); -out: - CFS_CONE_EX; - return 0; -} - -extern void bwillwrite(void); - -/* - * Write buffer to filp inside kernel - */ -int -kern_file_write(struct file *fp, void *buf, size_t nbyte, loff_t *pos) -{ - struct uio auio; - struct iovec aiov; - struct proc *p = current_proc(); - long cnt, error = 0; - int flags = 0; - CFS_DECL_CONE_DATA; - - aiov.iov_base = (void *)(uintptr_t)buf; - aiov.iov_len = nbyte; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - if (pos != NULL) { - auio.uio_offset = *pos; - /* - * Liang: If don't set FOF_OFFSET, vn_write() - * will use fp->f_offset as the the real offset. - * Same in vn_read() - */ - flags |= FOF_OFFSET; - } else - auio.uio_offset = (off_t)-1; - if (nbyte > INT_MAX) - return (EINVAL); - auio.uio_resid = nbyte; - auio.uio_rw = UIO_WRITE; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - - cnt = nbyte; - CFS_CONE_IN; - if (fp->f_type == DTYPE_VNODE) - bwillwrite(); /* empty stuff now */ - if ((error = fo_write(fp, &auio, fp->f_cred, flags, p))) { - if (auio.uio_resid != cnt && (error == ERESTART ||\ - error == EINTR || error == EWOULDBLOCK)) - error = 0; - /* The socket layer handles SIGPIPE */ - if (error == EPIPE && fp->f_type != DTYPE_SOCKET) - psignal(p, SIGPIPE); - } - CFS_CONE_EX; - if (error != 0) - cnt = -error; - else - cnt -= auio.uio_resid; - if (pos != NULL) - *pos += cnt; - return cnt; -} - -/* - * Read from filp inside kernel - */ -int -kern_file_read(struct file *fp, void *buf, size_t nbyte, loff_t *pos) -{ - struct uio auio; - struct iovec aiov; - struct proc *p = current_proc(); - long cnt, error = 0; - int flags = 0; - CFS_DECL_CONE_DATA; - - aiov.iov_base = (caddr_t)buf; - aiov.iov_len = nbyte; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - if (pos != NULL) { - auio.uio_offset = *pos; - flags |= FOF_OFFSET; - } else - auio.uio_offset = (off_t)-1; - if (nbyte > INT_MAX) - return (EINVAL); - auio.uio_resid = nbyte; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - - cnt = nbyte; - CFS_CONE_IN; - if ((error = fo_read(fp, &auio, fp->f_cred, flags, p)) != 0) { - if (auio.uio_resid != cnt && (error == ERESTART || - error == EINTR || error == EWOULDBLOCK)) - error = 0; - } - CFS_CONE_EX; - if (error != 0) - cnt = -error; - else - cnt -= auio.uio_resid; - if (pos != NULL) - *pos += cnt; - - return cnt; -} - -int -kern_file_sync(struct file *fp) -{ - struct vnode *vp = (struct vnode *)fp->f_data; - struct proc *p = current_proc(); - int error = 0; - CFS_DECL_CONE_DATA; - - CFS_CONE_IN; - if (fref(fp) == -1) { - CFS_CONE_EX; - return (-EBADF); - } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p); - VOP_UNLOCK(vp, 0, p); - frele(fp); - CFS_CONE_EX; - - return error; -} - -#endif /* !__DARWIN8__ */ - -struct posix_acl *posix_acl_alloc(int count, int flags) -{ - static struct posix_acl acl; - return &acl; -} diff --git a/libcfs/libcfs/darwin/darwin-internal.h b/libcfs/libcfs/darwin/darwin-internal.h deleted file mode 100644 index 7d62514..0000000 --- a/libcfs/libcfs/darwin/darwin-internal.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LIBCFS_DARWIN_INTERNAL_H__ -#define __LIBCFS_DARWIN_INTERNAL_H__ - -#include -#include -#include -#include -#include - -int cfs_sysctl_isvalid(void); -struct sysctl_oid *cfs_alloc_sysctl_node(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, int (*handler) SYSCTL_HANDLER_ARGS); -struct sysctl_oid *cfs_alloc_sysctl_int(struct sysctl_oid_list *parent, int n, - const char *name, int *ptr, int val); -struct sysctl_oid * cfs_alloc_sysctl_long(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, int *ptr, int val); -struct sysctl_oid * cfs_alloc_sysctl_string(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, char *ptr, int len); -struct sysctl_oid * cfs_alloc_sysctl_struct(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, void *ptr, int size); - -#endif diff --git a/libcfs/libcfs/darwin/darwin-mem.c b/libcfs/libcfs/darwin/darwin-mem.c deleted file mode 100644 index 4a30bec..0000000 --- a/libcfs/libcfs/darwin/darwin-mem.c +++ /dev/null @@ -1,495 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-mem.c - * - * Author: Liang Zhen - * Author: Nikita Danilov - */ -#define DEBUG_SUBSYSTEM S_LNET - -#include -#include -#include - -#include -#include "darwin-internal.h" - -#if CFS_INDIVIDUAL_ZONE -extern zone_t zinit( vm_size_t, vm_size_t, vm_size_t, const char *); -extern void * zalloc(zone_t zone); -extern void *zalloc_noblock(zone_t zone); -extern void zfree(zone_t zone, void *addr); - -struct cfs_zone_nob { - struct list_head *z_nob; /* Pointer to z_link */ - struct list_head z_link; /* Do NOT access it directly */ -}; - -static struct cfs_zone_nob cfs_zone_nob; -static spinlock_t cfs_zone_guard; - -struct kmem_cache *mem_cache_find(const char *name, size_t objsize) -{ - struct kmem_cache *walker = NULL; - - LASSERT(cfs_zone_nob.z_nob != NULL); - - spin_lock(&cfs_zone_guard); - list_for_each_entry(walker, cfs_zone_nob.z_nob, mc_link) { - if (!strcmp(walker->mc_name, name) && \ - walker->mc_size == objsize) - break; - } - spin_unlock(&cfs_zone_guard); - - return walker; -} - -/* - * our wrapper around kern/zalloc.c:zinit() - * - * Creates copy of name and calls zinit() to do real work. Needed because zone - * survives kext unloading, so that @name cannot be just static string - * embedded into kext image. - */ -struct kmem_cache *mem_cache_create(vm_size_t objsize, const char *name) -{ - struct kmem_cache *mc = NULL; - char *cname; - - MALLOC(mc, struct kmem_cache *, sizeof(struct kmem_cache), M_TEMP, M_WAITOK|M_ZERO); - if (mc == NULL){ - CERROR("cfs_mem_cache created fail!\n"); - return NULL; - } - - cname = _MALLOC(strlen(name) + 1, M_TEMP, M_WAITOK); - LASSERT(cname != NULL); - mc->mc_cache = zinit(objsize, (KMEM_MAX_ZONE * objsize), 0, strcpy(cname, name)); - mc->mc_size = objsize; - INIT_LIST_HEAD(&mc->mc_link); - strncpy(mc->mc_name, name, 1 + strlen(name)); - return mc; -} - -void mem_cache_destroy(struct kmem_cache *mc) -{ - /* - * zone can NOT be destroyed after creating, - * so just keep it in list. - * - * We will not lost a zone after we unload - * libcfs, it can be found by from libcfs.zone - */ - return; -} - -#define mem_cache_alloc(mc) zalloc((mc)->mc_cache) -#ifdef __DARWIN8__ -# define mem_cache_alloc_nb(mc) zalloc((mc)->mc_cache) -#else -/* XXX Liang: Tiger doesn't export zalloc_noblock() */ -# define mem_cache_alloc_nb(mc) zalloc_noblock((mc)->mc_cache) -#endif -#define mem_cache_free(mc, p) zfree((mc)->mc_cache, p) - -#else /* !CFS_INDIVIDUAL_ZONE */ - -struct kmem_cache * -mem_cache_find(const char *name, size_t objsize) -{ - return NULL; -} - -struct kmem_cache *mem_cache_create(vm_size_t size, const char *name) -{ - struct kmem_cache *mc = NULL; - - MALLOC(mc, struct kmem_cache *, sizeof(struct kmem_cache), M_TEMP, M_WAITOK|M_ZERO); - if (mc == NULL){ - CERROR("cfs_mem_cache created fail!\n"); - return NULL; - } - mc->mc_cache = OSMalloc_Tagalloc(name, OSMT_DEFAULT); - mc->mc_size = size; - return mc; -} - -void mem_cache_destroy(struct kmem_cache *mc) -{ - OSMalloc_Tagfree(mc->mc_cache); - FREE(mc, M_TEMP); -} - -#define mem_cache_alloc(mc) OSMalloc((mc)->mc_size, (mc)->mc_cache) -#define mem_cache_alloc_nb(mc) OSMalloc_noblock((mc)->mc_size, (mc)->mc_cache) -#define mem_cache_free(mc, p) OSFree(p, (mc)->mc_size, (mc)->mc_cache) - -#endif /* !CFS_INDIVIDUAL_ZONE */ - -struct kmem_cache * -kmem_cache_create(const char *name, size_t objsize, size_t off, - unsigned long arg1, void *ctro) -{ - struct kmem_cache *mc; - - mc = mem_cache_find(name, objsize); - if (mc) - return mc; - mc = mem_cache_create(objsize, name); - return mc; -} - -kmem_cache_destroy (struct kmem_cache *cachep) -{ - mem_cache_destroy(cachep); - return 0; -} - -void *kmem_cache_alloc (struct kmem_cache *cachep, int flags) -{ - void *result; - - /* zalloc_canblock() is not exported... Emulate it. */ - if (flags & GFP_ATOMIC) { - result = (void *)mem_cache_alloc_nb(cachep); - } else { - LASSERT(get_preemption_level() == 0); - result = (void *)mem_cache_alloc(cachep); - } - if (result != NULL && (flags & __GFP_ZERO)) - memset(result, 0, cachep->mc_size); - - return result; -} - -void kmem_cache_free (struct kmem_cache *cachep, void *objp) -{ - mem_cache_free(cachep, objp); -} - -/* --------------------------------------------------------------------------- - * Page operations - * - * --------------------------------------------------------------------------- */ - -/* - * "Raw" pages - */ - -static unsigned int raw_pages; -static struct kmem_cache *raw_page_cache; - -static struct xnu_page_ops raw_page_ops; -static struct xnu_page_ops *page_ops[XNU_PAGE_NTYPES] = { - [XNU_PAGE_RAW] = &raw_page_ops -}; - -#if defined(LIBCFS_DEBUG) -static int page_type_is_valid(struct page *page) -{ - LASSERT(page != NULL); - return 0 <= page->type && page->type < XNU_PAGE_NTYPES; -} - -static int page_is_raw(struct page *page) -{ - return page->type == XNU_PAGE_RAW; -} -#endif - -static struct xnu_raw_page *as_raw(struct page *page) -{ - LASSERT(page_is_raw(page)); - return list_entry(page, struct xnu_raw_page, header); -} - -static void *raw_page_address(struct page *pg) -{ - return (void *)as_raw(pg)->virtual; -} - -static void *raw_page_map(struct page *pg) -{ - return (void *)as_raw(pg)->virtual; -} - -static void raw_page_unmap(struct page *pg) -{ -} - -static struct xnu_page_ops raw_page_ops = { - .page_map = raw_page_map, - .page_unmap = raw_page_unmap, - .page_address = raw_page_address -}; - -extern int get_preemption_level(void); - -struct list_head page_death_row; -spinlock_t page_death_row_phylax; - -static void raw_page_finish(struct xnu_raw_page *pg) -{ - --raw_pages; - if (pg->virtual != NULL) - kmem_cache_free(raw_page_cache, pg->virtual); - kfree(pg); -} - -void raw_page_death_row_clean(void) -{ - struct xnu_raw_page *pg; - - spin_lock(&page_death_row_phylax); - while (!list_empty(&page_death_row)) { - pg = container_of(page_death_row.next, - struct xnu_raw_page, link); - list_del(&pg->link); - spin_unlock(&page_death_row_phylax); - raw_page_finish(pg); - spin_lock(&page_death_row_phylax); - } - spin_unlock(&page_death_row_phylax); -} - -/* Free a "page" */ -void free_raw_page(struct xnu_raw_page *pg) -{ - if (!atomic_dec_and_test(&pg->count)) - return; - /* - * kmem_free()->vm_map_remove()->vm_map_delete()->lock_write() may - * block. (raw_page_done()->upl_abort() can block too) On the other - * hand, __free_page() may be called in non-blockable context. To - * work around this, park pages on global list when cannot block. - */ - if (get_preemption_level() > 0) { - spin_lock(&page_death_row_phylax); - list_add(&pg->link, &page_death_row); - spin_unlock(&page_death_row_phylax); - } else { - raw_page_finish(pg); - raw_page_death_row_clean(); - } -} - -struct page *alloc_page(u_int32_t flags) -{ - struct xnu_raw_page *page; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - page = kmalloc(sizeof *page, flags); - if (page != NULL) { - page->virtual = kmem_cache_alloc(raw_page_cache, flags); - if (page->virtual != NULL) { - ++raw_pages; - page->header.type = XNU_PAGE_RAW; - atomic_set(&page->count, 1); - } else { - kfree(page); - page = NULL; - } - } - return page != NULL ? &page->header : NULL; -} - -void __free_page(struct page *pages) -{ - free_raw_page(as_raw(pages)); -} - -void get_page(struct page *p) -{ - atomic_inc(&as_raw(p)->count); -} - -int cfs_put_page_testzero(struct page *p) -{ - return atomic_dec_and_test(&as_raw(p)->count); -} - -int page_count(struct page *p) -{ - return atomic_read(&as_raw(p)->count); -} - -/* - * Generic page operations - */ - -void *page_address(struct page *pg) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - LASSERT(page_type_is_valid(pg)); - return page_ops[pg->type]->page_address(pg); -} - -void *kmap(struct page *pg) -{ - LASSERT(page_type_is_valid(pg)); - return page_ops[pg->type]->page_map(pg); -} - -void kunmap(struct page *pg) -{ - LASSERT(page_type_is_valid(pg)); - page_ops[pg->type]->page_unmap(pg); -} - -void xnu_page_ops_register(int type, struct xnu_page_ops *ops) -{ - LASSERT(0 <= type && type < XNU_PAGE_NTYPES); - LASSERT(ops != NULL); - LASSERT(page_ops[type] == NULL); - - page_ops[type] = ops; -} - -void xnu_page_ops_unregister(int type) -{ - LASSERT(0 <= type && type < XNU_PAGE_NTYPES); - LASSERT(page_ops[type] != NULL); - - page_ops[type] = NULL; -} - -/* - * Portable memory allocator API - */ -#ifdef HAVE_GET_PREEMPTION_LEVEL -extern int get_preemption_level(void); -#else -#define get_preemption_level() (0) -#endif - -void *kmalloc(size_t nr_bytes, u_int32_t flags) -{ - int mflags; - - mflags = 0; - if (flags & GFP_ATOMIC) { - mflags |= M_NOWAIT; - } else { - LASSERT(get_preemption_level() == 0); - mflags |= M_WAITOK; - } - - if (flags & __GFP_ZERO) - mflags |= M_ZERO; - - return _MALLOC(nr_bytes, M_TEMP, mflags); -} - -void kfree(void *addr) -{ - return _FREE(addr, M_TEMP); -} - -void *vmalloc(size_t nr_bytes) -{ - LASSERT(get_preemption_level() == 0); - return _MALLOC(nr_bytes, M_TEMP, M_WAITOK); -} - -void vfree(void *addr) -{ - LASSERT(get_preemption_level() == 0); - return _FREE(addr, M_TEMP); -} - -/* - * Lookup cfs_zone_nob by sysctl.zone, if it cannot be - * found (first load of * libcfs since boot), allocate - * sysctl libcfs.zone. - */ -int cfs_mem_init(void) -{ -#if CFS_INDIVIDUAL_ZONE - int rc; - size_t len; - - len = sizeof(struct cfs_zone_nob); - rc = sysctlbyname("libcfs.zone", - (void *)&cfs_zone_nob, &len, NULL, 0); - if (rc == ENOENT) { - /* zone_nob is not register in libcfs_sysctl */ - struct cfs_zone_nob *nob; - struct sysctl_oid *oid; - - assert(cfs_sysctl_isvalid()); - - nob = _MALLOC(sizeof(struct cfs_zone_nob), - M_TEMP, M_WAITOK | M_ZERO); - INIT_LIST_HEAD(&nob->z_link); - nob->z_nob = &nob->z_link; - oid = cfs_alloc_sysctl_struct(NULL, OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN, - "zone", nob, sizeof(struct cfs_zone_nob)); - if (oid == NULL) { - _FREE(nob, M_TEMP); - return -ENOMEM; - } - sysctl_register_oid(oid); - - cfs_zone_nob.z_nob = nob->z_nob; - } - spin_lock_init(&cfs_zone_guard); -#endif - INIT_LIST_HEAD(&page_death_row); - spin_lock_init(&page_death_row_phylax); - raw_page_cache = kmem_cache_create("raw-page", PAGE_CACHE_SIZE, - 0, 0, NULL); - return 0; -} - -void cfs_mem_fini(void) -{ - raw_page_death_row_clean(); - spin_lock_done(&page_death_row_phylax); - kmem_cache_destroy(raw_page_cache); - -#if CFS_INDIVIDUAL_ZONE - cfs_zone_nob.z_nob = NULL; - spin_lock_done(&cfs_zone_guard); -#endif -} diff --git a/libcfs/libcfs/darwin/darwin-module.c b/libcfs/libcfs/darwin/darwin-module.c deleted file mode 100644 index deea373..0000000 --- a/libcfs/libcfs/darwin/darwin-module.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LNET -#include - -int libcfs_ioctl_getdata(char *buf, char *end, void *arg) -{ - struct libcfs_ioctl_hdr *hdr; - struct libcfs_ioctl_data *data; - int err = 0; - ENTRY; - - hdr = (struct libcfs_ioctl_hdr *)buf; - data = (struct libcfs_ioctl_data *)buf; - /* libcfs_ioctl_data has been copied in by ioctl of osx */ - memcpy(buf, arg, sizeof(struct libcfs_ioctl_data)); - - if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { - CERROR("LIBCFS: version mismatch kernel vs application\n"); - RETURN(-EINVAL); - } - - if (hdr->ioc_len + buf >= end) { - CERROR("LIBCFS: user buffer exceeds kernel buffer\n"); - RETURN(-EINVAL); - } - - if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) { - CERROR("LIBCFS: user buffer too small for ioctl\n"); - RETURN(-EINVAL); - } - buf += size_round(sizeof(*data)); - - if (data->ioc_inllen1) { - err = copy_from_user(buf, data->ioc_inlbuf1, size_round(data->ioc_inllen1)); - if (err) - RETURN(err); - data->ioc_inlbuf1 = buf; - buf += size_round(data->ioc_inllen1); - } - - if (data->ioc_inllen2) { - copy_from_user(buf, data->ioc_inlbuf2, size_round(data->ioc_inllen2)); - if (err) - RETURN(err); - data->ioc_inlbuf2 = buf; - } - - RETURN(err); -} - -int libcfs_ioctl_popdata(void *arg, void *data, int size) -{ - /* - * system call will copy out ioctl arg to user space - */ - memcpy(arg, data, size); - return 0; -} - -extern struct cfs_psdev_ops libcfs_psdev_ops; -struct libcfs_device_userstate *mdev_state[16]; - -static int -libcfs_psdev_open(dev_t dev, int flags, int devtype, struct proc *p) -{ - struct libcfs_device_userstate *mstat = NULL; - int rc = 0; - int devid; - devid = minor(dev); - - if (devid > 16) return (ENXIO); - - if (libcfs_psdev_ops.p_open != NULL) - rc = -libcfs_psdev_ops.p_open(0, &mstat); - else - rc = EPERM; - if (rc == 0) - mdev_state[devid] = mstat; - return rc; -} - -static int -libcfs_psdev_close(dev_t dev, int flags, int mode, struct proc *p) -{ - int devid; - devid = minor(dev); - int rc = 0; - - if (devid > 16) return (ENXIO); - - if (libcfs_psdev_ops.p_close != NULL) - rc = -libcfs_psdev_ops.p_close(0, mdev_state[devid]); - else - rc = EPERM; - if (rc == 0) - mdev_state[devid] = NULL; - return rc; -} - -static int -libcfs_ioctl (dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) -{ - int rc = 0; - struct cfs_psdev_file pfile; - int devid; - devid = minor(dev); - - if (devid > 16) return (ENXIO); - - if (!is_suser()) - return (EPERM); - - pfile.off = 0; - pfile.private_data = mdev_state[devid]; - - if (libcfs_psdev_ops.p_ioctl != NULL) - rc = -libcfs_psdev_ops.p_ioctl(&pfile, cmd, (void *)arg); - else - rc = EPERM; - return rc; -} - -static struct cdevsw libcfs_devsw = -{ - .d_open = libcfs_psdev_open, - .d_close = libcfs_psdev_close, - .d_read = eno_rdwrt, - .d_write = eno_rdwrt, - .d_ioctl = libcfs_ioctl, - .d_stop = eno_stop, - .d_reset = eno_reset, - .d_ttys = NULL, - .d_select = eno_select, - .d_mmap = eno_mmap, - .d_strategy = eno_strat, - .d_getc = eno_getc, - .d_putc = eno_putc, - .d_type = 0 -}; - -struct miscdevice libcfs_dev = { - -1, - NULL, - "lnet", - &libcfs_devsw, - NULL -}; - -extern spinlock_t trace_cpu_serializer; -extern void cfs_sync_init(void); -extern void cfs_sync_fini(void); -extern int cfs_sysctl_init(void); -extern void cfs_sysctl_fini(void); -extern int cfs_mem_init(void); -extern int cfs_mem_fini(void); -extern void raw_page_death_row_clean(void); -extern void cfs_thread_agent_init(void); -extern void cfs_thread_agent_fini(void); -extern void cfs_symbol_init(void); -extern void cfs_symbol_fini(void); - -int libcfs_arch_init(void) -{ - cfs_sync_init(); - cfs_sysctl_init(); - cfs_mem_init(); - cfs_thread_agent_init(); - cfs_symbol_init(); - - spin_lock_init(&trace_cpu_serializer); - - return 0; -} - -void libcfs_arch_cleanup(void) -{ - spin_lock_done(&trace_cpu_serializer); - - cfs_symbol_fini(); - cfs_thread_agent_fini(); - cfs_mem_fini(); - cfs_sysctl_fini(); - cfs_sync_fini(); -} diff --git a/libcfs/libcfs/darwin/darwin-prim.c b/libcfs/libcfs/darwin/darwin-prim.c deleted file mode 100644 index 22ff5a9..0000000 --- a/libcfs/libcfs/darwin/darwin-prim.c +++ /dev/null @@ -1,600 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-prim.c - * - * Darwin porting library - * Make things easy to port - * - * Author: Phil Schwan - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * cfs pseudo device, actually pseudo char device in darwin - */ -#define KLNET_MAJOR -1 - -kern_return_t misc_register(struct miscdevice *dev) { - dev->index = cdevsw_add(KLNET_MAJOR, dev->devsw); - if (dev->index < 0) { - printf("libcfs_init: failed to allocate a major number!\n"); - return KERN_FAILURE; - } - dev->handle = devfs_make_node(makedev (dev->index, 0), - DEVFS_CHAR, UID_ROOT, - GID_WHEEL, 0666, (char *)dev->name, 0); - return KERN_SUCCESS; -} - -kern_return_t misc_deregister(struct miscdevice *dev) { - devfs_remove(dev->handle); - cdevsw_remove(dev->index, dev->devsw); - return KERN_SUCCESS; -} - -/* - * KPortal symbol register / unregister support - */ -struct rw_semaphore cfs_symbol_lock; -struct list_head cfs_symbol_list; - -void * -cfs_symbol_get(const char *name) -{ - struct list_head *walker; - struct cfs_symbol *sym = NULL; - - down_read(&cfs_symbol_lock); - list_for_each(walker, &cfs_symbol_list) { - sym = list_entry (walker, struct cfs_symbol, sym_list); - if (!strcmp(sym->name, name)) { - sym->ref ++; - break; - } - } - up_read(&cfs_symbol_lock); - if (sym != NULL) - return sym->value; - return NULL; -} - -kern_return_t -cfs_symbol_put(const char *name) -{ - struct list_head *walker; - struct cfs_symbol *sym = NULL; - - down_read(&cfs_symbol_lock); - list_for_each(walker, &cfs_symbol_list) { - sym = list_entry (walker, struct cfs_symbol, sym_list); - if (!strcmp(sym->name, name)) { - sym->ref --; - LASSERT(sym->ref >= 0); - break; - } - } - up_read(&cfs_symbol_lock); - LASSERT(sym != NULL); - - return 0; -} - -kern_return_t -cfs_symbol_register(const char *name, const void *value) -{ - struct list_head *walker; - struct cfs_symbol *sym = NULL; - struct cfs_symbol *new = NULL; - - MALLOC(new, struct cfs_symbol *, sizeof(struct cfs_symbol), M_TEMP, M_WAITOK|M_ZERO); - strncpy(new->name, name, CFS_SYMBOL_LEN); - new->value = (void *)value; - new->ref = 0; - INIT_LIST_HEAD(&new->sym_list); - - down_write(&cfs_symbol_lock); - list_for_each(walker, &cfs_symbol_list) { - sym = list_entry (walker, struct cfs_symbol, sym_list); - if (!strcmp(sym->name, name)) { - up_write(&cfs_symbol_lock); - FREE(new, M_TEMP); - return KERN_NAME_EXISTS; - } - } - list_add_tail(&new->sym_list, &cfs_symbol_list); - up_write(&cfs_symbol_lock); - return KERN_SUCCESS; -} - -kern_return_t -cfs_symbol_unregister(const char *name) -{ - struct list_head *walker; - struct list_head *nxt; - struct cfs_symbol *sym = NULL; - - down_write(&cfs_symbol_lock); - list_for_each_safe(walker, nxt, &cfs_symbol_list) { - sym = list_entry(walker, struct cfs_symbol, sym_list); - if (!strcmp(sym->name, name)) { - LASSERT(sym->ref == 0); - list_del(&sym->sym_list); - FREE(sym, M_TEMP); - break; - } - } - up_write(&cfs_symbol_lock); - - return KERN_SUCCESS; -} - -void -cfs_symbol_init() -{ - INIT_LIST_HEAD(&cfs_symbol_list); - init_rwsem(&cfs_symbol_lock); -} - -void -cfs_symbol_fini() -{ - struct list_head *walker; - struct cfs_symbol *sym = NULL; - - down_write(&cfs_symbol_lock); - list_for_each(walker, &cfs_symbol_list) { - sym = list_entry(walker, struct cfs_symbol, sym_list); - LASSERT(sym->ref == 0); - list_del(&sym->sym_list); - FREE(sym, M_TEMP); - } - up_write(&cfs_symbol_lock); - - fini_rwsem(&cfs_symbol_lock); - return; -} - -struct kernel_thread_arg -{ - spinlock_t lock; - atomic_t inuse; - cfs_thread_t func; - void *arg; -}; - -struct kernel_thread_arg cfs_thread_arg; - -#define THREAD_ARG_FREE 0 -#define THREAD_ARG_HOLD 1 -#define THREAD_ARG_RECV 2 - -#define set_targ_stat(a, v) atomic_set(&(a)->inuse, v) -#define get_targ_stat(a) atomic_read(&(a)->inuse) - -/* - * Hold the thread argument and set the status of thread_status - * to THREAD_ARG_HOLD, if the thread argument is held by other - * threads (It's THREAD_ARG_HOLD already), current-thread has to wait. - */ -#define thread_arg_hold(pta, _func, _arg) \ - do { \ - spin_lock(&(pta)->lock); \ - if (get_targ_stat(pta) == THREAD_ARG_FREE) { \ - set_targ_stat((pta), THREAD_ARG_HOLD); \ - (pta)->arg = (void *)_arg; \ - (pta)->func = _func; \ - spin_unlock(&(pta)->lock); \ - break; \ - } \ - spin_unlock(&(pta)->lock); \ - schedule(); \ - } while(1); \ - -/* - * Release the thread argument if the thread argument has been - * received by the child-thread (Status of thread_args is - * THREAD_ARG_RECV), otherwise current-thread has to wait. - * After release, the thread_args' status will be set to - * THREAD_ARG_FREE, and others can re-use the thread_args to - * create new kernel_thread. - */ -#define thread_arg_release(pta) \ - do { \ - spin_lock(&(pta)->lock); \ - if (get_targ_stat(pta) == THREAD_ARG_RECV) { \ - (pta)->arg = NULL; \ - (pta)->func = NULL; \ - set_targ_stat(pta, THREAD_ARG_FREE); \ - spin_unlock(&(pta)->lock); \ - break; \ - } \ - spin_unlock(&(pta)->lock); \ - schedule(); \ - } while(1) - -/* - * Receive thread argument (Used in child thread), set the status - * of thread_args to THREAD_ARG_RECV. - */ -#define __thread_arg_recv_fin(pta, _func, _arg, fin) \ - do { \ - spin_lock(&(pta)->lock); \ - if (get_targ_stat(pta) == THREAD_ARG_HOLD) { \ - if (fin) \ - set_targ_stat(pta, THREAD_ARG_RECV);\ - _arg = (pta)->arg; \ - _func = (pta)->func; \ - spin_unlock(&(pta)->lock); \ - break; \ - } \ - spin_unlock(&(pta)->lock); \ - schedule(); \ - } while (1); \ - -/* - * Just set the thread_args' status to THREAD_ARG_RECV - */ -#define thread_arg_fin(pta) \ - do { \ - spin_lock(&(pta)->lock); \ - assert( get_targ_stat(pta) == THREAD_ARG_HOLD); \ - set_targ_stat(pta, THREAD_ARG_RECV); \ - spin_unlock(&(pta)->lock); \ - } while(0) - -#define thread_arg_recv(pta, f, a) __thread_arg_recv_fin(pta, f, a, 1) -#define thread_arg_keep(pta, f, a) __thread_arg_recv_fin(pta, f, a, 0) - -void -cfs_thread_agent_init(void) -{ - set_targ_stat(&cfs_thread_arg, THREAD_ARG_FREE); - spin_lock_init(&cfs_thread_arg.lock); - cfs_thread_arg.arg = NULL; - cfs_thread_arg.func = NULL; -} - -void -cfs_thread_agent_fini(void) -{ - assert(get_targ_stat(&cfs_thread_arg) == THREAD_ARG_FREE); - - spin_lock_done(&cfs_thread_arg.lock); -} - -/* - * - * All requests to create kernel thread will create a new - * thread instance of cfs_thread_agent, one by one. - * cfs_thread_agent will call the caller's thread function - * with argument supplied by caller. - */ -void -cfs_thread_agent (void) -{ - cfs_thread_t func = NULL; - void *arg = NULL; - - thread_arg_recv(&cfs_thread_arg, func, arg); - /* printf("entry of thread agent (func: %08lx).\n", (void *)func); */ - assert(func != NULL); - func(arg); - /* printf("thread agent exit. (func: %08lx)\n", (void *)func); */ - (void) thread_terminate(current_thread()); -} - -extern thread_t kernel_thread(task_t task, void (*start)(void)); - -struct task_struct -kthread_run(cfs_thread_t func, void *arg, const char namefmt[], ...) -{ - int ret = 0; - thread_t th = NULL; - - thread_arg_hold(&cfs_thread_arg, func, arg); - th = kernel_thread(kernel_task, cfs_thread_agent); - thread_arg_release(&cfs_thread_arg); - if (th != THREAD_NULL) { - /* - * FIXME: change child thread name... - * current_comm() is already broken. So it is left as is... - va_list args; - va_start(args, namefmt); - snprintf(current_comm(), CFS_CURPROC_COMM_MAX, - namefmt, args); - va_end(args); - */ - } else { - ret = -1; - } - return (struct task_struct)((long)ret); -} - -/* - * XXX Liang: kexts cannot access sigmask in Darwin8. - * it's almost impossible for us to get/set signal mask - * without patching kernel. - * Should we provide these functions in xnu? - * - * These signal functions almost do nothing now, we - * need to investigate more about signal in Darwin. - */ - -extern int block_procsigmask(struct proc *p, int bit); - -sigset_t cfs_block_allsigs() -{ - sigset_t old = 0; -#ifdef __DARWIN8__ -#else - block_procsigmask(current_proc(), -1); -#endif - return old; -} - -sigset_t cfs_block_sigs(unsigned long sigs) -{ - sigset_t old = 0; -#ifdef __DARWIN8__ -#else - block_procsigmask(current_proc(), sigs); -#endif - return old; -} - -/* Block all signals except for the @sigs. It's only used in - * Linux kernel, just a dummy here. */ -sigset_t cfs_block_sigsinv(unsigned long sigs) -{ - sigset_t old = 0; - return old; -} - -void cfs_restore_sigs(sigset_t old) -{ -} - -int cfs_signal_pending(void) - -{ -#ifdef __DARWIN8__ - extern int thread_issignal(proc_t, thread_t, sigset_t); - return thread_issignal(current_proc(), current_thread(), (sigset_t)-1); -#else - return SHOULDissignal(current_proc(), current_uthread()) -#endif -} - -void cfs_clear_sigpending(void) -{ -#ifdef __DARWIN8__ -#else - clear_procsiglist(current_proc(), -1); -#endif -} - -#ifdef __DARWIN8__ - -#else /* !__DARWIN8__ */ - -void lustre_cone_in(boolean_t *state, funnel_t **cone) -{ - *cone = thread_funnel_get(); - if (*cone == network_flock) - thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL); - else if (*cone == NULL) - *state = thread_funnel_set(kernel_flock, TRUE); -} - -void lustre_cone_ex(boolean_t state, funnel_t *cone) -{ - if (cone == network_flock) - thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL); - else if (cone == NULL) - (void) thread_funnel_set(kernel_flock, state); -} - -void lustre_net_in(boolean_t *state, funnel_t **cone) -{ - *cone = thread_funnel_get(); - if (*cone == kernel_flock) - thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL); - else if (*cone == NULL) - *state = thread_funnel_set(network_flock, TRUE); -} - -void lustre_net_ex(boolean_t state, funnel_t *cone) -{ - if (cone == kernel_flock) - thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL); - else if (cone == NULL) - (void) thread_funnel_set(network_flock, state); -} -#endif /* !__DARWIN8__ */ - -void init_waitqueue_head(struct cfs_waitq *waitq) -{ - ksleep_chan_init(&waitq->wq_ksleep_chan); -} - -void init_waitqueue_entry_current(struct cfs_waitlink *link) -{ - ksleep_link_init(&link->wl_ksleep_link); -} - -void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link) -{ - link->wl_waitq = waitq; - ksleep_add(&waitq->wq_ksleep_chan, &link->wl_ksleep_link); -} - -void add_wait_queue_exclusive(struct cfs_waitq *waitq, - struct cfs_waitlink *link) -{ - link->wl_waitq = waitq; - link->wl_ksleep_link.flags |= KSLEEP_EXCLUSIVE; - ksleep_add(&waitq->wq_ksleep_chan, &link->wl_ksleep_link); -} - -void remove_wait_queue(struct cfs_waitq *waitq, - struct cfs_waitlink *link) -{ - ksleep_del(&waitq->wq_ksleep_chan, &link->wl_ksleep_link); -} - -int waitqueue_active(struct cfs_waitq *waitq) -{ - return (1); -} - -void wake_up(struct cfs_waitq *waitq) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - ksleep_wake(&waitq->wq_ksleep_chan); -} - -void wake_up_nr(struct cfs_waitq *waitq, int nr) -{ - ksleep_wake_nr(&waitq->wq_ksleep_chan, nr); -} - -void wake_up_all(struct cfs_waitq *waitq) -{ - ksleep_wake_all(&waitq->wq_ksleep_chan); -} - -void waitq_wait(struct cfs_waitlink *link, long state) -{ - ksleep_wait(&link->wl_waitq->wq_ksleep_chan, state); -} - -cfs_duration_t waitq_timedwait(struct cfs_waitlink *link, - long state, - cfs_duration_t timeout) -{ - return ksleep_timedwait(&link->wl_waitq->wq_ksleep_chan, - state, timeout); -} - -typedef void (*ktimer_func_t)(void *); -void cfs_timer_init(struct timer_list *t, void (* func)(unsigned long), void *arg) -{ - ktimer_init(&t->t, (ktimer_func_t)func, arg); -} - -void cfs_timer_done(struct cfs_timer *t) -{ - ktimer_done(&t->t); -} - -void cfs_timer_arm(struct cfs_timer *t, cfs_time_t deadline) -{ - ktimer_arm(&t->t, deadline); -} - -void cfs_timer_disarm(struct cfs_timer *t) -{ - ktimer_disarm(&t->t); -} - -int cfs_timer_is_armed(struct cfs_timer *t) -{ - return ktimer_is_armed(&t->t); -} - -cfs_time_t cfs_timer_deadline(struct cfs_timer *t) -{ - return ktimer_deadline(&t->t); -} - -void cfs_enter_debugger(void) -{ -#ifdef __DARWIN8__ - extern void Debugger(const char * reason); - Debugger("CFS"); -#else - extern void PE_enter_debugger(char *cause); - PE_enter_debugger("CFS"); -#endif -} - -int cfs_online_cpus(void) -{ - int activecpu; - size_t size; - -#ifdef __DARWIN8__ - size = sizeof(int); - sysctlbyname("hw.activecpu", &activecpu, &size, NULL, 0); - return activecpu; -#else - host_basic_info_data_t hinfo; - kern_return_t kret; - int count = HOST_BASIC_INFO_COUNT; -#define BSD_HOST 1 - kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count); - if (kret == KERN_SUCCESS) - return (hinfo.avail_cpus); - return(-EINVAL); -#endif -} - -int cfs_ncpus(void) -{ - int ncpu; - size_t size; - - size = sizeof(int); - - sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0); - return ncpu; -} diff --git a/libcfs/libcfs/darwin/darwin-proc.c b/libcfs/libcfs/darwin/darwin-proc.c deleted file mode 100644 index aacc66b..0000000 --- a/libcfs/libcfs/darwin/darwin-proc.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LNET - -#include - -#define LIBCFS_SYSCTL "libcfs" -#define LIBCFS_SYSCTL_SPRITE "sprite" -#define LIBCFS_SYSCTL_MAGIC 0xbabeface - -static struct libcfs_sysctl_sprite { - int ss_magic; - struct sysctl_oid_list *ss_link; -} libcfs_sysctl_sprite = { 0, NULL }; - -static struct ctl_table_header *libcfs_table_header = NULL; -extern unsigned int libcfs_debug; -extern unsigned int libcfs_subsystem_debug; -extern unsigned int libcfs_printk; -extern unsigned int libcfs_console_ratelimit; -extern unsigned int libcfs_catastrophe; -extern atomic_t libcfs_kmemory; - -static int sysctl_debug_kernel SYSCTL_HANDLER_ARGS -{ -#error "Check me" - const int maxstr = 1024; - char *str; - int error; - - if (req->newptr == USER_ADDR_NULL) { - /* read request */ - return -EINVAL; - } - - /* write request */ - error = trace_allocate_string_buffer(&str, maxstr + 1); - if (error != 0) - return error; - - error = SYSCTL_IN(req, str, maxstr); - - /* NB str guaranteed terminted */ - if (error == 0) - error = tracefile_dump_all_pages(str); - - trace_free_string_buffer(str, maxstr + 1); - return error; -} - -static int sysctl_daemon_file SYSCTL_HANDLER_ARGS -{ -#error "Check me" - int error; - char *str; - - if (req->newptr == USER_ADDR_NULL) { - /* a read */ - tracefile_read_lock(); - - /* include terminating '\0' */ - error = SYSCTL_OUT(req, tracefile, strlen(tracefile) + 1); - - tracefile_read_unlock(); - return error; - } - - /* write request */ - error = trace_allocate_string_buffer(&str, TRACEFILE_NAME_SIZE); - if (error != 0) - return error; - - error = SYSCTL_IN(req, str, TRACEFILE_NAME_SIZE - 1); - - /* NB str guaranteed terminted */ - if (error == 0) - error = trace_daemon_command(str); - - trace_free_string_buffer(str, TRACEFILE_NAME_SIZE); - return error; -} - - -static int sysctl_debug_mb SYSCTL_HANDLER_ARGS -{ -#error "Check me" - long mb; - int error; - - if (req->newptr == USER_ADDR_NULL) { - /* read */ - mb = trace_get_debug_mb(); - error = SYSCTL_OUT(req, &mb, sizeof(mb)); - } else { - /* write */ - error = SYSCTL_IN(req, &mb, sizeof(mb)); - if (error == 0) - error = trace_set_debug_mb(mb); - } - - return error; -} - -static int proc_fail_loc SYSCTL_HANDLER_ARGS -{ - int error = 0; - long old_fail_loc = cfs_fail_loc; - - error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (!error && req->newptr != USER_ADDR_NULL) { - if (old_fail_loc != cfs_fail_loc) - wake_up(&cfs_race_waitq); - } else if (req->newptr != USER_ADDR_NULL) { - /* Something was wrong with the write request */ - printf ("sysctl fail loc fault: %d.\n", error); - } else { - /* Read request */ - error = SYSCTL_OUT(req, &cfs_fail_loc, sizeof cfs_fail_loc); - } - return error; -} - -/* - * sysctl table for lnet - */ - -SYSCTL_NODE (, OID_AUTO, lnet, CTLFLAG_RW, - 0, "lnet sysctl top"); - -SYSCTL_INT(_lnet, OID_AUTO, debug, - CTLTYPE_INT | CTLFLAG_RW , &libcfs_debug, - 0, "debug"); -SYSCTL_INT(_lnet, OID_AUTO, subsystem_debug, - CTLTYPE_INT | CTLFLAG_RW, &libcfs_subsystem_debug, - 0, "subsystem debug"); -SYSCTL_INT(_lnet, OID_AUTO, printk, - CTLTYPE_INT | CTLFLAG_RW, &libcfs_printk, - 0, "printk"); -SYSCTL_INT(_lnet, OID_AUTO, console_ratelimit, - CTLTYPE_INT | CTLFLAG_RW, &libcfs_console_ratelimit, - 0, "console_ratelimit"); -SYSCTL_STRING(_lnet, OID_AUTO, debug_path, - CTLTYPE_STRING | CTLFLAG_RW, debug_file_path, - 1024, "debug path"); -SYSCTL_INT(_lnet, OID_AUTO, memused, - CTLTYPE_INT | CTLFLAG_RW, (int *)&libcfs_kmemory.counter, - 0, "memused"); -SYSCTL_INT(_lnet, OID_AUTO, catastrophe, - CTLTYPE_INT | CTLFLAG_RW, (int *)&libcfs_catastrophe, - 0, "catastrophe"); - -#error "check me" -SYSCTL_PROC(_lnet, OID_AUTO, debug_kernel, - CTLTYPE_STRING | CTLFLAG_W, 0, - 0, &sysctl_debug_kernel, "A", "debug_kernel"); -SYSCTL_PROC(_lnet, OID_AUTO, daemon_file, - CTLTYPE_STRING | CTLFLAG_RW, 0, - 0, &sysctl_daemon_file, "A", "daemon_file"); -SYSCTL_PROC(_lnet, OID_AUTO, debug_mb, - CTLTYPE_INT | CTLFLAG_RW, 0, - 0, &sysctl_debug_mb, "L", "debug_mb"); -SYSCTL_PROC(_lnet, OID_AUTO, fail_loc, - CTLTYPE_INT | CTLFLAG_RW , &cfs_fail_loc, - 0, &proc_fail_loc, "I", "cfs_fail_loc"); - -static struct ctl_table top_table[] = { - &sysctl__lnet, - &sysctl__lnet_debug, - &sysctl__lnet_subsystem_debug, - &sysctl__lnet_printk, - &sysctl__lnet_console_ratelimit, - &sysctl__lnet_debug_path, - &sysctl__lnet_memused, - &sysctl__lnet_catastrophe, - &sysctl__lnet_debug_kernel, - &sysctl__lnet_daemon_file, - &sysctl__lnet_debug_mb, - &sysctl__lnet_cfs_fail_loc - NULL -}; - -/* - * Register sysctl table - */ -struct ctl_table_header * -register_sysctl_table(struct ctl_table *table, int arg) -{ - struct ctl_table item; - int i = 0; - - while ((item = table[i++]) != NULL) - sysctl_register_oid(item); - return table; -} - -/* - * Unregister sysctl table - */ -void unregister_sysctl_table(struct ctl_table_header *table) -{ - int i = 0; - struct ctl_table item; - - while ((item = table[i++]) != NULL) - sysctl_unregister_oid(item); - return; -} - -/* - * Allocate a sysctl oid. - */ -static struct sysctl_oid * -cfs_alloc_sysctl(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, void *arg1, int arg2, const char *fmt, - int (*handler) SYSCTL_HANDLER_ARGS) -{ - struct sysctl_oid *oid; - char *sname = NULL; - char *sfmt = NULL; - - if (strlen(name) + 1 > CTL_MAXNAME) { - printf("libcfs: sysctl name: %s is too long.\n", name); - return NULL; - } - oid = (struct sysctl_oid*)_MALLOC(sizeof(struct sysctl_oid), - M_TEMP, M_WAITOK | M_ZERO); - if (oid == NULL) - return NULL; - - sname = (char *)_MALLOC(sizeof(CTL_MAXNAME), - M_TEMP, M_WAITOK | M_ZERO); - if (sname == NULL) - goto error; - strcpy(sname, name); - - sfmt = (char *)_MALLOC(4, M_TEMP, M_WAITOK | M_ZERO); - if (sfmt == NULL) - goto error; - strcpy(sfmt, fmt); - - if (parent == NULL) - oid->oid_parent = &sysctl__children; - else - oid->oid_parent = parent; - oid->oid_number = nbr; - oid->oid_kind = access; - oid->oid_name = sname; - oid->oid_handler = handler; - oid->oid_fmt = sfmt; - - if ((access & CTLTYPE) == CTLTYPE_NODE){ - /* It's a sysctl node */ - struct sysctl_oid_list *link; - - link = (struct sysctl_oid_list *)_MALLOC(sizeof(struct sysctl_oid_list), - M_TEMP, M_WAITOK | M_ZERO); - if (link == NULL) - goto error; - oid->oid_arg1 = link; - oid->oid_arg2 = 0; - } else { - oid->oid_arg1 = arg1; - oid->oid_arg2 = arg2; - } - - return oid; -error: - if (sfmt != NULL) - _FREE(sfmt, M_TEMP); - if (sname != NULL) - _FREE(sname, M_TEMP); - if (oid != NULL) - _FREE(oid, M_TEMP); - return NULL; -} - -void cfs_free_sysctl(struct sysctl_oid *oid) -{ - if (oid->oid_name != NULL) - _FREE((void *)oid->oid_name, M_TEMP); - if (oid->oid_fmt != NULL) - _FREE((void *)oid->oid_fmt, M_TEMP); - if ((oid->oid_kind & CTLTYPE_NODE != 0) && oid->oid_arg1) - /* XXX Liang: need to assert the list is empty */ - _FREE(oid->oid_arg1, M_TEMP); - _FREE(oid, M_TEMP); -} - -#define CFS_SYSCTL_ISVALID ((libcfs_sysctl_sprite.ss_magic == LIBCFS_SYSCTL_MAGIC) && \ - (libcfs_sysctl_sprite.ss_link != NULL)) - -int -cfs_sysctl_isvalid(void) -{ - return CFS_SYSCTL_ISVALID; -} - -struct sysctl_oid * -cfs_alloc_sysctl_node(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, int (*handler) SYSCTL_HANDLER_ARGS) -{ - if (parent == NULL && CFS_SYSCTL_ISVALID) - parent = libcfs_sysctl_sprite.ss_link; - return cfs_alloc_sysctl(parent, nbr, CTLTYPE_NODE | access, name, - NULL, 0, "N", handler); -} - -struct sysctl_oid * -cfs_alloc_sysctl_int(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, int *ptr, int val) -{ - if (parent == NULL && CFS_SYSCTL_ISVALID) - parent = libcfs_sysctl_sprite.ss_link; - return cfs_alloc_sysctl(parent, nbr, CTLTYPE_INT | access, name, - ptr, val, "I", sysctl_handle_int); -} - -struct sysctl_oid * -cfs_alloc_sysctl_long(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, int *ptr, int val) -{ - if (parent == NULL && CFS_SYSCTL_ISVALID) - parent = libcfs_sysctl_sprite.ss_link; - return cfs_alloc_sysctl(parent, nbr, CTLTYPE_INT | access, name, - ptr, val, "L", sysctl_handle_long); -} - -struct sysctl_oid * -cfs_alloc_sysctl_string(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, char *ptr, int len) -{ - if (parent == NULL && CFS_SYSCTL_ISVALID) - parent = libcfs_sysctl_sprite.ss_link; - return cfs_alloc_sysctl(parent, nbr, CTLTYPE_STRING | access, name, - ptr, len, "A", sysctl_handle_string); -} - -struct sysctl_oid * -cfs_alloc_sysctl_struct(struct sysctl_oid_list *parent, int nbr, int access, - const char *name, void *ptr, int size) -{ - if (parent == NULL && CFS_SYSCTL_ISVALID) - parent = libcfs_sysctl_sprite.ss_link; - return cfs_alloc_sysctl(parent, nbr, CTLTYPE_OPAQUE | access, name, - ptr, size, "S", sysctl_handle_opaque); -} - -/* no proc in osx */ -cfs_proc_dir_entry_t * -cfs_create_proc_entry(char *name, int mod, cfs_proc_dir_entry_t *parent) -{ - cfs_proc_dir_entry_t *entry; - MALLOC(entry, cfs_proc_dir_entry_t *, sizeof(cfs_proc_dir_entry_t), M_TEMP, M_WAITOK|M_ZERO); - - return entry; -} - -void -cfs_free_proc_entry(cfs_proc_dir_entry_t *de){ - FREE(de, M_TEMP); - return; -}; - -void -cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry) -{ - cfs_free_proc_entry(entry); - return; -} - -int -insert_proc(void) -{ -#if 1 - if (!libcfs_table_header) - libcfs_table_header = register_sysctl_table(top_table); -#endif - return 0; -} - -void -remove_proc(void) -{ -#if 1 - if (libcfs_table_header != NULL) - unregister_sysctl_table(libcfs_table_header); - libcfs_table_header = NULL; -#endif - return; -} - -int -cfs_sysctl_init(void) -{ - struct sysctl_oid *oid_root; - struct sysctl_oid *oid_sprite; - struct libcfs_sysctl_sprite *sprite; - size_t len; - int rc; - - len = sizeof(struct libcfs_sysctl_sprite); - rc = sysctlbyname("libcfs.sprite", - (void *)&libcfs_sysctl_sprite, &len, NULL, 0); - if (rc == 0) { - /* - * XXX Liang: assert (rc == 0 || rc == ENOENT) - * - * libcfs.sprite has been registered by previous - * loading of libcfs - */ - if (libcfs_sysctl_sprite.ss_magic != LIBCFS_SYSCTL_MAGIC) { - printf("libcfs: magic number of libcfs.sprite " - "is not right (%lx, %lx)\n", - libcfs_sysctl_sprite.ss_magic, - LIBCFS_SYSCTL_MAGIC); - return -1; - } - assert(libcfs_sysctl_sprite.ss_link != NULL); - printf("libcfs: registered libcfs.sprite found.\n"); - return 0; - } - oid_root = cfs_alloc_sysctl_node(NULL, OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN, - LIBCFS_SYSCTL, 0); - if (oid_root == NULL) - return -1; - sysctl_register_oid(oid_root); - - sprite = (struct libcfs_sysctl_sprite *)_MALLOC(sizeof(struct libcfs_sysctl_sprite), - M_TEMP, M_WAITOK | M_ZERO); - if (sprite == NULL) { - sysctl_unregister_oid(oid_root); - cfs_free_sysctl(oid_root); - return -1; - } - sprite->ss_magic = LIBCFS_SYSCTL_MAGIC; - sprite->ss_link = (struct sysctl_oid_list *)oid_root->oid_arg1; - oid_sprite = cfs_alloc_sysctl_struct((struct sysctl_oid_list *)oid_root->oid_arg1, - OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN, - LIBCFS_SYSCTL_SPRITE, sprite, - sizeof(struct libcfs_sysctl_sprite)); - if (oid_sprite == NULL) { - cfs_free_sysctl(oid_sprite); - sysctl_unregister_oid(oid_root); - cfs_free_sysctl(oid_root); - return -1; - } - sysctl_register_oid(oid_sprite); - - libcfs_sysctl_sprite.ss_magic = sprite->ss_magic; - libcfs_sysctl_sprite.ss_link = sprite->ss_link; - - return 0; -} - -void -cfs_sysctl_fini(void) -{ - libcfs_sysctl_sprite.ss_magic = 0; - libcfs_sysctl_sprite.ss_link = NULL; -} diff --git a/libcfs/libcfs/darwin/darwin-sync.c b/libcfs/libcfs/darwin/darwin-sync.c deleted file mode 100644 index 0aaabbb..0000000 --- a/libcfs/libcfs/darwin/darwin-sync.c +++ /dev/null @@ -1,1036 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-sync.c - * - * XNU synchronization primitives. - * - * Author: Nikita Danilov - */ - -/* - * This file contains very simplistic implementations of (saner) API for - * basic synchronization primitives: - * - * - spin-lock (kspin) - * - * - semaphore (ksem) - * - * - mutex (kmut) - * - * - condition variable (kcond) - * - * - wait-queue (ksleep_chan and ksleep_link) - * - * - timer (ktimer) - * - * A lot can be optimized here. - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#ifdef __DARWIN8__ -# include -#else -# include -# include -# include -#endif - -#include - -#define SLASSERT(e) ON_SYNC_DEBUG(LASSERT(e)) - -#ifdef HAVE_GET_PREEMPTION_LEVEL -extern int get_preemption_level(void); -#else -#define get_preemption_level() (0) -#endif - -#if SMP -#ifdef __DARWIN8__ - -static lck_grp_t *cfs_lock_grp = NULL; -#warning "Verify definition of lck_spin_t hasn't been changed while building!" - -/* hw_lock_* are not exported by Darwin8 */ -static inline void xnu_spin_init(xnu_spin_t *s) -{ - SLASSERT(cfs_lock_grp != NULL); - //*s = lck_spin_alloc_init(cfs_lock_grp, LCK_ATTR_NULL); - lck_spin_init((lck_spin_t *)s, cfs_lock_grp, LCK_ATTR_NULL); -} - -static inline void xnu_spin_done(xnu_spin_t *s) -{ - SLASSERT(cfs_lock_grp != NULL); - //lck_spin_free(*s, cfs_lock_grp); - //*s = NULL; - lck_spin_destroy((lck_spin_t *)s, cfs_lock_grp); -} - -#define xnu_spin_lock(s) lck_spin_lock((lck_spin_t *)(s)) -#define xnu_spin_unlock(s) lck_spin_unlock((lck_spin_t *)(s)) - -#warning "Darwin8 does not export lck_spin_try_lock" -#define xnu_spin_try(s) (1) - -#else /* DARWIN8 */ -extern void hw_lock_init(hw_lock_t); -extern void hw_lock_lock(hw_lock_t); -extern void hw_lock_unlock(hw_lock_t); -extern unsigned int hw_lock_to(hw_lock_t, unsigned int); -extern unsigned int hw_lock_try(hw_lock_t); -extern unsigned int hw_lock_held(hw_lock_t); - -#define xnu_spin_init(s) hw_lock_init(s) -#define xnu_spin_done(s) do {} while (0) -#define xnu_spin_lock(s) hw_lock_lock(s) -#define xnu_spin_unlock(s) hw_lock_unlock(s) -#define xnu_spin_try(s) hw_lock_try(s) -#endif /* DARWIN8 */ - -#else /* SMP */ -#define xnu_spin_init(s) do {} while (0) -#define xnu_spin_done(s) do {} while (0) -#define xnu_spin_lock(s) do {} while (0) -#define xnu_spin_unlock(s) do {} while (0) -#define xnu_spin_try(s) (1) -#endif /* SMP */ - -/* - * Warning: low level libcfs debugging code (libcfs_debug_msg(), for - * example), uses spin-locks, so debugging output here may lead to nasty - * surprises. - * - * In uniprocessor version of spin-lock. Only checks. - */ - -void kspin_init(struct kspin *spin) -{ - SLASSERT(spin != NULL); - xnu_spin_init(&spin->lock); - ON_SYNC_DEBUG(spin->magic = KSPIN_MAGIC); - ON_SYNC_DEBUG(spin->owner = NULL); -} - -void kspin_done(struct kspin *spin) -{ - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - SLASSERT(spin->owner == NULL); - xnu_spin_done(&spin->lock); -} - -void kspin_lock(struct kspin *spin) -{ - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - SLASSERT(spin->owner != current_thread()); - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - xnu_spin_lock(&spin->lock); - SLASSERT(spin->owner == NULL); - ON_SYNC_DEBUG(spin->owner = current_thread()); -} - -void kspin_unlock(struct kspin *spin) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - SLASSERT(spin->owner == current_thread()); - ON_SYNC_DEBUG(spin->owner = NULL); - xnu_spin_unlock(&spin->lock); -} - -int kspin_trylock(struct kspin *spin) -{ - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - - if (xnu_spin_try(&spin->lock)) { - SLASSERT(spin->owner == NULL); - ON_SYNC_DEBUG(spin->owner = current_thread()); - return 1; - } else - return 0; -} - -#if XNU_SYNC_DEBUG -int kspin_islocked(struct kspin *spin) -{ - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - return spin->owner == current_thread(); -} - -int kspin_isnotlocked(struct kspin *spin) -{ - SLASSERT(spin != NULL); - SLASSERT(spin->magic == KSPIN_MAGIC); - return spin->owner != current_thread(); -} -#endif - -/* - * read/write spin-lock - */ -void krw_spin_init(struct krw_spin *rwspin) -{ - SLASSERT(rwspin != NULL); - - kspin_init(&rwspin->guard); - rwspin->count = 0; - ON_SYNC_DEBUG(rwspin->magic = KRW_SPIN_MAGIC); -} - -void krw_spin_done(struct krw_spin *rwspin) -{ - SLASSERT(rwspin != NULL); - SLASSERT(rwspin->magic == KRW_SPIN_MAGIC); - SLASSERT(rwspin->count == 0); - kspin_done(&rwspin->guard); -} - -void krw_spin_down_r(struct krw_spin *rwspin) -{ - int i; - SLASSERT(rwspin != NULL); - SLASSERT(rwspin->magic == KRW_SPIN_MAGIC); - - kspin_lock(&rwspin->guard); - while(rwspin->count < 0) { - i = -1; - kspin_unlock(&rwspin->guard); - while (--i != 0 && rwspin->count < 0) - continue; - kspin_lock(&rwspin->guard); - } - ++ rwspin->count; - kspin_unlock(&rwspin->guard); -} - -void krw_spin_down_w(struct krw_spin *rwspin) -{ - int i; - SLASSERT(rwspin != NULL); - SLASSERT(rwspin->magic == KRW_SPIN_MAGIC); - - kspin_lock(&rwspin->guard); - while (rwspin->count != 0) { - i = -1; - kspin_unlock(&rwspin->guard); - while (--i != 0 && rwspin->count != 0) - continue; - kspin_lock(&rwspin->guard); - } - rwspin->count = -1; - kspin_unlock(&rwspin->guard); -} - -void krw_spin_up_r(struct krw_spin *rwspin) -{ - SLASSERT(rwspin != NULL); - SLASSERT(rwspin->magic == KRW_SPIN_MAGIC); - SLASSERT(rwspin->count > 0); - - kspin_lock(&rwspin->guard); - -- rwspin->count; - kspin_unlock(&rwspin->guard); -} - -void krw_spin_up_w(struct krw_spin *rwspin) -{ - SLASSERT(rwspin != NULL); - SLASSERT(rwspin->magic == KRW_SPIN_MAGIC); - SLASSERT(rwspin->count == -1); - - kspin_lock(&rwspin->guard); - rwspin->count = 0; - kspin_unlock(&rwspin->guard); -} - -/* - * semaphore - */ -#ifdef __DARWIN8__ - -#define xnu_waitq_init(q, a) do {} while (0) -#define xnu_waitq_done(q) do {} while (0) -#define xnu_waitq_wakeup_one(q, e, s) ({wakeup_one((void *)(e)); KERN_SUCCESS;}) -#define xnu_waitq_wakeup_all(q, e, s) ({wakeup((void *)(e)); KERN_SUCCESS;}) -#define xnu_waitq_assert_wait(q, e, s) assert_wait((e), s) - -#else /* DARWIN8 */ - -#define xnu_waitq_init(q, a) wait_queue_init((q), a) -#define xnu_waitq_done(q) do {} while (0) -#define xnu_waitq_wakeup_one(q, e, s) wait_queue_wakeup_one((q), (event_t)(e), s) -#define xnu_waitq_wakeup_all(q, e, s) wait_queue_wakeup_all((q), (event_t)(e), s) -#define xnu_waitq_assert_wait(q, e, s) wait_queue_assert_wait((q), (event_t)(e), s) - -#endif /* DARWIN8 */ -void ksem_init(struct ksem *sem, int value) -{ - SLASSERT(sem != NULL); - kspin_init(&sem->guard); - xnu_waitq_init(&sem->q, SYNC_POLICY_FIFO); - sem->value = value; - ON_SYNC_DEBUG(sem->magic = KSEM_MAGIC); -} - -void ksem_done(struct ksem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KSEM_MAGIC); - /* - * XXX nikita: cannot check that &sem->q is empty because - * wait_queue_empty() is Apple private API. - */ - kspin_done(&sem->guard); -} - -int ksem_up(struct ksem *sem, int value) -{ - int result; - - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KSEM_MAGIC); - SLASSERT(value >= 0); - - kspin_lock(&sem->guard); - sem->value += value; - if (sem->value == 0) - result = xnu_waitq_wakeup_one(&sem->q, sem, - THREAD_AWAKENED); - else - result = xnu_waitq_wakeup_all(&sem->q, sem, - THREAD_AWAKENED); - kspin_unlock(&sem->guard); - SLASSERT(result == KERN_SUCCESS || result == KERN_NOT_WAITING); - return (result == KERN_SUCCESS) ? 0 : 1; -} - -void ksem_down(struct ksem *sem, int value) -{ - int result; - - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KSEM_MAGIC); - SLASSERT(value >= 0); - SLASSERT(get_preemption_level() == 0); - - kspin_lock(&sem->guard); - while (sem->value < value) { - result = xnu_waitq_assert_wait(&sem->q, sem, - THREAD_UNINT); - SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING); - kspin_unlock(&sem->guard); - if (result == THREAD_WAITING) - thread_block(THREAD_CONTINUE_NULL); - kspin_lock(&sem->guard); - } - sem->value -= value; - kspin_unlock(&sem->guard); -} - -int ksem_trydown(struct ksem *sem, int value) -{ - int result; - - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KSEM_MAGIC); - SLASSERT(value >= 0); - - kspin_lock(&sem->guard); - if (sem->value >= value) { - sem->value -= value; - result = 0; - } else - result = -EBUSY; - kspin_unlock(&sem->guard); - return result; -} - -void kmut_init(struct kmut *mut) -{ - SLASSERT(mut != NULL); - ksem_init(&mut->s, 1); - ON_SYNC_DEBUG(mut->magic = KMUT_MAGIC); - ON_SYNC_DEBUG(mut->owner = NULL); -} - -void kmut_done(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - SLASSERT(mut->owner == NULL); - ksem_done(&mut->s); -} - -void kmut_lock(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - SLASSERT(mut->owner != current_thread()); - SLASSERT(get_preemption_level() == 0); - - ksem_down(&mut->s, 1); - ON_SYNC_DEBUG(mut->owner = current_thread()); -} - -void kmut_unlock(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - SLASSERT(mut->owner == current_thread()); - - ON_SYNC_DEBUG(mut->owner = NULL); - ksem_up(&mut->s, 1); -} - -int kmut_trylock(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - return ksem_trydown(&mut->s, 1); -} - -#if XNU_SYNC_DEBUG -int kmut_islocked(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - return mut->owner == current_thread(); -} - -int kmut_isnotlocked(struct kmut *mut) -{ - SLASSERT(mut != NULL); - SLASSERT(mut->magic == KMUT_MAGIC); - return mut->owner != current_thread(); -} -#endif - - -void kcond_init(struct kcond *cond) -{ - SLASSERT(cond != NULL); - - kspin_init(&cond->guard); - cond->waiters = NULL; - ON_SYNC_DEBUG(cond->magic = KCOND_MAGIC); -} - -void kcond_done(struct kcond *cond) -{ - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - SLASSERT(cond->waiters == NULL); - kspin_done(&cond->guard); -} - -void kcond_wait(struct kcond *cond, struct kspin *lock) -{ - struct kcond_link link; - - SLASSERT(cond != NULL); - SLASSERT(lock != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - SLASSERT(kspin_islocked(lock)); - - ksem_init(&link.sem, 0); - kspin_lock(&cond->guard); - link.next = cond->waiters; - cond->waiters = &link; - kspin_unlock(&cond->guard); - kspin_unlock(lock); - - ksem_down(&link.sem, 1); - - kspin_lock(&cond->guard); - kspin_unlock(&cond->guard); - kspin_lock(lock); -} - -void kcond_wait_guard(struct kcond *cond) -{ - struct kcond_link link; - - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - SLASSERT(kspin_islocked(&cond->guard)); - - ksem_init(&link.sem, 0); - link.next = cond->waiters; - cond->waiters = &link; - kspin_unlock(&cond->guard); - - ksem_down(&link.sem, 1); - - kspin_lock(&cond->guard); -} - -void kcond_signal_guard(struct kcond *cond) -{ - struct kcond_link *link; - - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - SLASSERT(kspin_islocked(&cond->guard)); - - link = cond->waiters; - if (link != NULL) { - cond->waiters = link->next; - ksem_up(&link->sem, 1); - } -} - -void kcond_signal(struct kcond *cond) -{ - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - - kspin_lock(&cond->guard); - kcond_signal_guard(cond); - kspin_unlock(&cond->guard); -} - -void kcond_broadcast_guard(struct kcond *cond) -{ - struct kcond_link *link; - - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - SLASSERT(kspin_islocked(&cond->guard)); - - for (link = cond->waiters; link != NULL; link = link->next) - ksem_up(&link->sem, 1); - cond->waiters = NULL; -} - -void kcond_broadcast(struct kcond *cond) -{ - SLASSERT(cond != NULL); - SLASSERT(cond->magic == KCOND_MAGIC); - - kspin_lock(&cond->guard); - kcond_broadcast_guard(cond); - kspin_unlock(&cond->guard); -} - -void krw_sem_init(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - - kcond_init(&sem->cond); - sem->count = 0; - ON_SYNC_DEBUG(sem->magic = KRW_MAGIC); -} - -void krw_sem_done(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - SLASSERT(sem->count == 0); - kcond_done(&sem->cond); -} - -void krw_sem_down_r(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - SLASSERT(get_preemption_level() == 0); - - kspin_lock(&sem->cond.guard); - while (sem->count < 0) - kcond_wait_guard(&sem->cond); - ++ sem->count; - kspin_unlock(&sem->cond.guard); -} - -int krw_sem_down_r_try(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - - kspin_lock(&sem->cond.guard); - if (sem->count < 0) { - kspin_unlock(&sem->cond.guard); - return -EBUSY; - } - ++ sem->count; - kspin_unlock(&sem->cond.guard); - return 0; -} - -void krw_sem_down_w(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - SLASSERT(get_preemption_level() == 0); - - kspin_lock(&sem->cond.guard); - while (sem->count != 0) - kcond_wait_guard(&sem->cond); - sem->count = -1; - kspin_unlock(&sem->cond.guard); -} - -int krw_sem_down_w_try(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - - kspin_lock(&sem->cond.guard); - if (sem->count != 0) { - kspin_unlock(&sem->cond.guard); - return -EBUSY; - } - sem->count = -1; - kspin_unlock(&sem->cond.guard); - return 0; -} - -void krw_sem_up_r(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - SLASSERT(sem->count > 0); - - kspin_lock(&sem->cond.guard); - -- sem->count; - if (sem->count == 0) - kcond_broadcast_guard(&sem->cond); - kspin_unlock(&sem->cond.guard); -} - -void krw_sem_up_w(struct krw_sem *sem) -{ - SLASSERT(sem != NULL); - SLASSERT(sem->magic == KRW_MAGIC); - SLASSERT(sem->count == -1); - - kspin_lock(&sem->cond.guard); - sem->count = 0; - kspin_unlock(&sem->cond.guard); - kcond_broadcast(&sem->cond); -} - -void ksleep_chan_init(struct ksleep_chan *chan) -{ - SLASSERT(chan != NULL); - - kspin_init(&chan->guard); - INIT_LIST_HEAD(&chan->waiters); - ON_SYNC_DEBUG(chan->magic = KSLEEP_CHAN_MAGIC); -} - -void ksleep_chan_done(struct ksleep_chan *chan) -{ - SLASSERT(chan != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - SLASSERT(list_empty(&chan->waiters)); - kspin_done(&chan->guard); -} - -void ksleep_link_init(struct ksleep_link *link) -{ - SLASSERT(link != NULL); - - INIT_LIST_HEAD(&link->linkage); - link->flags = 0; - link->event = current_thread(); - link->hits = 0; - link->forward = NULL; - ON_SYNC_DEBUG(link->magic = KSLEEP_LINK_MAGIC); -} - -void ksleep_link_done(struct ksleep_link *link) -{ - SLASSERT(link != NULL); - SLASSERT(link->magic == KSLEEP_LINK_MAGIC); - SLASSERT(list_empty(&link->linkage)); -} - -void ksleep_add(struct ksleep_chan *chan, struct ksleep_link *link) -{ - SLASSERT(chan != NULL); - SLASSERT(link != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - SLASSERT(link->magic == KSLEEP_LINK_MAGIC); - SLASSERT(list_empty(&link->linkage)); - - kspin_lock(&chan->guard); - if (link->flags & KSLEEP_EXCLUSIVE) - list_add_tail(&link->linkage, &chan->waiters); - else - list_add(&link->linkage, &chan->waiters); - kspin_unlock(&chan->guard); -} - -void ksleep_del(struct ksleep_chan *chan, struct ksleep_link *link) -{ - SLASSERT(chan != NULL); - SLASSERT(link != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - SLASSERT(link->magic == KSLEEP_LINK_MAGIC); - - kspin_lock(&chan->guard); - list_del_init(&link->linkage); - kspin_unlock(&chan->guard); -} - -static int has_hits(struct ksleep_chan *chan, event_t event) -{ - struct ksleep_link *scan; - - SLASSERT(kspin_islocked(&chan->guard)); - list_for_each_entry(scan, &chan->waiters, linkage) { - if (scan->event == event && scan->hits > 0) { - /* consume hit */ - -- scan->hits; - return 1; - } - } - return 0; -} - -static void add_hit(struct ksleep_chan *chan, event_t event) -{ - struct ksleep_link *scan; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - SLASSERT(kspin_islocked(&chan->guard)); - list_for_each_entry(scan, &chan->waiters, linkage) { - if (scan->event == event) { - ++ scan->hits; - break; - } - } -} - -void ksleep_wait(struct ksleep_chan *chan, long state) -{ - event_t event; - int result; - - ENTRY; - - SLASSERT(chan != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - SLASSERT(get_preemption_level() == 0); - - event = current_thread(); - kspin_lock(&chan->guard); - if (!has_hits(chan, event)) { - result = assert_wait(event, state); - kspin_unlock(&chan->guard); - SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING); - if (result == THREAD_WAITING) - thread_block(THREAD_CONTINUE_NULL); - } else - kspin_unlock(&chan->guard); - EXIT; -} - -/* - * Sleep on @chan for no longer than @timeout nano-seconds. Return remaining - * sleep time (non-zero only if thread was waken by a signal (not currently - * implemented), or waitq was already in the "signalled" state). - */ -int64_t ksleep_timedwait(struct ksleep_chan *chan, - long state, - __u64 timeout) -{ - event_t event; - - ENTRY; - - SLASSERT(chan != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - SLASSERT(get_preemption_level() == 0); - - event = current_thread(); - kspin_lock(&chan->guard); - if (!has_hits(chan, event)) { - int result; - __u64 expire; - result = assert_wait(event, state); - if (timeout > 0) { - /* - * arm a timer. thread_set_timer()'s first argument is - * uint32_t, so we have to cook deadline ourselves. - */ - nanoseconds_to_absolutetime(timeout, &expire); - clock_absolutetime_interval_to_deadline(expire, &expire); - thread_set_timer_deadline(expire); - } - kspin_unlock(&chan->guard); - SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING); - if (result == THREAD_WAITING) - result = thread_block(THREAD_CONTINUE_NULL); - thread_cancel_timer(); - - if (result == THREAD_TIMED_OUT) - timeout = 0; - else { - __u64 now; - clock_get_uptime(&now); - if (expire > now) - absolutetime_to_nanoseconds(expire - now, &timeout); - else - timeout = 0; - } - } else { - /* just return timeout, because I've got event and don't need to wait */ - kspin_unlock(&chan->guard); - } - - RETURN(timeout); -} - -/* - * wake up single exclusive waiter (plus some arbitrary number of * - * non-exclusive) - */ -void ksleep_wake(struct ksleep_chan *chan) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - ksleep_wake_nr(chan, 1); -} - -/* - * wake up all waiters on @chan - */ -void ksleep_wake_all(struct ksleep_chan *chan) -{ - ENTRY; - ksleep_wake_nr(chan, 0); - EXIT; -} - -/* - * wakeup no more than @nr exclusive waiters from @chan, plus some arbitrary - * number of non-exclusive. If @nr is 0, wake up all waiters. - */ -void ksleep_wake_nr(struct ksleep_chan *chan, int nr) -{ - struct ksleep_link *scan; - int result; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - SLASSERT(chan != NULL); - SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC); - - kspin_lock(&chan->guard); - list_for_each_entry(scan, &chan->waiters, linkage) { - struct ksleep_chan *forward; - - forward = scan->forward; - if (forward != NULL) - kspin_lock(&forward->guard); - result = thread_wakeup(scan->event); - SLASSERT(result == KERN_SUCCESS || result == KERN_NOT_WAITING); - if (result == KERN_NOT_WAITING) { - ++ scan->hits; - if (forward != NULL) - add_hit(forward, scan->event); - } - if (forward != NULL) - kspin_unlock(&forward->guard); - if ((scan->flags & KSLEEP_EXCLUSIVE) && --nr == 0) - break; - } - kspin_unlock(&chan->guard); -} - -void ktimer_init(struct ktimer *t, void (*func)(void *), void *arg) -{ - SLASSERT(t != NULL); - SLASSERT(func != NULL); - - kspin_init(&t->guard); - t->func = func; - t->arg = arg; - ON_SYNC_DEBUG(t->magic = KTIMER_MAGIC); -} - -void ktimer_done(struct ktimer *t) -{ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - kspin_done(&t->guard); - ON_SYNC_DEBUG(t->magic = 0); -} - -static void ktimer_actor(void *arg0, void *arg1) -{ - struct ktimer *t; - int armed; - - t = arg0; - /* - * this assumes that ktimer's are never freed. - */ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - /* - * call actual timer function - */ - kspin_lock(&t->guard); - armed = t->armed; - t->armed = 0; - kspin_unlock(&t->guard); - - if (armed) - t->func(t->arg); -} - -extern boolean_t thread_call_func_cancel(thread_call_func_t, thread_call_param_t, boolean_t); -extern void thread_call_func_delayed(thread_call_func_t, thread_call_param_t, __u64); - -static void ktimer_disarm_locked(struct ktimer *t) -{ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - thread_call_func_cancel(ktimer_actor, t, FALSE); -} - -/* - * Received deadline is nanoseconds, but time checked by - * thread_call is absolute time (The abstime unit is equal to - * the length of one bus cycle, so the duration is dependent - * on the bus speed of the computer), so we need to convert - * nanotime to abstime by nanoseconds_to_absolutetime(). - * - * Refer to _delayed_call_timer(...) - * - * if thread_call_func_delayed is not exported in the future, - * we can use timeout() or bsd_timeout() to replace it. - */ -void ktimer_arm(struct ktimer *t, u_int64_t deadline) -{ - cfs_time_t abstime; - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - kspin_lock(&t->guard); - ktimer_disarm_locked(t); - t->armed = 1; - nanoseconds_to_absolutetime(deadline, &abstime); - thread_call_func_delayed(ktimer_actor, t, deadline); - kspin_unlock(&t->guard); -} - -void ktimer_disarm(struct ktimer *t) -{ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - kspin_lock(&t->guard); - t->armed = 0; - ktimer_disarm_locked(t); - kspin_unlock(&t->guard); -} - -int ktimer_is_armed(struct ktimer *t) -{ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - /* - * no locking---result is only a hint anyway. - */ - return t->armed; -} - -u_int64_t ktimer_deadline(struct ktimer *t) -{ - SLASSERT(t != NULL); - SLASSERT(t->magic == KTIMER_MAGIC); - - return t->deadline; -} - -void cfs_sync_init(void) -{ -#ifdef __DARWIN8__ - /* Initialize lock group */ - cfs_lock_grp = lck_grp_alloc_init("libcfs sync", LCK_GRP_ATTR_NULL); -#endif -} - -void cfs_sync_fini(void) -{ -#ifdef __DARWIN8__ - /* - * XXX Liang: destroy lock group. As we haven't called lock_done - * for all locks, cfs_lock_grp may not be freed by kernel(reference - * count > 1). - */ - lck_grp_free(cfs_lock_grp); - cfs_lock_grp = NULL; -#endif -} -/* - * Local variables: - * c-indentation-style: "K&R" - * c-basic-offset: 8 - * tab-width: 8 - * fill-column: 80 - * scroll-step: 1 - * End: - */ diff --git a/libcfs/libcfs/darwin/darwin-tcpip.c b/libcfs/libcfs/darwin/darwin-tcpip.c deleted file mode 100644 index 406eb7e..0000000 --- a/libcfs/libcfs/darwin/darwin-tcpip.c +++ /dev/null @@ -1,1352 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-tcpip.c - * - * Darwin porting library - * Make things easy to port - * - * Author: Phil Schwan - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LNET - -#include - -static __inline__ struct sockaddr_in -blank_sin() -{ - struct sockaddr_in blank = { sizeof(struct sockaddr_in), AF_INET }; - return (blank); -} - -void -libcfs_ipif_free_enumeration (char **names, int n) -{ - int i; - - LASSERT (n > 0); - - for (i = 0; i < n && names[i] != NULL; i++) - LIBCFS_FREE(names[i], IFNAMSIZ); - - LIBCFS_FREE(names, n * sizeof(*names)); -} - -#ifdef __DARWIN8__ -/* - * Darwin 8.x - * - * No hack kernel structre, all using KPI. - */ - -int -libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) -{ - struct ifreq ifr; - socket_t so; - __u32 val; - int nob; - int rc; - - rc = -sock_socket(PF_INET, SOCK_STREAM, 0, - NULL, NULL, &so); - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return rc; - } - - nob = strnlen(name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - CERROR("Interface name %s too long\n", name); - rc = -EINVAL; - goto out; - } - - CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ); - bzero(&ifr, sizeof(ifr)); - strcpy(ifr.ifr_name, name); - rc = -sock_ioctl (so, SIOCGIFFLAGS, &ifr); - - if (rc != 0) { - CERROR("Can't get flags for interface %s\n", name); - goto out; - } - - if ((ifr.ifr_flags & IFF_UP) == 0) { - CDEBUG(D_NET, "Interface %s down\n", name); - *up = 0; - *ip = *mask = 0; - goto out; - } - - *up = 1; - - bzero(&ifr, sizeof(ifr)); - strcpy(ifr.ifr_name, name); - *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin(); - rc = -sock_ioctl(so, SIOCGIFADDR, &ifr); - - if (rc != 0) { - CERROR("Can't get IP address for interface %s\n", name); - goto out; - } - - val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; - *ip = ntohl(val); - - bzero(&ifr, sizeof(ifr)); - strcpy(ifr.ifr_name, name); - *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin(); - rc = -sock_ioctl(so, SIOCGIFNETMASK, &ifr); - - if (rc != 0) { - CERROR("Can't get netmask for interface %s\n", name); - goto out; - } - - val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; - *mask = ntohl(val); -out: - sock_close(so); - return rc; -} - -int -libcfs_ipif_enumerate (char ***namesp) -{ - /* Allocate and fill in 'names', returning # interfaces/error */ - char **names; - int toobig; - int nalloc; - int nfound; - socket_t so; - struct ifreq *ifr; - struct ifconf ifc; - int rc; - int nob; - int i; - - rc = -sock_socket(PF_INET, SOCK_STREAM, 0, - NULL, NULL, &so); - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return (rc); - } - - nalloc = 16; /* first guess at max interfaces */ - toobig = 0; - for (;;) { - if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) { - toobig = 1; - nalloc = PAGE_CACHE_SIZE/sizeof(*ifr); - CWARN("Too many interfaces: only enumerating first %d\n", - nalloc); - } - - LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); - if (ifr == NULL) { - CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc); - rc = -ENOMEM; - goto out0; - } - - ifc.ifc_buf = (char *)ifr; - ifc.ifc_len = nalloc * sizeof(*ifr); - -#if 1 - /* - * XXX Liang: - * sock_ioctl(..., SIOCGIFCONF, ...) is not supposed to be used in - * kernel space because it always try to copy result to userspace. - * So we can't get interfaces name by sock_ioctl(...,SIOCGIFCONF,...). - * I've created a bug for Apple, let's wait... - */ - nfound = 0; - for (i = 0; i < 16; i++) { - struct ifreq en; - bzero(&en, sizeof(en)); - snprintf(en.ifr_name, IFNAMSIZ, "en%d", i); - rc = -sock_ioctl (so, SIOCGIFFLAGS, &en); - if (rc != 0) - continue; - strcpy(ifr[nfound++].ifr_name, en.ifr_name); - } - -#else /* NOT in using now */ - rc = -sock_ioctl(so, SIOCGIFCONF, (caddr_t)&ifc); - - if (rc < 0) { - CERROR ("Error %d enumerating interfaces\n", rc); - goto out1; - } - - nfound = ifc.ifc_len/sizeof(*ifr); - LASSERT (nfound <= nalloc); -#endif - - if (nfound < nalloc || toobig) - break; - - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); - nalloc *= 2; - } - if (nfound == 0) - goto out1; - - LIBCFS_ALLOC(names, nfound * sizeof(*names)); - if (names == NULL) { - rc = -ENOMEM; - goto out1; - } - /* NULL out all names[i] */ - memset (names, 0, nfound * sizeof(*names)); - - for (i = 0; i < nfound; i++) { - - nob = strnlen (ifr[i].ifr_name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - /* no space for terminating NULL */ - CERROR("interface name %.*s too long (%d max)\n", - nob, ifr[i].ifr_name, IFNAMSIZ); - rc = -ENAMETOOLONG; - goto out2; - } - - LIBCFS_ALLOC(names[i], IFNAMSIZ); - if (names[i] == NULL) { - rc = -ENOMEM; - goto out2; - } - - memcpy(names[i], ifr[i].ifr_name, nob); - names[i][nob] = 0; - } - - *namesp = names; - rc = nfound; - -out2: - if (rc < 0) - libcfs_ipif_free_enumeration(names, nfound); -out1: - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); -out0: - sock_close(so); - return rc; - -} - -/* - * Public entry of socket upcall. - * - * so_upcall can only be installed while create/accept of socket in - * Darwin 8.0, so we setup libcfs_sock_upcall() as upcall for all - * sockets in creat/accept, it will call upcall provided by user - * which can be setup after create/accept of socket. - */ -static void libcfs_sock_upcall(socket_t so, void* arg, int waitf) -{ - cfs_socket_t *sock; - - sock = (cfs_socket_t *)arg; - LASSERT(sock->s_magic == CFS_SOCK_MAGIC); - - if ((sock->s_flags & CFS_SOCK_UPCALL) != 0 && sock->s_upcall != NULL) - sock->s_upcall(so, sock->s_upcallarg, waitf); - return; -} - -void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg) -{ - sock->s_upcall = callback; - sock->s_upcallarg = arg; - sock->s_flags |= CFS_SOCK_UPCALL; - return; -} - -void libcfs_sock_reset_cb(cfs_socket_t *sock) -{ - sock->s_flags &= ~CFS_SOCK_UPCALL; - sock->s_upcall = NULL; - sock->s_upcallarg = NULL; - return; -} - -static int -libcfs_sock_create (cfs_socket_t **sockp, int *fatal, - __u32 local_ip, int local_port) -{ - struct sockaddr_in locaddr; - cfs_socket_t *sock; - int option; - int optlen; - int rc; - - /* All errors are fatal except bind failure if the port is in use */ - *fatal = 1; - - sock = _MALLOC(sizeof(cfs_socket_t), M_TEMP, M_WAITOK|M_ZERO); - if (!sock) { - CERROR("Can't allocate cfs_socket.\n"); - return -ENOMEM; - } - *sockp = sock; - sock->s_magic = CFS_SOCK_MAGIC; - - rc = -sock_socket(PF_INET, SOCK_STREAM, 0, - libcfs_sock_upcall, sock, &C2B_SOCK(sock)); - if (rc != 0) - goto out; - option = 1; - optlen = sizeof(option); - rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, - SO_REUSEADDR, &option, optlen); - if (rc != 0) - goto out; - - /* can't specify a local port without a local IP */ - LASSERT (local_ip == 0 || local_port != 0); - - if (local_ip != 0 || local_port != 0) { - bzero (&locaddr, sizeof (locaddr)); - locaddr.sin_len = sizeof(struct sockaddr_in); - locaddr.sin_family = AF_INET; - locaddr.sin_port = htons (local_port); - locaddr.sin_addr.s_addr = (local_ip != 0) ? htonl(local_ip) : INADDR_ANY; - rc = -sock_bind(C2B_SOCK(sock), (struct sockaddr *)&locaddr); - if (rc == -EADDRINUSE) { - CDEBUG(D_NET, "Port %d already in use\n", local_port); - *fatal = 0; - goto out; - } - if (rc != 0) { - CERROR("Error trying to bind to port %d: %d\n", - local_port, rc); - goto out; - } - } - return 0; -out: - if (C2B_SOCK(sock) != NULL) - sock_close(C2B_SOCK(sock)); - FREE(sock, M_TEMP); - return rc; -} - -int -libcfs_sock_listen (cfs_socket_t **sockp, - __u32 local_ip, int local_port, int backlog) -{ - cfs_socket_t *sock; - int fatal; - int rc; - - rc = libcfs_sock_create(&sock, &fatal, local_ip, local_port); - if (rc != 0) { - if (!fatal) - CERROR("Can't create socket: port %d already in use\n", - local_port); - return rc; - - } - rc = -sock_listen(C2B_SOCK(sock), backlog); - if (rc == 0) { - *sockp = sock; - return 0; - } - - if (C2B_SOCK(sock) != NULL) - sock_close(C2B_SOCK(sock)); - FREE(sock, M_TEMP); - return rc; -} - -int -libcfs_sock_accept (cfs_socket_t **newsockp, cfs_socket_t *sock) -{ - cfs_socket_t *newsock; - int rc; - - newsock = _MALLOC(sizeof(cfs_socket_t), M_TEMP, M_WAITOK|M_ZERO); - if (!newsock) { - CERROR("Can't allocate cfs_socket.\n"); - return -ENOMEM; - } - newsock->s_magic = CFS_SOCK_MAGIC; - /* - * thread will sleep in sock_accept by calling of msleep(), - * it can be interrupted because msleep() use PCATCH as argument. - */ - rc = -sock_accept(C2B_SOCK(sock), NULL, 0, 0, - libcfs_sock_upcall, newsock, &C2B_SOCK(newsock)); - if (rc) { - if (C2B_SOCK(newsock) != NULL) - sock_close(C2B_SOCK(newsock)); - FREE(newsock, M_TEMP); - if ((sock->s_flags & CFS_SOCK_DOWN) != 0) - /* shutdown by libcfs_sock_abort_accept(), fake - * error number for lnet_acceptor() */ - rc = -EAGAIN; - return rc; - } - *newsockp = newsock; - return 0; -} - -void -libcfs_sock_abort_accept (cfs_socket_t *sock) -{ - /* - * XXX Liang: - * - * we want to wakeup thread blocked by sock_accept, but we don't - * know the address where thread is sleeping on, so we cannot - * wakeup it directly. - * The thread slept in sock_accept will be waken up while: - * 1. interrupt by signal - * 2. new connection is coming (sonewconn) - * 3. disconnecting of the socket (soisconnected) - * - * Cause we can't send signal to a thread directly(no KPI), so the - * only thing can be done here is disconnect the socket (by - * sock_shutdown() or sth else? ). - * - * Shutdown request of socket with SHUT_WR or SHUT_RDWR will - * be issured to the protocol. - * sock_shutdown()->tcp_usr_shutdown()->tcp_usrclosed()-> - * tcp_close()->soisdisconnected(), it will wakeup thread by - * wakeup((caddr_t)&so->so_timeo); - */ - sock->s_flags |= CFS_SOCK_DOWN; - sock_shutdown(C2B_SOCK(sock), SHUT_RDWR); -} - -int -libcfs_sock_read (cfs_socket_t *sock, void *buffer, int nob, int timeout) -{ - size_t rcvlen; - int rc; - cfs_duration_t to = cfs_time_seconds(timeout); - cfs_time_t then; - struct timeval tv; - - LASSERT(nob > 0); - - for (;;) { - struct iovec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = &iov, - .msg_iovlen = 1, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = 0, - }; - cfs_duration_usec(to, &tv); - rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_RCVTIMEO, - &tv, sizeof(tv)); - if (rc != 0) { - CERROR("Can't set socket recv timeout " - "%ld.%06d: %d\n", - (long)tv.tv_sec, (int)tv.tv_usec, rc); - return rc; - } - - then = cfs_time_current(); - rc = -sock_receive(C2B_SOCK(sock), &msg, 0, &rcvlen); - to -= cfs_time_current() - then; - - if (rc != 0 && rc != -EWOULDBLOCK) - return rc; - if (rcvlen == nob) - return 0; - - if (to <= 0) - return -EAGAIN; - - buffer = ((char *)buffer) + rcvlen; - nob -= rcvlen; - } - return 0; -} - -int -libcfs_sock_write (cfs_socket_t *sock, void *buffer, int nob, int timeout) -{ - size_t sndlen; - int rc; - cfs_duration_t to = cfs_time_seconds(timeout); - cfs_time_t then; - struct timeval tv; - - LASSERT(nob > 0); - - for (;;) { - struct iovec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = &iov, - .msg_iovlen = 1, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0, - }; - - if (timeout != 0) { - cfs_duration_usec(to, &tv); - rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDTIMEO, - &tv, sizeof(tv)); - if (rc != 0) { - CERROR("Can't set socket send timeout " - "%ld.%06d: %d\n", - (long)tv.tv_sec, (int)tv.tv_usec, rc); - return rc; - } - } - - then = cfs_time_current(); - rc = -sock_send(C2B_SOCK(sock), &msg, - ((timeout == 0) ? MSG_DONTWAIT : 0), &sndlen); - to -= cfs_time_current() - then; - - if (rc != 0 && rc != -EWOULDBLOCK) - return rc; - if (sndlen == nob) - return 0; - - if (to <= 0) - return -EAGAIN; - buffer = ((char *)buffer) + sndlen; - nob -= sndlen; - } - return 0; - -} - -int -libcfs_sock_getaddr (cfs_socket_t *sock, int remote, __u32 *ip, int *port) -{ - struct sockaddr_in sin; - int rc; - - if (remote != 0) - /* Get remote address */ - rc = -sock_getpeername(C2B_SOCK(sock), (struct sockaddr *)&sin, sizeof(sin)); - else - /* Get local address */ - rc = -sock_getsockname(C2B_SOCK(sock), (struct sockaddr *)&sin, sizeof(sin)); - if (rc != 0) { - CERROR ("Error %d getting sock %s IP/port\n", - rc, remote ? "peer" : "local"); - return rc; - } - - if (ip != NULL) - *ip = ntohl (sin.sin_addr.s_addr); - - if (port != NULL) - *port = ntohs (sin.sin_port); - return 0; -} - -int -libcfs_sock_setbuf (cfs_socket_t *sock, int txbufsize, int rxbufsize) -{ - int option; - int rc; - - if (txbufsize != 0) { - option = txbufsize; - rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDBUF, - (char *)&option, sizeof (option)); - if (rc != 0) { - CERROR ("Can't set send buffer %d: %d\n", - option, rc); - return (rc); - } - } - - if (rxbufsize != 0) { - option = rxbufsize; - rc = -sock_setsockopt (C2B_SOCK(sock), SOL_SOCKET, SO_RCVBUF, - (char *)&option, sizeof (option)); - if (rc != 0) { - CERROR ("Can't set receive buffer %d: %d\n", - option, rc); - return (rc); - } - } - return 0; -} - -int -libcfs_sock_getbuf (cfs_socket_t *sock, int *txbufsize, int *rxbufsize) -{ - int option; - int optlen; - int rc; - - if (txbufsize != NULL) { - optlen = sizeof(option); - rc = -sock_getsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDBUF, - (char *)&option, &optlen); - if (rc != 0) { - CERROR ("Can't get send buffer size: %d\n", rc); - return (rc); - } - *txbufsize = option; - } - - if (rxbufsize != NULL) { - optlen = sizeof(option); - rc = -sock_getsockopt (C2B_SOCK(sock), SOL_SOCKET, SO_RCVBUF, - (char *)&option, &optlen); - if (rc != 0) { - CERROR ("Can't get receive buffer size: %d\n", rc); - return (rc); - } - *rxbufsize = option; - } - return 0; -} - -void -libcfs_sock_release (cfs_socket_t *sock) -{ - if (C2B_SOCK(sock) != NULL) { - sock_shutdown(C2B_SOCK(sock), 2); - sock_close(C2B_SOCK(sock)); - } - FREE(sock, M_TEMP); -} - -int -libcfs_sock_connect (cfs_socket_t **sockp, int *fatal, - __u32 local_ip, int local_port, - __u32 peer_ip, int peer_port) -{ - cfs_socket_t *sock; - struct sockaddr_in srvaddr; - int rc; - - rc = libcfs_sock_create(&sock, fatal, local_ip, local_port); - if (rc != 0) - return rc; - - bzero(&srvaddr, sizeof(srvaddr)); - srvaddr.sin_len = sizeof(struct sockaddr_in); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons(peer_port); - srvaddr.sin_addr.s_addr = htonl(peer_ip); - - rc = -sock_connect(C2B_SOCK(sock), (struct sockaddr *)&srvaddr, 0); - if (rc == 0) { - *sockp = sock; - return 0; - } - - *fatal = !(rc == -EADDRNOTAVAIL || rc == -EADDRINUSE); - CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); - - libcfs_sock_release(sock); - return rc; -} - -#else /* !__DARWIN8__ */ - -/* - * To use bigger buffer for socket: - * 1. Increase nmbclusters (Cannot increased by sysctl because it's ready only, so - * we must patch kernel). - * 2. Increase net.inet.tcp.reass.maxsegments - * 3. Increase net.inet.tcp.sendspace - * 4. Increase net.inet.tcp.recvspace - * 5. Increase kern.ipc.maxsockbuf - */ -#define KSOCK_MAX_BUF (1152*1024) - -int -libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask) -{ - struct socket *so; - struct ifreq ifr; - int nob; - int rc; - __u32 val; - CFS_DECL_FUNNEL_DATA; - - CFS_NET_IN; - rc = socreate(PF_INET, &so, SOCK_STREAM, 0); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return (-rc); - } - nob = strnlen(name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - CERROR("Interface name %s too long\n", name); - rc = -EINVAL; - goto out; - } - - CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ); - strcpy(ifr.ifr_name, name); - CFS_NET_IN; - rc = ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ifr, current_proc()); - CFS_NET_EX; - - if (rc != 0) { - CERROR("Can't get flags for interface %s\n", name); - goto out; - } - if ((ifr.ifr_flags & IFF_UP) == 0) { - CDEBUG(D_NET, "Interface %s down\n", name); - *up = 0; - *ip = *mask = 0; - goto out; - } - - *up = 1; - strcpy(ifr.ifr_name, name); - *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin(); - CFS_NET_IN; - rc = ifioctl(so, SIOCGIFADDR, (caddr_t)&ifr, current_proc()); - CFS_NET_EX; - - if (rc != 0) { - CERROR("Can't get IP address for interface %s\n", name); - goto out; - } - - val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; - *ip = ntohl(val); - - strcpy(ifr.ifr_name, name); - *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin(); - CFS_NET_IN; - rc = ifioctl(so, SIOCGIFNETMASK, (caddr_t)&ifr, current_proc()); - CFS_NET_EX; - - if (rc != 0) { - CERROR("Can't get netmask for interface %s\n", name); - goto out; - } - - val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; - *mask = ntohl(val); -out: - CFS_NET_IN; - soclose(so); - CFS_NET_EX; - return -rc; -} - -int -libcfs_ipif_enumerate (char ***namesp) -{ - /* Allocate and fill in 'names', returning # interfaces/error */ - char **names; - int toobig; - int nalloc; - int nfound; - struct socket *so; - struct ifreq *ifr; - struct ifconf ifc; - int rc; - int nob; - int i; - CFS_DECL_FUNNEL_DATA; - - CFS_NET_IN; - rc = socreate(PF_INET, &so, SOCK_STREAM, 0); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return (-rc); - } - - nalloc = 16; /* first guess at max interfaces */ - toobig = 0; - for (;;) { - if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) { - toobig = 1; - nalloc = PAGE_CACHE_SIZE/sizeof(*ifr); - CWARN("Too many interfaces: only enumerating first %d\n", - nalloc); - } - - LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); - if (ifr == NULL) { - CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc); - rc = -ENOMEM; - goto out0; - } - - ifc.ifc_buf = (char *)ifr; - ifc.ifc_len = nalloc * sizeof(*ifr); - - CFS_NET_IN; - rc = -ifioctl(so, SIOCGIFCONF, (caddr_t)&ifc, current_proc()); - CFS_NET_EX; - - if (rc < 0) { - CERROR ("Error %d enumerating interfaces\n", rc); - goto out1; - } - - nfound = ifc.ifc_len/sizeof(*ifr); - LASSERT (nfound <= nalloc); - - if (nfound < nalloc || toobig) - break; - - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); - nalloc *= 2; - } - if (nfound == 0) - goto out1; - - LIBCFS_ALLOC(names, nfound * sizeof(*names)); - if (names == NULL) { - rc = -ENOMEM; - goto out1; - } - /* NULL out all names[i] */ - memset (names, 0, nfound * sizeof(*names)); - - for (i = 0; i < nfound; i++) { - - nob = strnlen (ifr[i].ifr_name, IFNAMSIZ); - if (nob == IFNAMSIZ) { - /* no space for terminating NULL */ - CERROR("interface name %.*s too long (%d max)\n", - nob, ifr[i].ifr_name, IFNAMSIZ); - rc = -ENAMETOOLONG; - goto out2; - } - - LIBCFS_ALLOC(names[i], IFNAMSIZ); - if (names[i] == NULL) { - rc = -ENOMEM; - goto out2; - } - - memcpy(names[i], ifr[i].ifr_name, nob); - names[i][nob] = 0; - } - - *namesp = names; - rc = nfound; - -out2: - if (rc < 0) - libcfs_ipif_free_enumeration(names, nfound); -out1: - LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); -out0: - CFS_NET_IN; - soclose(so); - CFS_NET_EX; - return rc; -} - -static int -libcfs_sock_create (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port) -{ - struct sockaddr_in locaddr; - struct socket *so; - struct sockopt sopt; - int option; - int rc; - CFS_DECL_FUNNEL_DATA; - - *fatal = 1; - CFS_NET_IN; - rc = socreate(PF_INET, &so, SOCK_STREAM, 0); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't create socket: %d\n", rc); - return (-rc); - } - - bzero(&sopt, sizeof sopt); - option = 1; - sopt.sopt_level = SOL_SOCKET; - sopt.sopt_name = SO_REUSEADDR; - sopt.sopt_val = &option; - sopt.sopt_valsize = sizeof(option); - CFS_NET_IN; - rc = sosetopt(so, &sopt); - if (rc != 0) { - CFS_NET_EX; - CERROR ("Can't set sock reuse address: %d\n", rc); - goto out; - } - /* can't specify a local port without a local IP */ - LASSERT (local_ip == 0 || local_port != 0); - - if (local_ip != 0 || local_port != 0) { - bzero (&locaddr, sizeof (locaddr)); - locaddr.sin_len = sizeof(struct sockaddr_in); - locaddr.sin_family = AF_INET; - locaddr.sin_port = htons (local_port); - locaddr.sin_addr.s_addr = (local_ip != 0) ? htonl(local_ip) : - INADDR_ANY; - - rc = sobind(so, (struct sockaddr *)&locaddr); - if (rc == EADDRINUSE) { - CFS_NET_EX; - CDEBUG(D_NET, "Port %d already in use\n", local_port); - *fatal = 0; - goto out; - } - if (rc != 0) { - CFS_NET_EX; - CERROR ("Can't bind to local IP Address %u.%u.%u.%u: %d\n", - HIPQUAD(local_ip), rc); - goto out; - } - } - *sockp = so; - return 0; -out: - CFS_NET_IN; - soclose(so); - CFS_NET_EX; - return -rc; -} - -int -libcfs_sock_listen (struct socket **sockp, - __u32 local_ip, int local_port, int backlog) -{ - int fatal; - int rc; - CFS_DECL_FUNNEL_DATA; - - rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port); - if (rc != 0) { - if (!fatal) - CERROR("Can't create socket: port %d already in use\n", - local_port); - return rc; - } - CFS_NET_IN; - rc = solisten(*sockp, backlog); - CFS_NET_EX; - if (rc == 0) - return 0; - CERROR("Can't set listen backlog %d: %d\n", backlog, rc); - CFS_NET_IN; - soclose(*sockp); - CFS_NET_EX; - return -rc; -} - -int -libcfs_sock_accept (struct socket **newsockp, struct socket *sock) -{ - struct socket *so; - struct sockaddr *sa; - int error, s; - CFS_DECL_FUNNEL_DATA; - - CFS_NET_IN; - s = splnet(); - if ((sock->so_options & SO_ACCEPTCONN) == 0) { - splx(s); - CFS_NET_EX; - return (-EINVAL); - } - - if ((sock->so_state & SS_NBIO) && sock->so_comp.tqh_first == NULL) { - splx(s); - CFS_NET_EX; - return (-EWOULDBLOCK); - } - - error = 0; - while (TAILQ_EMPTY(&sock->so_comp) && sock->so_error == 0) { - if (sock->so_state & SS_CANTRCVMORE) { - sock->so_error = ECONNABORTED; - break; - } - error = tsleep((caddr_t)&sock->so_timeo, PSOCK | PCATCH, - "accept", 0); - if (error) { - splx(s); - CFS_NET_EX; - return (-error); - } - } - if (sock->so_error) { - error = sock->so_error; - sock->so_error = 0; - splx(s); - CFS_NET_EX; - return (-error); - } - - /* - * At this point we know that there is at least one connection - * ready to be accepted. Remove it from the queue prior to - * allocating the file descriptor for it since falloc() may - * block allowing another process to accept the connection - * instead. - */ - so = TAILQ_FIRST(&sock->so_comp); - TAILQ_REMOVE(&sock->so_comp, so, so_list); - sock->so_qlen--; - - so->so_state &= ~SS_COMP; - so->so_head = NULL; - sa = 0; - (void) soaccept(so, &sa); - - *newsockp = so; - FREE(sa, M_SONAME); - splx(s); - CFS_NET_EX; - return (-error); -} - -void -libcfs_sock_abort_accept (struct socket *sock) -{ - wakeup(&sock->so_timeo); -} - -/* - * XXX Liang: timeout for write is not supported yet. - */ -int -libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) -{ - int rc; - CFS_DECL_NET_DATA; - - while (nob > 0) { - struct iovec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct uio suio = { - .uio_iov = &iov, - .uio_iovcnt = 1, - .uio_offset = 0, - .uio_resid = nob, - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_WRITE, - .uio_procp = NULL - }; - - CFS_NET_IN; - rc = sosend(sock, NULL, &suio, (struct mbuf *)0, (struct mbuf *)0, 0); - CFS_NET_EX; - - if (rc != 0) { - if ( suio.uio_resid != nob && ( rc == ERESTART || rc == EINTR ||\ - rc == EWOULDBLOCK)) - rc = 0; - if ( rc != 0 ) - return -rc; - rc = nob - suio.uio_resid; - buffer = ((char *)buffer) + rc; - nob = suio.uio_resid; - continue; - } - break; - } - return (0); -} - -/* - * XXX Liang: timeout for read is not supported yet. - */ -int -libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) -{ - int rc; - CFS_DECL_NET_DATA; - - while (nob > 0) { - struct iovec iov = { - .iov_base = buffer, - .iov_len = nob - }; - struct uio ruio = { - .uio_iov = &iov, - .uio_iovcnt = 1, - .uio_offset = 0, - .uio_resid = nob, - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_READ, - .uio_procp = NULL - }; - - CFS_NET_IN; - rc = soreceive(sock, (struct sockaddr **)0, &ruio, (struct mbuf **)0, (struct mbuf **)0, (int *)0); - CFS_NET_EX; - - if (rc != 0) { - if ( ruio.uio_resid != nob && ( rc == ERESTART || rc == EINTR ||\ - rc == EWOULDBLOCK)) - rc = 0; - if (rc != 0) - return -rc; - rc = nob - ruio.uio_resid; - buffer = ((char *)buffer) + rc; - nob = ruio.uio_resid; - continue; - } - break; - } - return (0); -} - -int -libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) -{ - struct sockopt sopt; - int rc = 0; - int option; - CFS_DECL_NET_DATA; - - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = SOL_SOCKET; - sopt.sopt_val = &option; - sopt.sopt_valsize = sizeof(option); - - if (txbufsize != 0) { - option = txbufsize; - if (option > KSOCK_MAX_BUF) - option = KSOCK_MAX_BUF; - - sopt.sopt_name = SO_SNDBUF; - CFS_NET_IN; - rc = sosetopt(sock, &sopt); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't set send buffer %d: %d\n", - option, rc); - - return -rc; - } - } - - if (rxbufsize != 0) { - option = rxbufsize; - sopt.sopt_name = SO_RCVBUF; - CFS_NET_IN; - rc = sosetopt(sock, &sopt); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't set receive buffer %d: %d\n", - option, rc); - return -rc; - } - } - return 0; -} - -int -libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port) -{ - struct sockaddr_in *sin; - struct sockaddr *sa = NULL; - int rc; - CFS_DECL_NET_DATA; - - if (remote != 0) { - CFS_NET_IN; - rc = sock->so_proto->pr_usrreqs->pru_peeraddr(sock, &sa); - CFS_NET_EX; - - if (rc != 0) { - if (sa) FREE(sa, M_SONAME); - CERROR ("Error %d getting sock peer IP\n", rc); - return -rc; - } - } else { - CFS_NET_IN; - rc = sock->so_proto->pr_usrreqs->pru_sockaddr(sock, &sa); - CFS_NET_EX; - if (rc != 0) { - if (sa) FREE(sa, M_SONAME); - CERROR ("Error %d getting sock local IP\n", rc); - return -rc; - } - } - if (sa != NULL) { - sin = (struct sockaddr_in *)sa; - if (ip != NULL) - *ip = ntohl (sin->sin_addr.s_addr); - if (port != NULL) - *port = ntohs (sin->sin_port); - if (sa) - FREE(sa, M_SONAME); - } - return 0; -} - -int -libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize) -{ - struct sockopt sopt; - int rc; - CFS_DECL_NET_DATA; - - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = SOL_SOCKET; - - if (txbufsize != NULL) { - sopt.sopt_val = txbufsize; - sopt.sopt_valsize = sizeof(*txbufsize); - sopt.sopt_name = SO_SNDBUF; - CFS_NET_IN; - rc = sogetopt(sock, &sopt); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't get send buffer size: %d\n", rc); - return -rc; - } - } - - if (rxbufsize != NULL) { - sopt.sopt_val = rxbufsize; - sopt.sopt_valsize = sizeof(*rxbufsize); - sopt.sopt_name = SO_RCVBUF; - CFS_NET_IN; - rc = sogetopt(sock, &sopt); - CFS_NET_EX; - if (rc != 0) { - CERROR ("Can't get receive buffer size: %d\n", rc); - return -rc; - } - } - return 0; -} - -int -libcfs_sock_connect (struct socket **sockp, int *fatal, - __u32 local_ip, int local_port, - __u32 peer_ip, int peer_port) -{ - struct sockaddr_in srvaddr; - struct socket *so; - int s; - int rc; - CFS_DECL_FUNNEL_DATA; - - rc = libcfs_sock_create(sockp, fatal, local_ip, local_port); - if (rc != 0) - return rc; - so = *sockp; - bzero(&srvaddr, sizeof(srvaddr)); - srvaddr.sin_len = sizeof(struct sockaddr_in); - srvaddr.sin_family = AF_INET; - srvaddr.sin_port = htons (peer_port); - srvaddr.sin_addr.s_addr = htonl (peer_ip); - - CFS_NET_IN; - rc = soconnect(so, (struct sockaddr *)&srvaddr); - if (rc != 0) { - CFS_NET_EX; - if (rc != EADDRNOTAVAIL && rc != EADDRINUSE) - CNETERR("Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); - goto out; - } - s = splnet(); - while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { - CDEBUG(D_NET, "ksocknal sleep for waiting auto_connect.\n"); - (void) tsleep((caddr_t)&so->so_timeo, PSOCK, "ksocknal_conn", hz); - } - if ((rc = so->so_error) != 0) { - so->so_error = 0; - splx(s); - CFS_NET_EX; - CNETERR("Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); - goto out; - } - LASSERT(so->so_state & SS_ISCONNECTED); - splx(s); - CFS_NET_EX; - if (sockp) - *sockp = so; - return (0); -out: - CFS_NET_IN; - soshutdown(so, 2); - soclose(so); - CFS_NET_EX; - return (-rc); -} - -void -libcfs_sock_release (struct socket *sock) -{ - CFS_DECL_FUNNEL_DATA; - CFS_NET_IN; - soshutdown(sock, 0); - CFS_NET_EX; -} - -#endif diff --git a/libcfs/libcfs/darwin/darwin-tracefile.c b/libcfs/libcfs/darwin/darwin-tracefile.c deleted file mode 100644 index 7ef1cad..0000000 --- a/libcfs/libcfs/darwin/darwin-tracefile.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_LNET -#define LUSTRE_TRACEFILE_PRIVATE -#include -#include "tracefile.h" - -/* - * We can't support smp tracefile currently. - * Everything is put on one cpu. - */ - -#define M_TCD_MAX_PAGES (128 * 1280) - -static long max_permit_mb = (64 * 1024); - -spinlock_t trace_cpu_serializer; - -/* - * thread currently executing tracefile code or NULL if none does. Used to - * detect recursive calls to libcfs_debug_msg(). - */ -static thread_t trace_owner = NULL; - -extern int get_preemption_level(void); -extern atomic_t tage_allocated; - -struct rw_semaphore tracefile_sem; - -int tracefile_init_arch() { - init_rwsem(&tracefile_sem); -#error "Todo: initialise per-cpu console buffers" - return 0; -} - -void tracefile_fini_arch() { - fini_rwsem(&tracefile_sem); -} - -void tracefile_read_lock() { - down_read(&tracefile_sem); -} - -void tracefile_read_unlock() { - up_read(&tracefile_sem); -} - -void tracefile_write_lock() { - down_write(&tracefile_sem); -} - -void tracefile_write_unlock() { - up_write(&tracefile_sem); -} - -char *trace_get_console_buffer(void) -{ -#error "todo: return a per-cpu/interrupt console buffer and disable pre-emption" -} - -void trace_put_console_buffer(char *buffer) -{ -#error "todo: re-enable pre-emption" -} - -struct trace_cpu_data *trace_get_tcd(void) -{ - struct trace_cpu_data *tcd; - int nr_pages; - struct list_head pages; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - - /* - * debugging check for recursive call to libcfs_debug_msg() - */ - if (trace_owner == current_thread()) { - /* - * Cannot assert here. - */ - printk(KERN_EMERG "recursive call to %s", __FUNCTION__); - /* - * "The death of God left the angels in a strange position." - */ - cfs_enter_debugger(); - } - tcd = &trace_data[0].tcd; - INIT_LIST_HEAD(&pages); - if (get_preemption_level() == 0) - nr_pages = trace_refill_stock(tcd, GFP_IOFS, &pages); - else - nr_pages = 0; - spin_lock(&trace_cpu_serializer); - trace_owner = current_thread(); - tcd->tcd_cur_stock_pages += nr_pages; - list_splice(&pages, &tcd->tcd_stock_pages); - return tcd; -} - -extern void raw_page_death_row_clean(void); - -void __trace_put_tcd(struct trace_cpu_data *tcd) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - LASSERT(trace_owner == current_thread()); - trace_owner = NULL; - spin_unlock(&trace_cpu_serializer); - if (get_preemption_level() == 0) - /* purge all pending pages */ - raw_page_death_row_clean(); -} - -int tcd_owns_tage(struct trace_cpu_data *tcd, struct trace_page *tage) -{ - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - /* XNU has global tcd, and all pages are owned by it */ - return 1; -} - -void -set_ptldebug_header(struct ptldebug_header *header, int subsys, int mask, - const int line, unsigned long stack) -{ - struct timeval tv; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - do_gettimeofday(&tv); - header->ph_subsys = subsys; - header->ph_mask = mask; - header->ph_cpu_id = smp_processor_id(); - header->ph_type = 0; - header->ph_sec = (__u32)tv.tv_sec; - header->ph_usec = tv.tv_usec; - header->ph_stack = stack; - header->ph_pid = current_pid(); - header->ph_line_num = line; - header->ph_extern_pid = (__u32)current_thread(); -} - -void print_to_console(struct ptldebug_header *hdr, int mask, const char *buf, - int len, const char *file, const char *fn) -{ - char *prefix = "Lustre", *ptype = KERN_INFO; - - /* - * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT) - * from here: this will lead to infinite recursion. - */ - if ((mask & D_EMERG) != 0) { - prefix = "LustreError"; - ptype = KERN_EMERG; - } else if ((mask & D_ERROR) != 0) { - prefix = "LustreError"; - ptype = KERN_ERR; - } else if ((mask & D_WARNING) != 0) { - prefix = "Lustre"; - ptype = KERN_WARNING; - } else if ((mask & libcfs_printk) != 0 || (mask & D_CONSOLE)) { - prefix = "Lustre"; - ptype = KERN_INFO; - } - - if ((mask & D_CONSOLE) != 0) { - printk("%s%s: %.*s", ptype, prefix, len, buf); - } else { - printk("%s%s: %d:%d:(%s:%d:%s()) %*s", - ptype, prefix, hdr->ph_pid, hdr->ph_extern_pid, - file, hdr->ph_line_num, fn, len, buf); - } -} - -int trace_max_debug_mb(void) -{ - return max_permit_mb; -} diff --git a/libcfs/libcfs/darwin/darwin-utils.c b/libcfs/libcfs/darwin/darwin-utils.c deleted file mode 100644 index 909b586..0000000 --- a/libcfs/libcfs/darwin/darwin-utils.c +++ /dev/null @@ -1,595 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/darwin/darwin-utils.c - * - * Darwin porting library - * Make things easy to port - * - * Author: Phil Schwan - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include -#include -#include -#include -#include -#include - -#include - -#ifndef isspace -inline int -isspace(char c) -{ - return (c == ' ' || c == '\t' || c == '\n' || c == '\12'); -} -#endif - -char * strpbrk(const char * cs,const char * ct) -{ - const char *sc1,*sc2; - - for( sc1 = cs; *sc1 != '\0'; ++sc1) { - for( sc2 = ct; *sc2 != '\0'; ++sc2) { - if (*sc1 == *sc2) - return (char *) sc1; - } - } - return NULL; -} - -char * strsep(char **s, const char *ct) -{ - char *sbegin = *s, *end; - - if (sbegin == NULL) - return NULL; - end = strpbrk(sbegin, ct); - if (end != NULL) - *end++ = '\0'; - *s = end; - - return sbegin; -} - -size_t strnlen(const char * s, size_t count) -{ - const char *sc; - - for (sc = s; count-- && *sc != '\0'; ++sc) - /* nothing */; - return sc - s; -} - -char * -strstr(const char *in, const char *str) -{ - char c; - size_t len; - - c = *str++; - if (!c) - return (char *) in; // Trivial empty string case - len = strlen(str); - do { - char sc; - do { - sc = *in++; - if (!sc) - return (char *) 0; - } while (sc != c); - } while (strncmp(in, str, len) != 0); - return (char *) (in - 1); -} - -char * -strrchr(const char *p, int ch) -{ - const char *end = p + strlen(p); - do { - if (*end == (char)ch) - return (char *)end; - } while (--end >= p); - return NULL; -} - -char * -ul2dstr(unsigned long address, char *buf, int len) -{ - char *pos = buf + len - 1; - - if (len <= 0 || !buf) - return NULL; - *pos = 0; - while (address) { - if (!--len) break; - *--pos = address % 10 + '0'; - address /= 10; - } - return pos; -} - -/* - * miscellaneous libcfs stuff - */ - -/* - * Convert server error code to client format. - * Linux errno.h. - */ - -/* obtained by - * - * cc /usr/include/asm/errno.h -E -dM | grep '#define E' | sort -n -k3,3 - * - */ -enum linux_errnos { - LINUX_EPERM = 1, - LINUX_ENOENT = 2, - LINUX_ESRCH = 3, - LINUX_EINTR = 4, - LINUX_EIO = 5, - LINUX_ENXIO = 6, - LINUX_E2BIG = 7, - LINUX_ENOEXEC = 8, - LINUX_EBADF = 9, - LINUX_ECHILD = 10, - LINUX_EAGAIN = 11, - LINUX_ENOMEM = 12, - LINUX_EACCES = 13, - LINUX_EFAULT = 14, - LINUX_ENOTBLK = 15, - LINUX_EBUSY = 16, - LINUX_EEXIST = 17, - LINUX_EXDEV = 18, - LINUX_ENODEV = 19, - LINUX_ENOTDIR = 20, - LINUX_EISDIR = 21, - LINUX_EINVAL = 22, - LINUX_ENFILE = 23, - LINUX_EMFILE = 24, - LINUX_ENOTTY = 25, - LINUX_ETXTBSY = 26, - LINUX_EFBIG = 27, - LINUX_ENOSPC = 28, - LINUX_ESPIPE = 29, - LINUX_EROFS = 30, - LINUX_EMLINK = 31, - LINUX_EPIPE = 32, - LINUX_EDOM = 33, - LINUX_ERANGE = 34, - LINUX_EDEADLK = 35, - LINUX_ENAMETOOLONG = 36, - LINUX_ENOLCK = 37, - LINUX_ENOSYS = 38, - LINUX_ENOTEMPTY = 39, - LINUX_ELOOP = 40, - LINUX_ENOMSG = 42, - LINUX_EIDRM = 43, - LINUX_ECHRNG = 44, - LINUX_EL2NSYNC = 45, - LINUX_EL3HLT = 46, - LINUX_EL3RST = 47, - LINUX_ELNRNG = 48, - LINUX_EUNATCH = 49, - LINUX_ENOCSI = 50, - LINUX_EL2HLT = 51, - LINUX_EBADE = 52, - LINUX_EBADR = 53, - LINUX_EXFULL = 54, - LINUX_ENOANO = 55, - LINUX_EBADRQC = 56, - LINUX_EBADSLT = 57, - LINUX_EBFONT = 59, - LINUX_ENOSTR = 60, - LINUX_ENODATA = 61, - LINUX_ETIME = 62, - LINUX_ENOSR = 63, - LINUX_ENONET = 64, - LINUX_ENOPKG = 65, - LINUX_EREMOTE = 66, - LINUX_ENOLINK = 67, - LINUX_EADV = 68, - LINUX_ESRMNT = 69, - LINUX_ECOMM = 70, - LINUX_EPROTO = 71, - LINUX_EMULTIHOP = 72, - LINUX_EDOTDOT = 73, - LINUX_EBADMSG = 74, - LINUX_EOVERFLOW = 75, - LINUX_ENOTUNIQ = 76, - LINUX_EBADFD = 77, - LINUX_EREMCHG = 78, - LINUX_ELIBACC = 79, - LINUX_ELIBBAD = 80, - LINUX_ELIBSCN = 81, - LINUX_ELIBMAX = 82, - LINUX_ELIBEXEC = 83, - LINUX_EILSEQ = 84, - LINUX_ERESTART = 85, - LINUX_ESTRPIPE = 86, - LINUX_EUSERS = 87, - LINUX_ENOTSOCK = 88, - LINUX_EDESTADDRREQ = 89, - LINUX_EMSGSIZE = 90, - LINUX_EPROTOTYPE = 91, - LINUX_ENOPROTOOPT = 92, - LINUX_EPROTONOSUPPORT = 93, - LINUX_ESOCKTNOSUPPORT = 94, - LINUX_EOPNOTSUPP = 95, - LINUX_EPFNOSUPPORT = 96, - LINUX_EAFNOSUPPORT = 97, - LINUX_EADDRINUSE = 98, - LINUX_EADDRNOTAVAIL = 99, - LINUX_ENETDOWN = 100, - LINUX_ENETUNREACH = 101, - LINUX_ENETRESET = 102, - LINUX_ECONNABORTED = 103, - LINUX_ECONNRESET = 104, - LINUX_ENOBUFS = 105, - LINUX_EISCONN = 106, - LINUX_ENOTCONN = 107, - LINUX_ESHUTDOWN = 108, - LINUX_ETOOMANYREFS = 109, - LINUX_ETIMEDOUT = 110, - LINUX_ECONNREFUSED = 111, - LINUX_EHOSTDOWN = 112, - LINUX_EHOSTUNREACH = 113, - LINUX_EALREADY = 114, - LINUX_EINPROGRESS = 115, - LINUX_ESTALE = 116, - LINUX_EUCLEAN = 117, - LINUX_ENOTNAM = 118, - LINUX_ENAVAIL = 119, - LINUX_EISNAM = 120, - LINUX_EREMOTEIO = 121, - LINUX_EDQUOT = 122, - LINUX_ENOMEDIUM = 123, - LINUX_EMEDIUMTYPE = 124, - - /* - * we don't need these, but for completeness.. - */ - LINUX_EDEADLOCK = LINUX_EDEADLK, - LINUX_EWOULDBLOCK = LINUX_EAGAIN -}; - -int convert_server_error(__u64 ecode) -{ - int sign; - int code; - - static int errno_xlate[] = { - /* success is always success */ - [0] = 0, - [LINUX_EPERM] = EPERM, - [LINUX_ENOENT] = ENOENT, - [LINUX_ESRCH] = ESRCH, - [LINUX_EINTR] = EINTR, - [LINUX_EIO] = EIO, - [LINUX_ENXIO] = ENXIO, - [LINUX_E2BIG] = E2BIG, - [LINUX_ENOEXEC] = ENOEXEC, - [LINUX_EBADF] = EBADF, - [LINUX_ECHILD] = ECHILD, - [LINUX_EAGAIN] = EAGAIN, - [LINUX_ENOMEM] = ENOMEM, - [LINUX_EACCES] = EACCES, - [LINUX_EFAULT] = EFAULT, - [LINUX_ENOTBLK] = ENOTBLK, - [LINUX_EBUSY] = EBUSY, - [LINUX_EEXIST] = EEXIST, - [LINUX_EXDEV] = EXDEV, - [LINUX_ENODEV] = ENODEV, - [LINUX_ENOTDIR] = ENOTDIR, - [LINUX_EISDIR] = EISDIR, - [LINUX_EINVAL] = EINVAL, - [LINUX_ENFILE] = ENFILE, - [LINUX_EMFILE] = EMFILE, - [LINUX_ENOTTY] = ENOTTY, - [LINUX_ETXTBSY] = ETXTBSY, - [LINUX_EFBIG] = EFBIG, - [LINUX_ENOSPC] = ENOSPC, - [LINUX_ESPIPE] = ESPIPE, - [LINUX_EROFS] = EROFS, - [LINUX_EMLINK] = EMLINK, - [LINUX_EPIPE] = EPIPE, - [LINUX_EDOM] = EDOM, - [LINUX_ERANGE] = ERANGE, - [LINUX_EDEADLK] = EDEADLK, - [LINUX_ENAMETOOLONG] = ENAMETOOLONG, - [LINUX_ENOLCK] = ENOLCK, - [LINUX_ENOSYS] = ENOSYS, - [LINUX_ENOTEMPTY] = ENOTEMPTY, - [LINUX_ELOOP] = ELOOP, - [LINUX_ENOMSG] = ENOMSG, - [LINUX_EIDRM] = EIDRM, - [LINUX_ECHRNG] = EINVAL /* ECHRNG */, - [LINUX_EL2NSYNC] = EINVAL /* EL2NSYNC */, - [LINUX_EL3HLT] = EINVAL /* EL3HLT */, - [LINUX_EL3RST] = EINVAL /* EL3RST */, - [LINUX_ELNRNG] = EINVAL /* ELNRNG */, - [LINUX_EUNATCH] = EINVAL /* EUNATCH */, - [LINUX_ENOCSI] = EINVAL /* ENOCSI */, - [LINUX_EL2HLT] = EINVAL /* EL2HLT */, - [LINUX_EBADE] = EINVAL /* EBADE */, - [LINUX_EBADR] = EBADRPC, - [LINUX_EXFULL] = EINVAL /* EXFULL */, - [LINUX_ENOANO] = EINVAL /* ENOANO */, - [LINUX_EBADRQC] = EINVAL /* EBADRQC */, - [LINUX_EBADSLT] = EINVAL /* EBADSLT */, - [LINUX_EBFONT] = EINVAL /* EBFONT */, - [LINUX_ENOSTR] = EINVAL /* ENOSTR */, - [LINUX_ENODATA] = EINVAL /* ENODATA */, - [LINUX_ETIME] = EINVAL /* ETIME */, - [LINUX_ENOSR] = EINVAL /* ENOSR */, - [LINUX_ENONET] = EINVAL /* ENONET */, - [LINUX_ENOPKG] = EINVAL /* ENOPKG */, - [LINUX_EREMOTE] = EREMOTE, - [LINUX_ENOLINK] = EINVAL /* ENOLINK */, - [LINUX_EADV] = EINVAL /* EADV */, - [LINUX_ESRMNT] = EINVAL /* ESRMNT */, - [LINUX_ECOMM] = EINVAL /* ECOMM */, - [LINUX_EPROTO] = EPROTOTYPE, - [LINUX_EMULTIHOP] = EINVAL /* EMULTIHOP */, - [LINUX_EDOTDOT] = EINVAL /* EDOTDOT */, - [LINUX_EBADMSG] = EINVAL /* EBADMSG */, - [LINUX_EOVERFLOW] = EOVERFLOW, - [LINUX_ENOTUNIQ] = EINVAL /* ENOTUNIQ */, - [LINUX_EBADFD] = EINVAL /* EBADFD */, - [LINUX_EREMCHG] = EINVAL /* EREMCHG */, - [LINUX_ELIBACC] = EINVAL /* ELIBACC */, - [LINUX_ELIBBAD] = EINVAL /* ELIBBAD */, - [LINUX_ELIBSCN] = EINVAL /* ELIBSCN */, - [LINUX_ELIBMAX] = EINVAL /* ELIBMAX */, - [LINUX_ELIBEXEC] = EINVAL /* ELIBEXEC */, - [LINUX_EILSEQ] = EILSEQ, - [LINUX_ERESTART] = EINVAL /* because ERESTART is - * negative in XNU */, - [LINUX_ESTRPIPE] = EINVAL /* ESTRPIPE */, - [LINUX_EUSERS] = EUSERS, - [LINUX_ENOTSOCK] = ENOTSOCK, - [LINUX_EDESTADDRREQ] = EDESTADDRREQ, - [LINUX_EMSGSIZE] = EMSGSIZE, - [LINUX_EPROTOTYPE] = EPROTOTYPE, - [LINUX_ENOPROTOOPT] = ENOPROTOOPT, - [LINUX_EPROTONOSUPPORT] = EPROTONOSUPPORT, - [LINUX_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT, - [LINUX_EOPNOTSUPP] = EOPNOTSUPP, - [LINUX_EPFNOSUPPORT] = EPFNOSUPPORT, - [LINUX_EAFNOSUPPORT] = EAFNOSUPPORT, - [LINUX_EADDRINUSE] = EADDRINUSE, - [LINUX_EADDRNOTAVAIL] = EADDRNOTAVAIL, - [LINUX_ENETDOWN] = ENETDOWN, - [LINUX_ENETUNREACH] = ENETUNREACH, - [LINUX_ENETRESET] = ENETRESET, - [LINUX_ECONNABORTED] = ECONNABORTED, - [LINUX_ECONNRESET] = ECONNRESET, - [LINUX_ENOBUFS] = ENOBUFS, - [LINUX_EISCONN] = EISCONN, - [LINUX_ENOTCONN] = ENOTCONN, - [LINUX_ESHUTDOWN] = ESHUTDOWN, - [LINUX_ETOOMANYREFS] = ETOOMANYREFS, - [LINUX_ETIMEDOUT] = ETIMEDOUT, - [LINUX_ECONNREFUSED] = ECONNREFUSED, - [LINUX_EHOSTDOWN] = EHOSTDOWN, - [LINUX_EHOSTUNREACH] = EHOSTUNREACH, - [LINUX_EALREADY] = EALREADY, - [LINUX_EINPROGRESS] = EINPROGRESS, - [LINUX_ESTALE] = ESTALE, - [LINUX_EUCLEAN] = EINVAL /* EUCLEAN */, - [LINUX_ENOTNAM] = EINVAL /* ENOTNAM */, - [LINUX_ENAVAIL] = EINVAL /* ENAVAIL */, - [LINUX_EISNAM] = EINVAL /* EISNAM */, - [LINUX_EREMOTEIO] = EINVAL /* EREMOTEIO */, - [LINUX_EDQUOT] = EDQUOT, - [LINUX_ENOMEDIUM] = EINVAL /* ENOMEDIUM */, - [LINUX_EMEDIUMTYPE] = EINVAL /* EMEDIUMTYPE */, - }; - code = (int)ecode; - if (code >= 0) { - sign = +1; - } else { - sign = -1; - code = -code; - } - if (code < (sizeof errno_xlate) / (sizeof errno_xlate[0])) { - code = errno_xlate[code]; - LASSERT(code >= 0); - } - return sign * code; -} - -enum { - LINUX_O_RDONLY = 00, - LINUX_O_WRONLY = 01, - LINUX_O_RDWR = 02, - LINUX_O_CREAT = 0100, - LINUX_O_EXCL = 0200, - LINUX_O_NOCTTY = 0400, - LINUX_O_TRUNC = 01000, - LINUX_O_APPEND = 02000, - LINUX_O_NONBLOCK = 04000, - LINUX_O_NDELAY = LINUX_O_NONBLOCK, - LINUX_O_SYNC = 010000, - LINUX_O_FSYNC = LINUX_O_SYNC, - LINUX_O_ASYNC = 020000, - LINUX_O_DIRECT = 040000, - LINUX_O_NOFOLLOW = 0400000 -}; - -static inline void obit_convert(int *cflag, int *sflag, - unsigned cmask, unsigned smask) -{ - if (*cflag & cmask != 0) { - *sflag |= smask; - *cflag &= ~cmask; - } -} - -/* - * convert flag from XNU client to Linux _i386_ server. - */ -int convert_client_oflag(int cflag, int *result) -{ - int sflag = 0; - - cflag = 0; - obit_convert(&cflag, &sflag, O_RDONLY, LINUX_O_RDONLY); - obit_convert(&cflag, &sflag, O_WRONLY, LINUX_O_WRONLY); - obit_convert(&cflag, &sflag, O_RDWR, LINUX_O_RDWR); - obit_convert(&cflag, &sflag, O_NONBLOCK, LINUX_O_NONBLOCK); - obit_convert(&cflag, &sflag, O_APPEND, LINUX_O_APPEND); - obit_convert(&cflag, &sflag, O_ASYNC, LINUX_O_ASYNC); - obit_convert(&cflag, &sflag, O_FSYNC, LINUX_O_FSYNC); - obit_convert(&cflag, &sflag, O_NOFOLLOW, LINUX_O_NOFOLLOW); - obit_convert(&cflag, &sflag, O_CREAT, LINUX_O_CREAT); - obit_convert(&cflag, &sflag, O_TRUNC, LINUX_O_TRUNC); - obit_convert(&cflag, &sflag, O_EXCL, LINUX_O_EXCL); - obit_convert(&cflag, &sflag, O_CREAT, LINUX_O_CREAT); - obit_convert(&cflag, &sflag, O_NDELAY, LINUX_O_NDELAY); - obit_convert(&cflag, &sflag, O_NOCTTY, LINUX_O_NOCTTY); - /* - * Some more obscure BSD flags have no Linux counterparts: - * - * O_SHLOCK 0x0010 - * O_EXLOCK 0x0020 - * O_EVTONLY 0x8000 - * O_POPUP 0x80000000 - * O_ALERT 0x20000000 - */ - if (cflag == 0) { - *result = sflag; - return 0; - } else - return -EINVAL; -} - -#ifdef __DARWIN8__ -#else /* !__DARWIN8__ */ -extern int unix_syscall(); -extern int unix_syscall_return(); - -extern int ktrsysret(); -extern int ktrace(); - -extern int ast_taken(); -extern int ast_check(); - -extern int trap(); -extern int syscall_trace(); - -static int is_addr_in_range(void *addr, void *start, void *end) -{ - return start <= addr && addr <= end; -} - -extern void cfs_thread_agent (void); - -static int is_last_frame(void *addr) -{ - if (addr == NULL) - return 1; - else if (is_addr_in_range(addr, unix_syscall, unix_syscall_return)) - return 1; - else if (is_addr_in_range(addr, ktrsysret, ktrace)) - return 1; - else if (is_addr_in_range(addr, ast_taken, ast_check)) - return 1; - else if (is_addr_in_range(addr, trap, syscall_trace)) - return 1; - else if (is_addr_in_range(addr, cfs_thread_agent, kthread_run)) - return 1; - else - return 0; -} - -static void *get_frame(int i) -{ - void *result; - -#define CASE(i) case (i): result = __builtin_return_address(i); break - switch (i + 1) { - CASE(1); - CASE(2); - CASE(3); - CASE(4); - CASE(5); - CASE(6); - CASE(7); - CASE(8); - CASE(9); - CASE(10); - CASE(11); - CASE(12); - CASE(13); - CASE(14); - CASE(15); - CASE(16); - CASE(17); - CASE(18); - CASE(19); - CASE(20); - default: - panic("impossible frame number: %d\n", i); - result = NULL; - } - return result; -} - -void cfs_stack_trace_fill(struct cfs_stack_trace *trace) -{ - int i; - - memset(trace, 0, sizeof *trace); - for (i = 0; i < ARRAY_SIZE(trace->frame); ++ i) { - void *addr; - - addr = get_frame(i); - trace->frame[i] = addr; - if (is_last_frame(addr)) - break; - } -} - -void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no) -{ - if (0 <= frame_no && frame_no < ARRAY_SIZE(trace->frame)) - return trace->frame[frame_no]; - else - return NULL; -} -#endif /* !__DARWIN8__ */ diff --git a/libcfs/libcfs/libcfs.xcode/project.pbxproj b/libcfs/libcfs/libcfs.xcode/project.pbxproj deleted file mode 100644 index 479c21b..0000000 --- a/libcfs/libcfs/libcfs.xcode/project.pbxproj +++ /dev/null @@ -1,439 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 39; - objects = { - 06AA1262FFB20DD611CA28AA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - OPTIMIZATION_CFLAGS = "-O0"; - ZERO_LINK = YES; - }; - isa = PBXBuildStyle; - name = Development; - }; - 06AA1263FFB20DD611CA28AA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - ZERO_LINK = NO; - }; - isa = PBXBuildStyle; - name = Deployment; - }; -//060 -//061 -//062 -//063 -//064 -//080 -//081 -//082 -//083 -//084 - 089C1669FE841209C02AAC07 = { - buildSettings = { - }; - buildStyles = ( - 06AA1262FFB20DD611CA28AA, - 06AA1263FFB20DD611CA28AA, - ); - hasScannedForEncodings = 1; - isa = PBXProject; - mainGroup = 089C166AFE841209C02AAC07; - projectDirPath = ""; - targets = ( - 32A4FEB80562C75700D090E7, - ); - }; - 089C166AFE841209C02AAC07 = { - children = ( - 247142CAFF3F8F9811CA285C, - 089C167CFE841241C02AAC07, - 19C28FB6FE9D52B211CA2CBB, - ); - isa = PBXGroup; - name = libcfs; - refType = 4; - sourceTree = ""; - }; - 089C167CFE841241C02AAC07 = { - children = ( - 32A4FEC30562C75700D090E7, - ); - isa = PBXGroup; - name = Resources; - refType = 4; - sourceTree = ""; - }; -//080 -//081 -//082 -//083 -//084 -//190 -//191 -//192 -//193 -//194 - 19444794072D07AD00DAF9BC = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = tracefile.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19444795072D07AD00DAF9BC = { - fileRef = 19444794072D07AD00DAF9BC; - isa = PBXBuildFile; - settings = { - }; - }; - 19444796072D08AA00DAF9BC = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = debug.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19444797072D08AA00DAF9BC = { - fileRef = 19444796072D08AA00DAF9BC; - isa = PBXBuildFile; - settings = { - }; - }; - 19509C03072CD5FF00A958C3 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = module.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19509C04072CD5FF00A958C3 = { - fileRef = 19509C03072CD5FF00A958C3; - isa = PBXBuildFile; - settings = { - }; - }; - 19713B76072E8274004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_prim.c; - path = arch/xnu/cfs_prim.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713B77072E8274004E8469 = { - fileRef = 19713B76072E8274004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713BB7072E8281004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_mem.c; - path = arch/xnu/cfs_mem.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713BB8072E8281004E8469 = { - fileRef = 19713BB7072E8281004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713BF7072E828E004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_proc.c; - path = arch/xnu/cfs_proc.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713BF8072E828E004E8469 = { - fileRef = 19713BF7072E828E004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713C7A072E82B2004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_utils.c; - path = arch/xnu/cfs_utils.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713C7B072E82B2004E8469 = { - fileRef = 19713C7A072E82B2004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713CD6072E8A56004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_module.c; - path = arch/xnu/cfs_module.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713CD7072E8A56004E8469 = { - fileRef = 19713CD6072E8A56004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713D1B072E8E39004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_fs.c; - path = arch/xnu/cfs_fs.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713D1C072E8E39004E8469 = { - fileRef = 19713D1B072E8E39004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713D60072E9109004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = xnu_sync.c; - path = arch/xnu/xnu_sync.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713D61072E9109004E8469 = { - fileRef = 19713D60072E9109004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713DC2072F994D004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_tracefile.c; - path = arch/xnu/cfs_tracefile.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713DC3072F994D004E8469 = { - fileRef = 19713DC2072F994D004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19713E1C072FAFB5004E8469 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = cfs_debug.c; - path = arch/xnu/cfs_debug.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 19713E1D072FAFB5004E8469 = { - fileRef = 19713E1C072FAFB5004E8469; - isa = PBXBuildFile; - settings = { - }; - }; - 19C28FB6FE9D52B211CA2CBB = { - children = ( - 32A4FEC40562C75800D090E7, - ); - isa = PBXGroup; - name = Products; - refType = 4; - sourceTree = ""; - }; -//190 -//191 -//192 -//193 -//194 -//240 -//241 -//242 -//243 -//244 - 247142CAFF3F8F9811CA285C = { - children = ( - 19713E1C072FAFB5004E8469, - 19713DC2072F994D004E8469, - 19713D60072E9109004E8469, - 19713D1B072E8E39004E8469, - 19713CD6072E8A56004E8469, - 19713C7A072E82B2004E8469, - 19713BF7072E828E004E8469, - 19713BB7072E8281004E8469, - 19713B76072E8274004E8469, - 19444796072D08AA00DAF9BC, - 19444794072D07AD00DAF9BC, - 19509C03072CD5FF00A958C3, - ); - isa = PBXGroup; - name = Source; - path = ""; - refType = 4; - sourceTree = ""; - }; -//240 -//241 -//242 -//243 -//244 -//320 -//321 -//322 -//323 -//324 - 32A4FEB80562C75700D090E7 = { - buildPhases = ( - 32A4FEB90562C75700D090E7, - 32A4FEBA0562C75700D090E7, - 32A4FEBB0562C75700D090E7, - 32A4FEBD0562C75700D090E7, - 32A4FEBF0562C75700D090E7, - 32A4FEC00562C75700D090E7, - 32A4FEC10562C75700D090E7, - ); - buildRules = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; - GCC_WARN_UNKNOWN_PRAGMAS = NO; - HEADER_SEARCH_PATHS = ../include; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Extensions"; - LIBRARY_SEARCH_PATHS = ""; - MODULE_NAME = com.clusterfs.lustre.portals.libcfs; - MODULE_START = libcfs_start; - MODULE_STOP = libcfs_stop; - MODULE_VERSION = 1.0.1; - OTHER_CFLAGS = "-D__KERNEL__"; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = libcfs; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost"; - WRAPPER_EXTENSION = kext; - }; - dependencies = ( - ); - isa = PBXNativeTarget; - name = libcfs; - productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Extensions"; - productName = libcfs; - productReference = 32A4FEC40562C75800D090E7; - productType = "com.apple.product-type.kernel-extension"; - }; - 32A4FEB90562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXShellScriptBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPreprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; - }; - 32A4FEBA0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBB0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBD0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - 19509C04072CD5FF00A958C3, - 19444795072D07AD00DAF9BC, - 19444797072D08AA00DAF9BC, - 19713B77072E8274004E8469, - 19713BB8072E8281004E8469, - 19713BF8072E828E004E8469, - 19713C7B072E82B2004E8469, - 19713CD7072E8A56004E8469, - 19713D1C072E8E39004E8469, - 19713D61072E9109004E8469, - 19713DC3072F994D004E8469, - 19713E1D072FAFB5004E8469, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBF0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEC00562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEC10562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXShellScriptBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPostprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; - }; - 32A4FEC30562C75700D090E7 = { - isa = PBXFileReference; - lastKnownFileType = text.plist.xml; - path = Info.plist; - refType = 4; - sourceTree = ""; - }; - 32A4FEC40562C75800D090E7 = { - explicitFileType = wrapper.cfbundle; - includeInIndex = 0; - isa = PBXFileReference; - path = libcfs.kext; - refType = 3; - sourceTree = BUILT_PRODUCTS_DIR; - }; - }; - rootObject = 089C1669FE841209C02AAC07; -} diff --git a/libcfs/libcfs/user-mem.c b/libcfs/libcfs/user-mem.c index e3c0084..a7caf14 100644 --- a/libcfs/libcfs/user-mem.c +++ b/libcfs/libcfs/user-mem.c @@ -56,11 +56,7 @@ struct page *alloc_page(unsigned int flags) return NULL; pg->addr = NULL; -#if defined (__DARWIN__) - pg->addr = valloc(PAGE_CACHE_SIZE); -#else rc = posix_memalign(&pg->addr, PAGE_CACHE_SIZE, PAGE_CACHE_SIZE); -#endif if (rc != 0 || pg->addr == NULL) { free(pg); return NULL; diff --git a/libcfs/libcfs/user-tcpip.c b/libcfs/libcfs/user-tcpip.c index e779eb6..da0d2a1 100644 --- a/libcfs/libcfs/user-tcpip.c +++ b/libcfs/libcfs/user-tcpip.c @@ -50,9 +50,6 @@ #include #include #include -#if defined(__sun__) || defined(__sun) -#include -#endif #include /* diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 32eae63..1df8ca3 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -595,15 +595,6 @@ LN_CONFIG_SK_DATA_READY ]) # LN_PROG_LINUX # -# LN_PROG_DARWIN -# -# Darwin checks -# -AC_DEFUN([LN_PROG_DARWIN], [ -LB_DARWIN_CHECK_FUNCS([get_preemption_level]) -]) # LN_PROG_DARWIN - -# # LN_PATH_DEFAULTS # # default paths for installed files @@ -730,6 +721,5 @@ lnet/ulnds/Makefile lnet/ulnds/autoMakefile lnet/ulnds/socklnd/Makefile lnet/utils/Makefile -lnet/include/lnet/darwin/Makefile ]) ]) # LN_CONFIG_FILES diff --git a/lnet/include/lnet/Makefile.am b/lnet/include/lnet/Makefile.am index 4a7ac95..b7e824f 100644 --- a/lnet/include/lnet/Makefile.am +++ b/lnet/include/lnet/Makefile.am @@ -1,10 +1,7 @@ lnetdir=$(includedir)/lnet SUBDIRS = linux -if DARWIN -SUBDIRS += darwin -endif -DIST_SUBDIRS = linux darwin +DIST_SUBDIRS = linux EXTRA_DIST = api.h api-support.h \ lib-lnet.h lib-types.h lnet.h lnetctl.h types.h \ diff --git a/lnet/include/lnet/api-support.h b/lnet/include/lnet/api-support.h index fc9bc0f..650435c 100644 --- a/lnet/include/lnet/api-support.h +++ b/lnet/include/lnet/api-support.h @@ -37,8 +37,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported Operating System #endif diff --git a/lnet/include/lnet/darwin/.gitignore b/lnet/include/lnet/darwin/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/lnet/include/lnet/darwin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/lnet/include/lnet/darwin/Makefile.am b/lnet/include/lnet/darwin/Makefile.am deleted file mode 100644 index 29df720..0000000 --- a/lnet/include/lnet/darwin/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = lib-lnet.h lib-types.h lnet.h api-support.h diff --git a/lnet/include/lnet/darwin/api-support.h b/lnet/include/lnet/darwin/api-support.h deleted file mode 100644 index 8c46b85..0000000 --- a/lnet/include/lnet/darwin/api-support.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_API_SUPPORT_H__ -#define __DARWIN_API_SUPPORT_H__ - -#ifndef __LNET_API_SUPPORT_H__ -#error Do not #include this file directly. #include instead -#endif - -#ifndef __KERNEL__ -# include -# include -# include -# include - -/* Lots of POSIX dependencies to support PtlEQWait_timeout */ -# include -# include -# include - -# ifdef HAVE_LIBREADLINE -# include -typedef VFunction rl_vintfunc_t; -typedef VFunction rl_voidfunc_t; -# endif -#endif - - -#endif diff --git a/lnet/include/lnet/darwin/lib-lnet.h b/lnet/include/lnet/darwin/lib-lnet.h deleted file mode 100644 index 1863734..0000000 --- a/lnet/include/lnet/darwin/lib-lnet.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __LNET_DARWIN_LIB_LNET_H__ -#define __LNET_DARWIN_LIB_LNET_H__ - -#ifndef __LNET_LIB_LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -#include -#include - -#undef LNET_ROUTER - -#endif diff --git a/lnet/include/lnet/darwin/lib-types.h b/lnet/include/lnet/darwin/lib-types.h deleted file mode 100644 index 5dd29a3..0000000 --- a/lnet/include/lnet/darwin/lib-types.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __LNET_DARWIN_LIB_TYPES_H__ -#define __LNET_DARWIN_LIB_TYPES_H__ - -#ifndef __LNET_LIB_TYPES_H__ -#error Do not #include this file directly. #include instead -#endif - -#include -#include -#include - -/* - * XXX Liang: - * - * Temporary fix, because lnet_me_free()->kfree->FREE() can be blocked in xnu, - * at then same time we've taken LNET_LOCK(), which is a spinlock. - * by using LNET_USE_LIB_FREELIST, we can avoid calling of FREE(). - * - * A better solution is moving lnet_me_free() out from LNET_LOCK, it's not hard - * but need to be very careful and take some time. - */ -#define LNET_USE_LIB_FREELIST - -#endif diff --git a/lnet/include/lnet/darwin/lnet.h b/lnet/include/lnet/darwin/lnet.h deleted file mode 100644 index a9fdb12..0000000 --- a/lnet/include/lnet/darwin/lnet.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __LNET_DARWIN_LNET_H__ -#define __LNET_DARWIN_LNET_H__ - -#ifndef __LNET_H__ -#error Do not #include this file directly. #include instead -#endif - -/* - * lnet.h - * - * User application interface file - */ - -#include -#include - -#endif diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index dbf8a69..49f3fa7 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -43,8 +43,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported Operating System #endif diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index ddfc7f4..f65d90c 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -44,8 +44,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported Operating System #endif diff --git a/lnet/include/lnet/lnet.h b/lnet/include/lnet/lnet.h index 7901fb9..8b07c24 100644 --- a/lnet/include/lnet/lnet.h +++ b/lnet/include/lnet/lnet.h @@ -42,8 +42,6 @@ */ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported Operating System #endif diff --git a/lnet/klnds/socklnd/Info.plist b/lnet/klnds/socklnd/Info.plist deleted file mode 100644 index f5a5460..0000000 --- a/lnet/klnds/socklnd/Info.plist +++ /dev/null @@ -1,39 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ksocklnd - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.ksocklnd - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - com.clusterfs.lustre.libcfs - 1.0.0 - com.clusterfs.lustre.lnet - 1.0.0 - - - diff --git a/lnet/klnds/socklnd/autoMakefile.am b/lnet/klnds/socklnd/autoMakefile.am index ea8861b..8fac7a6 100644 --- a/lnet/klnds/socklnd/autoMakefile.am +++ b/lnet/klnds/socklnd/autoMakefile.am @@ -8,22 +8,4 @@ endif # MODULES EXTRA_DIST := $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h -if DARWIN - macos_PROGRAMS = ksocklnd - - nodist_ksocklnd_SOURCES = socklnd.c socklnd_cb.c socklnd_proto.c - nodist_ksocklnd_SOURCES += socklnd_modparams.c socklnd_lib-darwin.c - EXTRA_DIST += socklnd_lib-darwin.c socklnd_lib-darwin.h - - ksocklnd_CFLAGS := $(EXTRA_KCFLAGS) - ksocklnd_LDFLAGS := $(EXTRA_KLDFLAGS) - ksocklnd_LDADD := $(EXTRA_KLIBS) - - plist_DATA = Info.plist - install_data_hook = fix-kext-ownership -endif # DARWIN - -EXTRA_DIST += $(plist_DATA) -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ socklnd_lib.c diff --git a/lnet/klnds/socklnd/ksocklnd.xcode/project.pbxproj b/lnet/klnds/socklnd/ksocklnd.xcode/project.pbxproj deleted file mode 100644 index cab8b43..0000000 --- a/lnet/klnds/socklnd/ksocklnd.xcode/project.pbxproj +++ /dev/null @@ -1,287 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 39; - objects = { - 06AA1262FFB20DD611CA28AA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - OPTIMIZATION_CFLAGS = "-O0"; - ZERO_LINK = YES; - }; - isa = PBXBuildStyle; - name = Development; - }; - 06AA1263FFB20DD611CA28AA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - ZERO_LINK = NO; - }; - isa = PBXBuildStyle; - name = Deployment; - }; -//060 -//061 -//062 -//063 -//064 -//080 -//081 -//082 -//083 -//084 - 089C1669FE841209C02AAC07 = { - buildSettings = { - }; - buildStyles = ( - 06AA1262FFB20DD611CA28AA, - 06AA1263FFB20DD611CA28AA, - ); - hasScannedForEncodings = 1; - isa = PBXProject; - mainGroup = 089C166AFE841209C02AAC07; - projectDirPath = ""; - targets = ( - 32A4FEB80562C75700D090E7, - ); - }; - 089C166AFE841209C02AAC07 = { - children = ( - 247142CAFF3F8F9811CA285C, - 089C167CFE841241C02AAC07, - 19C28FB6FE9D52B211CA2CBB, - ); - isa = PBXGroup; - name = ksocknal; - refType = 4; - sourceTree = ""; - }; - 089C167CFE841241C02AAC07 = { - children = ( - 32A4FEC30562C75700D090E7, - ); - isa = PBXGroup; - name = Resources; - refType = 4; - sourceTree = ""; - }; -//080 -//081 -//082 -//083 -//084 -//190 -//191 -//192 -//193 -//194 - 1957C5680737C71F00425049 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = socknal.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 1957C5690737C71F00425049 = { - fileRef = 1957C5680737C71F00425049; - isa = PBXBuildFile; - settings = { - }; - }; - 1957C56A0737C72F00425049 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = socknal_cb.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 1957C56B0737C72F00425049 = { - fileRef = 1957C56A0737C72F00425049; - isa = PBXBuildFile; - settings = { - }; - }; - 1957C5B20737C78E00425049 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = socknal_lib.c; - path = arch/xnu/socknal_lib.c; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 1957C5B30737C78E00425049 = { - fileRef = 1957C5B20737C78E00425049; - isa = PBXBuildFile; - settings = { - }; - }; - 19C28FB6FE9D52B211CA2CBB = { - children = ( - 32A4FEC40562C75800D090E7, - ); - isa = PBXGroup; - name = Products; - refType = 4; - sourceTree = ""; - }; -//190 -//191 -//192 -//193 -//194 -//240 -//241 -//242 -//243 -//244 - 247142CAFF3F8F9811CA285C = { - children = ( - 1957C5B20737C78E00425049, - 1957C56A0737C72F00425049, - 1957C5680737C71F00425049, - ); - isa = PBXGroup; - name = Source; - path = ""; - refType = 4; - sourceTree = ""; - }; -//240 -//241 -//242 -//243 -//244 -//320 -//321 -//322 -//323 -//324 - 32A4FEB80562C75700D090E7 = { - buildPhases = ( - 32A4FEB90562C75700D090E7, - 32A4FEBA0562C75700D090E7, - 32A4FEBB0562C75700D090E7, - 32A4FEBD0562C75700D090E7, - 32A4FEBF0562C75700D090E7, - 32A4FEC00562C75700D090E7, - 32A4FEC10562C75700D090E7, - ); - buildRules = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; - GCC_WARN_UNKNOWN_PRAGMAS = NO; - HEADER_SEARCH_PATHS = "../../include ./arch/xnu"; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/Extensions"; - LIBRARY_SEARCH_PATHS = ""; - MODULE_NAME = com.clusterfs.lustre.portals.knals.ksocknal; - MODULE_START = ksocknal_start; - MODULE_STOP = ksocknal_stop; - MODULE_VERSION = 1.0.1; - OTHER_CFLAGS = "-D__KERNEL__"; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = ksocknal; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost"; - WRAPPER_EXTENSION = kext; - }; - dependencies = ( - ); - isa = PBXNativeTarget; - name = ksocknal; - productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Extensions"; - productName = ksocknal; - productReference = 32A4FEC40562C75800D090E7; - productType = "com.apple.product-type.kernel-extension"; - }; - 32A4FEB90562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXShellScriptBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPreprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; - }; - 32A4FEBA0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBB0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBD0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - 1957C5690737C71F00425049, - 1957C56B0737C72F00425049, - 1957C5B30737C78E00425049, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEBF0562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEC00562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 32A4FEC10562C75700D090E7 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXShellScriptBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPostprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; - }; - 32A4FEC30562C75700D090E7 = { - isa = PBXFileReference; - lastKnownFileType = text.plist.xml; - path = Info.plist; - refType = 4; - sourceTree = ""; - }; - 32A4FEC40562C75800D090E7 = { - explicitFileType = wrapper.cfbundle; - includeInIndex = 0; - isa = PBXFileReference; - path = ksocknal.kext; - refType = 3; - sourceTree = BUILT_PRODUCTS_DIR; - }; - }; - rootObject = 089C1669FE841209C02AAC07; -} diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h index 5cf8d95..c67f717 100644 --- a/lnet/klnds/socklnd/socklnd.h +++ b/lnet/klnds/socklnd/socklnd.h @@ -30,8 +30,6 @@ #if defined(__linux__) #include "socklnd_lib-linux.h" -#elif defined(__APPLE__) -#include "socklnd_lib-darwin.h" #else #error Unsupported Operating System #endif diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c index 515b22f..96d4eec 100644 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ b/lnet/klnds/socklnd/socklnd_cb.c @@ -724,10 +724,6 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) KSOCK_MSG_NOOP, tx->tx_nob, tx->tx_niov, tx->tx_nkiov); - /* - * FIXME: SOCK_WMEM_QUEUED and SOCK_ERROR could block in __DARWIN8__ - * but they're used inside spinlocks a lot. - */ bufnob = libcfs_sock_wmem_queued(conn->ksnc_sock); spin_lock_bh(&sched->kss_lock); @@ -2265,8 +2261,6 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) /* Don't need the {get,put}connsock dance to deref ksnc_sock */ LASSERT (!conn->ksnc_closing); - /* SOCK_ERROR will reset error code of socket in - * some platform (like Darwin8.x) */ error = libcfs_sock_error(conn->ksnc_sock); if (error != 0) { ksocknal_conn_addref(conn); diff --git a/lnet/klnds/socklnd/socklnd_lib-darwin.c b/lnet/klnds/socklnd/socklnd_lib-darwin.c deleted file mode 100644 index 363183e..0000000 --- a/lnet/klnds/socklnd/socklnd_lib-darwin.c +++ /dev/null @@ -1,1078 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lnet/klnds/socklnd/socklnd_lib-darwin.c - * - * Darwin porting library - * Make things easy to port - * - * Author: Phil Schwan - */ -#include -#include -#include -#include -#include - -#include "socklnd.h" - -# if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM - -SYSCTL_DECL(_lnet); - -SYSCTL_NODE (_lnet, OID_AUTO, ksocknal, CTLFLAG_RW, - 0, "ksocknal_sysctl"); - -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, timeout, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_timeout, - 0, "timeout"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, credits, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_credits, - 0, "credits"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, peer_credits, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_peertxcredits, - 0, "peer_credits"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, nconnds, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_nconnds, - 0, "nconnds"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, min_reconnectms, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_min_reconnectms, - 0, "min_reconnectms"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, max_reconnectms, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_max_reconnectms, - 0, "max_reconnectms"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, eager_ack, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_eager_ack, - 0, "eager_ack"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, typed, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_typed_conns, - 0, "typed"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, min_bulk, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_min_bulk, - 0, "min_bulk"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, rx_buffer_size, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_rx_buffer_size, - 0, "rx_buffer_size"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, tx_buffer_size, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_tx_buffer_size, - 0, "tx_buffer_size"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, nagle, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_nagle, - 0, "nagle"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, keepalive_idle, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_keepalive_idle, - 0, "keepalive_idle"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, keepalive_count, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_keepalive_count, - 0, "keepalive_count"); -SYSCTL_INT(_lnet_ksocknal, OID_AUTO, keepalive_intvl, - CTLTYPE_INT | CTLFLAG_RW , &ksocknal_tunables.ksnd_keepalive_intvl, - 0, "keepalive_intvl"); - -struct ctl_table ksocknal_top_ctl_table [] = { - &sysctl__lnet_ksocknal, - &sysctl__lnet_ksocknal_timeout, - &sysctl__lnet_ksocknal_credits, - &sysctl__lnet_ksocknal_peer_credits, - &sysctl__lnet_ksocknal_nconnds, - &sysctl__lnet_ksocknal_min_reconnectms, - &sysctl__lnet_ksocknal_max_reconnectms, - &sysctl__lnet_ksocknal_eager_ack, - &sysctl__lnet_ksocknal_typed, - &sysctl__lnet_ksocknal_min_bulk, - &sysctl__lnet_ksocknal_rx_buffer_size, - &sysctl__lnet_ksocknal_tx_buffer_size, - &sysctl__lnet_ksocknal_nagle, - &sysctl__lnet_ksocknal_keepalive_idle, - &sysctl__lnet_ksocknal_keepalive_count, - &sysctl__lnet_ksocknal_keepalive_intvl, - NULL -}; - -int -ksocknal_lib_tunables_init () -{ - ksocknal_tunables.ksnd_sysctl = - register_sysctl_table (ksocknal_top_ctl_table); - - if (ksocknal_tunables.ksnd_sysctl == NULL) - return -ENOMEM; - - return 0; -} - -void -ksocknal_lib_tunables_fini () -{ - if (ksocknal_tunables.ksnd_sysctl != NULL) - unregister_sysctl_table (ksocknal_tunables.ksnd_sysctl); -} -#else -int -ksocknal_lib_tunables_init () -{ - return 0; -} - -void -ksocknal_lib_tunables_fini () -{ -} -#endif - -/* - * To use bigger buffer for socket: - * 1. Increase nmbclusters (Cannot increased by sysctl because it's ready only, so - * we must patch kernel). - * 2. Increase net.inet.tcp.reass.maxsegments - * 3. Increase net.inet.tcp.sendspace - * 4. Increase net.inet.tcp.recvspace - * 5. Increase kern.ipc.maxsockbuf - */ -#define KSOCKNAL_MAX_BUFFER (1152*1024) - -int -ksocknal_lib_get_conn_addrs (ksock_conn_t *conn) -{ - int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1, - &conn->ksnc_ipaddr, - &conn->ksnc_port); - - /* Didn't need the {get,put}connsock dance to deref ksnc_sock... */ - LASSERT (!conn->ksnc_closing); - - if (rc != 0) { - CERROR ("Error %d getting sock peer IP\n", rc); - return rc; - } - - rc = libcfs_sock_getaddr(conn->ksnc_sock, 0, - &conn->ksnc_myipaddr, NULL); - if (rc != 0) { - CERROR ("Error %d getting sock local IP\n", rc); - return rc; - } - - return 0; -} - -#ifdef __DARWIN8__ - -int -ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) -{ - socket_t sock = C2B_SOCK(conn->ksnc_sock); - size_t sndlen; - int nob; - int rc; - -#if SOCKNAL_SINGLE_FRAG_TX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_niov; -#endif - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = scratchiov, - .msg_iovlen = niov, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = MSG_DONTWAIT - }; - - int i; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i] = tx->tx_iov[i]; - nob += scratchiov[i].iov_len; - } - - /* - * XXX Liang: - * Linux has MSG_MORE, do we have anything to - * reduce number of partial TCP segments sent? - */ - rc = -sock_send(sock, &msg, MSG_DONTWAIT, &sndlen); - if (rc == 0) - rc = sndlen; - return rc; -} - -int -ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) -{ - socket_t sock = C2B_SOCK(conn->ksnc_sock); - lnet_kiov_t *kiov = tx->tx_kiov; - int rc; - int nob; - size_t sndlen; - -#if SOCKNAL_SINGLE_FRAG_TX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_nkiov; -#endif - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = scratchiov, - .msg_iovlen = niov, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = MSG_DONTWAIT - }; - - int i; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + - kiov[i].kiov_offset; - nob += scratchiov[i].iov_len = kiov[i].kiov_len; - } - - /* - * XXX Liang: - * Linux has MSG_MORE, do wen have anyting to - * reduce number of partial TCP segments sent? - */ - rc = -sock_send(sock, &msg, MSG_DONTWAIT, &sndlen); - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - if (rc == 0) - rc = sndlen; - return rc; -} - -int -ksocknal_lib_recv_iov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = conn->ksnc_rx_niov; -#endif - struct iovec *iov = conn->ksnc_rx_iov; - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = scratchiov, - .msg_iovlen = niov, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = 0 - }; - size_t rcvlen; - int nob; - int i; - int rc; - - LASSERT (niov > 0); - - for (nob = i = 0; i < niov; i++) { - scratchiov[i] = iov[i]; - nob += scratchiov[i].iov_len; - } - LASSERT (nob <= conn->ksnc_rx_nob_wanted); - rc = -sock_receive (C2B_SOCK(conn->ksnc_sock), &msg, MSG_DONTWAIT, &rcvlen); - if (rc == 0) - rc = rcvlen; - - return rc; -} - -int -ksocknal_lib_recv_kiov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = conn->ksnc_rx_nkiov; -#endif - lnet_kiov_t *kiov = conn->ksnc_rx_kiov; - struct msghdr msg = { - .msg_name = NULL, - .msg_namelen = 0, - .msg_iov = scratchiov, - .msg_iovlen = niov, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = 0 - }; - int nob; - int i; - size_t rcvlen; - int rc; - - /* NB we can't trust socket ops to either consume our iovs - * or leave them alone. */ - for (nob = i = 0; i < niov; i++) { - scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + \ - kiov[i].kiov_offset; - nob += scratchiov[i].iov_len = kiov[i].kiov_len; - } - LASSERT (nob <= conn->ksnc_rx_nob_wanted); - rc = -sock_receive(C2B_SOCK(conn->ksnc_sock), &msg, MSG_DONTWAIT, &rcvlen); - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - if (rc == 0) - rc = rcvlen; - return (rc); -} - -void -ksocknal_lib_eager_ack (ksock_conn_t *conn) -{ - /* XXX Liang: */ -} - -int -ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) -{ - socket_t sock = C2B_SOCK(conn->ksnc_sock); - int len; - int rc; - - rc = ksocknal_connsock_addref(conn); - if (rc != 0) { - LASSERT (conn->ksnc_closing); - *txmem = *rxmem = *nagle = 0; - return (-ESHUTDOWN); - } - rc = libcfs_sock_getbuf(conn->ksnc_sock, txmem, rxmem); - if (rc == 0) { - len = sizeof(*nagle); - rc = -sock_getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, - nagle, &len); - } - ksocknal_connsock_decref(conn); - - if (rc == 0) - *nagle = !*nagle; - else - *txmem = *rxmem = *nagle = 0; - - return (rc); -} - -int -ksocknal_lib_setup_sock (cfs_socket_t *sock) -{ - int rc; - int option; - int keep_idle; - int keep_intvl; - int keep_count; - int do_keepalive; - socket_t so = C2B_SOCK(sock); - struct linger linger; - - /* Ensure this socket aborts active sends immediately when we close - * it. */ - linger.l_onoff = 0; - linger.l_linger = 0; - rc = -sock_setsockopt(so, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)); - if (rc != 0) { - CERROR ("Can't set SO_LINGER: %d\n", rc); - return (rc); - } - - if (!*ksocknal_tunables.ksnd_nagle) { - option = 1; - rc = -sock_setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)); - if (rc != 0) { - CERROR ("Can't disable nagle: %d\n", rc); - return (rc); - } - } - - rc = libcfs_sock_setbuf(sock, - *ksocknal_tunables.ksnd_tx_buffer_size, - *ksocknal_tunables.ksnd_rx_buffer_size); - if (rc != 0) { - CERROR ("Can't set buffer tx %d, rx %d buffers: %d\n", - *ksocknal_tunables.ksnd_tx_buffer_size, - *ksocknal_tunables.ksnd_rx_buffer_size, rc); - return (rc); - } - - /* snapshot tunables */ - keep_idle = *ksocknal_tunables.ksnd_keepalive_idle; - keep_count = *ksocknal_tunables.ksnd_keepalive_count; - keep_intvl = *ksocknal_tunables.ksnd_keepalive_intvl; - - do_keepalive = (keep_idle > 0 && keep_count > 0 && keep_intvl > 0); - option = (do_keepalive ? 1 : 0); - - rc = -sock_setsockopt(so, SOL_SOCKET, SO_KEEPALIVE, &option, sizeof(option)); - if (rc != 0) { - CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); - return (rc); - } - - if (!do_keepalive) - return (rc); - rc = -sock_setsockopt(so, IPPROTO_TCP, TCP_KEEPALIVE, - &keep_idle, sizeof(keep_idle)); - - return (rc); -} - -void -ksocknal_lib_push_conn(ksock_conn_t *conn) -{ - socket_t sock; - int val = 1; - int rc; - - rc = ksocknal_connsock_addref(conn); - if (rc != 0) /* being shut down */ - return; - sock = C2B_SOCK(conn->ksnc_sock); - - rc = -sock_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); - LASSERT(rc == 0); - - ksocknal_connsock_decref(conn); - return; -} - -extern void ksocknal_read_callback (ksock_conn_t *conn); -extern void ksocknal_write_callback (ksock_conn_t *conn); - -static void -ksocknal_upcall(socket_t so, void *arg, int waitf) -{ - ksock_conn_t *conn = (ksock_conn_t *)arg; - ENTRY; - - read_lock (&ksocknal_data.ksnd_global_lock); - if (conn == NULL) - goto out; - - ksocknal_read_callback (conn); - /* XXX Liang */ - ksocknal_write_callback (conn); -out: - read_unlock (&ksocknal_data.ksnd_global_lock); - EXIT; -} - -void -ksocknal_lib_save_callback(cfs_socket_t *sock, ksock_conn_t *conn) -{ - /* No callback need to save in osx */ - return; -} - -void -ksocknal_lib_set_callback(cfs_socket_t *sock, ksock_conn_t *conn) -{ - libcfs_sock_set_cb(sock, ksocknal_upcall, (void *)conn); - return; -} - -void -ksocknal_lib_reset_callback(cfs_socket_t *sock, ksock_conn_t *conn) -{ - libcfs_sock_reset_cb(sock); -} - -#else /* !__DARWIN8__ */ - -int -ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) -{ -#if SOCKNAL_SINGLE_FRAG_TX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_niov; -#endif - struct socket *sock = conn->ksnc_sock; - int nob; - int rc; - int i; - struct uio suio = { - .uio_iov = scratchiov, - .uio_iovcnt = niov, - .uio_offset = 0, - .uio_resid = 0, /* This will be valued after a while */ - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_WRITE, - .uio_procp = NULL - }; - int flags = MSG_DONTWAIT; - CFS_DECL_NET_DATA; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i] = tx->tx_iov[i]; - nob += scratchiov[i].iov_len; - } - suio.uio_resid = nob; - - CFS_NET_IN; - rc = sosend(sock, NULL, &suio, (struct mbuf *)0, (struct mbuf *)0, flags); - CFS_NET_EX; - - /* NB there is no return value can indicate how many - * have been sent and how many resid, we have to get - * sent bytes from suio. */ - if (rc != 0) { - if (suio.uio_resid != nob &&\ - (rc == ERESTART || rc == EINTR || rc == EWOULDBLOCK)) - /* We have sent something */ - rc = nob - suio.uio_resid; - else if ( rc == EWOULDBLOCK ) - /* Actually, EAGAIN and EWOULDBLOCK have same value in OSX */ - rc = -EAGAIN; - else - rc = -rc; - } else /* rc == 0 */ - rc = nob - suio.uio_resid; - - return rc; -} - -int -ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) -{ -#if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = tx->tx_nkiov; -#endif - struct socket *sock = conn->ksnc_sock; - lnet_kiov_t *kiov = tx->tx_kiov; - int nob; - int rc; - int i; - struct uio suio = { - .uio_iov = scratchiov, - .uio_iovcnt = niov, - .uio_offset = 0, - .uio_resid = 0, /* It should be valued after a while */ - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_WRITE, - .uio_procp = NULL - }; - int flags = MSG_DONTWAIT; - CFS_DECL_NET_DATA; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + - kiov[i].kiov_offset; - nob += scratchiov[i].iov_len = kiov[i].kiov_len; - } - suio.uio_resid = nob; - - CFS_NET_IN; - rc = sosend(sock, NULL, &suio, (struct mbuf *)0, (struct mbuf *)0, flags); - CFS_NET_EX; - - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - - if (rc != 0) { - if (suio.uio_resid != nob &&\ - (rc == ERESTART || rc == EINTR || rc == EWOULDBLOCK)) - /* We have sent something */ - rc = nob - suio.uio_resid; - else if ( rc == EWOULDBLOCK ) - /* EAGAIN and EWOULD BLOCK have same value in OSX */ - rc = -EAGAIN; - else - rc = -rc; - } else /* rc == 0 */ - rc = nob - suio.uio_resid; - - return rc; -} - -/* - * liang: Hack of inpcb and tcpcb. - * To get tcpcb of a socket, and call tcp_output - * to send quick ack. - */ -struct ks_tseg_qent{ - int foo; -}; - -struct ks_tcptemp{ - int foo; -}; - -LIST_HEAD(ks_tsegqe_head, ks_tseg_qent); - -struct ks_tcpcb { - struct ks_tsegqe_head t_segq; - int t_dupacks; - struct ks_tcptemp *unused; - int t_timer[4]; - struct inpcb *t_inpcb; - int t_state; - u_int t_flags; - /* - * There are more fields but we dont need - * ...... - */ -}; - -#define TF_ACKNOW 0x00001 -#define TF_DELACK 0x00002 - -struct ks_inpcb { - LIST_ENTRY(ks_inpcb) inp_hash; - struct in_addr reserved1; - struct in_addr reserved2; - u_short inp_fport; - u_short inp_lport; - LIST_ENTRY(inpcb) inp_list; - caddr_t inp_ppcb; - /* - * There are more fields but we dont need - * ...... - */ -}; - -#define ks_sotoinpcb(so) ((struct ks_inpcb *)(so)->so_pcb) -#define ks_intotcpcb(ip) ((struct ks_tcpcb *)(ip)->inp_ppcb) -#define ks_sototcpcb(so) (intotcpcb(sotoinpcb(so))) - -void -ksocknal_lib_eager_ack (ksock_conn_t *conn) -{ - struct socket *sock = conn->ksnc_sock; - struct ks_inpcb *inp = ks_sotoinpcb(sock); - struct ks_tcpcb *tp = ks_intotcpcb(inp); - int s; - CFS_DECL_NET_DATA; - - extern int tcp_output(register struct ks_tcpcb *tp); - - CFS_NET_IN; - s = splnet(); - - /* - * No TCP_QUICKACK supported in BSD, so I have to call tcp_fasttimo - * to send immediate ACK. - */ - if (tp && tp->t_flags & TF_DELACK){ - tp->t_flags &= ~TF_DELACK; - tp->t_flags |= TF_ACKNOW; - (void) tcp_output(tp); - } - splx(s); - - CFS_NET_EX; - - return; -} - -int -ksocknal_lib_recv_iov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = conn->ksnc_rx_niov; -#endif - struct iovec *iov = conn->ksnc_rx_iov; - int nob; - int rc; - int i; - struct uio ruio = { - .uio_iov = scratchiov, - .uio_iovcnt = niov, - .uio_offset = 0, - .uio_resid = 0, /* It should be valued after a while */ - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_READ, - .uio_procp = NULL - }; - int flags = MSG_DONTWAIT; - CFS_DECL_NET_DATA; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i] = iov[i]; - nob += scratchiov[i].iov_len; - } - LASSERT (nob <= conn->ksnc_rx_nob_wanted); - - ruio.uio_resid = nob; - - CFS_NET_IN; - rc = soreceive(conn->ksnc_sock, (struct sockaddr **)0, &ruio, (struct mbuf **)0, (struct mbuf **)0, &flags); - CFS_NET_EX; - if (rc){ - if (ruio.uio_resid != nob && \ - (rc == ERESTART || rc == EINTR || rc == EWOULDBLOCK || rc == EAGAIN)) - /* data particially received */ - rc = nob - ruio.uio_resid; - else if (rc == EWOULDBLOCK) - /* EAGAIN and EWOULD BLOCK have same value in OSX */ - rc = -EAGAIN; - else - rc = -rc; - } else - rc = nob - ruio.uio_resid; - - return (rc); -} - -int -ksocknal_lib_recv_kiov (ksock_conn_t *conn) -{ -#if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK - struct iovec scratch; - struct iovec *scratchiov = &scratch; - unsigned int niov = 1; -#else - struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; - unsigned int niov = conn->ksnc_rx_nkiov; -#endif - lnet_kiov_t *kiov = conn->ksnc_rx_kiov; - int nob; - int rc; - int i; - struct uio ruio = { - .uio_iov = scratchiov, - .uio_iovcnt = niov, - .uio_offset = 0, - .uio_resid = 0, - .uio_segflg = UIO_SYSSPACE, - .uio_rw = UIO_READ, - .uio_procp = NULL - }; - int flags = MSG_DONTWAIT; - CFS_DECL_NET_DATA; - - for (nob = i = 0; i < niov; i++) { - scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset; - nob += scratchiov[i].iov_len = kiov[i].kiov_len; - } - LASSERT (nob <= conn->ksnc_rx_nob_wanted); - - ruio.uio_resid = nob; - - CFS_NET_IN; - rc = soreceive(conn->ksnc_sock, (struct sockaddr **)0, &ruio, (struct mbuf **)0, NULL, &flags); - CFS_NET_EX; - - for (i = 0; i < niov; i++) - kunmap(kiov[i].kiov_page); - - if (rc){ - if (ruio.uio_resid != nob && \ - (rc == ERESTART || rc == EINTR || rc == EWOULDBLOCK)) - /* data particially received */ - rc = nob - ruio.uio_resid; - else if (rc == EWOULDBLOCK) - /* receive blocked, EWOULDBLOCK == EAGAIN */ - rc = -EAGAIN; - else - rc = -rc; - } else - rc = nob - ruio.uio_resid; - - return (rc); -} - -int -ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) -{ - struct socket *sock = conn->ksnc_sock; - int rc; - - rc = ksocknal_connsock_addref(conn); - if (rc != 0) { - LASSERT (conn->ksnc_closing); - *txmem = *rxmem = *nagle = 0; - return -ESHUTDOWN; - } - rc = libcfs_sock_getbuf(sock, txmem, rxmem); - if (rc == 0) { - struct sockopt sopt; - int len; - CFS_DECL_NET_DATA; - - len = sizeof(*nagle); - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = IPPROTO_TCP; - sopt.sopt_name = TCP_NODELAY; - sopt.sopt_val = nagle; - sopt.sopt_valsize = len; - - CFS_NET_IN; - rc = -sogetopt(sock, &sopt); - CFS_NET_EX; - } - - ksocknal_connsock_decref(conn); - - if (rc == 0) - *nagle = !*nagle; - else - *txmem = *rxmem = *nagle = 0; - return (rc); -} - -int -ksocknal_lib_setup_sock (struct socket *so) -{ - struct sockopt sopt; - int rc; - int option; - int keep_idle; - int keep_intvl; - int keep_count; - int do_keepalive; - struct linger linger; - CFS_DECL_NET_DATA; - - rc = libcfs_sock_setbuf(so, - *ksocknal_tunables.ksnd_tx_buffer_size, - *ksocknal_tunables.ksnd_rx_buffer_size); - if (rc != 0) { - CERROR ("Can't set buffer tx %d, rx %d buffers: %d\n", - *ksocknal_tunables.ksnd_tx_buffer_size, - *ksocknal_tunables.ksnd_rx_buffer_size, rc); - return (rc); - } - - /* Ensure this socket aborts active sends immediately when we close - * it. */ - bzero(&sopt, sizeof sopt); - - linger.l_onoff = 0; - linger.l_linger = 0; - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = SOL_SOCKET; - sopt.sopt_name = SO_LINGER; - sopt.sopt_val = &linger; - sopt.sopt_valsize = sizeof(linger); - - CFS_NET_IN; - rc = -sosetopt(so, &sopt); - if (rc != 0) { - CERROR ("Can't set SO_LINGER: %d\n", rc); - goto out; - } - - if (!*ksocknal_tunables.ksnd_nagle) { - option = 1; - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = IPPROTO_TCP; - sopt.sopt_name = TCP_NODELAY; - sopt.sopt_val = &option; - sopt.sopt_valsize = sizeof(option); - rc = -sosetopt(so, &sopt); - if (rc != 0) { - CERROR ("Can't disable nagle: %d\n", rc); - goto out; - } - } - - /* snapshot tunables */ - keep_idle = *ksocknal_tunables.ksnd_keepalive_idle; - keep_count = *ksocknal_tunables.ksnd_keepalive_count; - keep_intvl = *ksocknal_tunables.ksnd_keepalive_intvl; - - do_keepalive = (keep_idle > 0 && keep_count > 0 && keep_intvl > 0); - option = (do_keepalive ? 1 : 0); - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = SOL_SOCKET; - sopt.sopt_name = SO_KEEPALIVE; - sopt.sopt_val = &option; - sopt.sopt_valsize = sizeof(option); - rc = -sosetopt(so, &sopt); - if (rc != 0) { - CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); - goto out; - } - - if (!do_keepalive) { - /* no more setting, just return */ - rc = 0; - goto out; - } - - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = IPPROTO_TCP; - sopt.sopt_name = TCP_KEEPALIVE; - sopt.sopt_val = &keep_idle; - sopt.sopt_valsize = sizeof(keep_idle); - rc = -sosetopt(so, &sopt); - if (rc != 0) { - CERROR ("Can't set TCP_KEEPALIVE : %d\n", rc); - goto out; - } -out: - CFS_NET_EX; - return (rc); -} - -void -ksocknal_lib_push_conn(ksock_conn_t *conn) -{ - struct socket *sock; - struct sockopt sopt; - int val = 1; - int rc; - CFS_DECL_NET_DATA; - - rc = ksocknal_connsock_addref(conn); - if (rc != 0) /* being shut down */ - return; - sock = conn->ksnc_sock; - bzero(&sopt, sizeof sopt); - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = IPPROTO_TCP; - sopt.sopt_name = TCP_NODELAY; - sopt.sopt_val = &val; - sopt.sopt_valsize = sizeof val; - - CFS_NET_IN; - sosetopt(sock, &sopt); - CFS_NET_EX; - - ksocknal_connsock_decref(conn); - return; -} - - -extern void ksocknal_read_callback (ksock_conn_t *conn); -extern void ksocknal_write_callback (ksock_conn_t *conn); - -static void -ksocknal_upcall(struct socket *so, caddr_t arg, int waitf) -{ - ksock_conn_t *conn = (ksock_conn_t *)arg; - ENTRY; - - read_lock (&ksocknal_data.ksnd_global_lock); - if (conn == NULL) - goto out; - - if (so->so_rcv.sb_flags & SB_UPCALL) { - extern int soreadable(struct socket *so); - if (conn->ksnc_rx_nob_wanted && soreadable(so)) - /* To verify whether the upcall is for receive */ - ksocknal_read_callback (conn); - } - /* go foward? */ - if (so->so_snd.sb_flags & SB_UPCALL){ - extern int sowriteable(struct socket *so); - if (sowriteable(so)) - /* socket is writable */ - ksocknal_write_callback(conn); - } -out: - read_unlock (&ksocknal_data.ksnd_global_lock); - - EXIT; -} - -void -ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn) -{ - /* No callback need to save in osx */ - return; -} - -void -ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn) -{ - CFS_DECL_NET_DATA; - - CFS_NET_IN; - sock->so_upcallarg = (void *)conn; - sock->so_upcall = ksocknal_upcall; - sock->so_snd.sb_timeo = 0; - sock->so_rcv.sb_timeo = cfs_time_seconds(2); - sock->so_rcv.sb_flags |= SB_UPCALL; - sock->so_snd.sb_flags |= SB_UPCALL; - CFS_NET_EX; - return; -} - -void -ksocknal_lib_act_callback(struct socket *sock, ksock_conn_t *conn) -{ - CFS_DECL_NET_DATA; - - CFS_NET_IN; - ksocknal_upcall (sock, (void *)conn, 0); - CFS_NET_EX; -} - -void -ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn) -{ - CFS_DECL_NET_DATA; - - CFS_NET_IN; - sock->so_rcv.sb_flags &= ~SB_UPCALL; - sock->so_snd.sb_flags &= ~SB_UPCALL; - sock->so_upcall = NULL; - sock->so_upcallarg = NULL; - CFS_NET_EX; -} - -#endif /* !__DARWIN8__ */ diff --git a/lnet/klnds/socklnd/socklnd_lib-darwin.h b/lnet/klnds/socklnd/socklnd_lib-darwin.h deleted file mode 100644 index 7da8dcd..0000000 --- a/lnet/klnds/socklnd/socklnd_lib-darwin.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __XNU_SOCKNAL_LIB_H__ -#define __XNU_SOCKNAL_LIB_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#endif diff --git a/lnet/klnds/socklnd/socklnd_modparams.c b/lnet/klnds/socklnd/socklnd_modparams.c index 2244c52..42f28d8 100644 --- a/lnet/klnds/socklnd/socklnd_modparams.c +++ b/lnet/klnds/socklnd/socklnd_modparams.c @@ -63,12 +63,7 @@ static int max_reconnectms = 60000; CFS_MODULE_PARM(max_reconnectms, "i", int, 0644, "max connection retry interval (mS)"); -#if defined(__APPLE__) && !defined(__DARWIN8__) -# define DEFAULT_EAGER_ACK 1 -#else -# define DEFAULT_EAGER_ACK 0 -#endif -static int eager_ack = DEFAULT_EAGER_ACK; +static int eager_ack; CFS_MODULE_PARM(eager_ack, "i", int, 0644, "send tcp ack packets eagerly"); @@ -80,15 +75,7 @@ static int min_bulk = (1<<10); CFS_MODULE_PARM(min_bulk, "i", int, 0644, "smallest 'large' message"); -#ifdef __APPLE__ -# ifdef __DARWIN8__ -# define DEFAULT_BUFFER_SIZE (224*1024) -# else -# define DEFAULT_BUFFER_SIZE (1152 * 1024) -# endif -#else # define DEFAULT_BUFFER_SIZE 0 -#endif static int tx_buffer_size = DEFAULT_BUFFER_SIZE; CFS_MODULE_PARM(tx_buffer_size, "i", int, 0644, "socket tx buffer size (0 for system default)"); diff --git a/lnet/lnet/Info.plist b/lnet/lnet/Info.plist deleted file mode 100644 index 2b3967f..0000000 --- a/lnet/lnet/Info.plist +++ /dev/null @@ -1,37 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - lnet - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.lnet - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - com.clusterfs.lustre.libcfs - 1.0.0 - - - diff --git a/lnet/lnet/autoMakefile.am b/lnet/lnet/autoMakefile.am index 6978319..49dc222 100644 --- a/lnet/lnet/autoMakefile.am +++ b/lnet/lnet/autoMakefile.am @@ -18,27 +18,7 @@ if LINUX modulenet_DATA = lnet$(KMODEXT) endif # LINUX -if DARWIN -macos_PROGRAMS = lnet - -lnet_SOURCES = api-ni.c config.c -lnet_SOURCES += lib-me.c lib-msg.c lib-eq.c lib-md.c -lnet_SOURCES += lib-move.c module.c lo.c router.c router_proc.c -lnet_SOURCES += acceptor.c peer.c - -lnet_CFLAGS := $(EXTRA_KCFLAGS) -lnet_LDFLAGS := $(EXTRA_KLDFLAGS) -lnet_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif # DARWIN - endif # MODULES -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ lnet -EXTRA_DIST = $(lnet-objs:%.o=%.c) Info.plist +EXTRA_DIST = $(lnet-objs:%.o=%.c) diff --git a/lnet/selftest/autoMakefile.am b/lnet/selftest/autoMakefile.am index 0688f16..04d726e 100644 --- a/lnet/selftest/autoMakefile.am +++ b/lnet/selftest/autoMakefile.am @@ -17,7 +17,5 @@ endif # LINUX endif # MODULES -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ selftest EXTRA_DIST = $(lnet_selftest-objs:%.o=%.c) console.h conrpc.h rpc.h selftest.h timer.h diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c index 098c2a9..8702818 100644 --- a/lnet/utils/debug.c +++ b/lnet/utils/debug.c @@ -93,47 +93,6 @@ dbg_write_cmd(int fd, char *str, int len) return (rc == len ? 0 : 1); } -#elif defined(__DARWIN__) - -#define DAEMON_CTL_NAME "lnet.trace_daemon" -#define SUBSYS_DEBUG_CTL_NAME "lnet.subsystem_debug" -#define DEBUG_CTL_NAME "lnet.debug" -#define DUMP_KERNEL_CTL_NAME "lnet.trace_dumpkernel" - -static char sysctl_name[128]; -static int -dbg_open_ctlhandle(const char *str) -{ - - if (strlen(str)+1 > 128) { - fprintf(stderr, "sysctl name is too long: %s.\n", str); - return -1; - } - strcpy(sysctl_name, str); - - return 0; -} - -static void -dbg_close_ctlhandle(int fd) -{ - sysctl_name[0] = '\0'; - return; -} - -static int -dbg_write_cmd(int fd, char *str, int len) -{ - int rc; - - rc = sysctlbyname(sysctl_name, NULL, NULL, str, len+1); - if (rc != 0) { - fprintf(stderr, "sysctl %s with cmd (%s) error: %d\n", - sysctl_name, str, errno); - } - return (rc == 0 ? 0: 1); -} - #else #error - Unknown sysctl convention. #endif diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index a9fd267..e42acbf 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -37,7 +37,7 @@ AC_SUBST(pkgexampledir) # AC_DEFUN([LC_TARGET_SUPPORTED], [ case $target_os in - linux* | darwin*) + linux*) $1 ;; *) @@ -1944,7 +1944,6 @@ lustre/doc/Makefile lustre/include/Makefile lustre/include/lustre_ver.h lustre/include/linux/Makefile -lustre/include/darwin/Makefile lustre/include/lustre/Makefile lustre/kernel_patches/targets/3.10-rhel7.target lustre/kernel_patches/targets/2.6-rhel6.target @@ -2012,6 +2011,5 @@ lustre/osp/Makefile lustre/osp/autoMakefile lustre/lod/Makefile lustre/lod/autoMakefile -lustre/obdclass/darwin/Makefile ]) ]) # LC_CONFIG_FILES diff --git a/lustre/fid/autoMakefile.am b/lustre/fid/autoMakefile.am index db183fa..ef2297e 100644 --- a/lustre/fid/autoMakefile.am +++ b/lustre/fid/autoMakefile.am @@ -38,6 +38,4 @@ if MODULES modulefs_DATA = fid$(KMODEXT) endif -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index 093b587..c40cf4e 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -38,7 +38,7 @@ SUBDIRS = linux lustre -DIST_SUBDIRS = linux lustre darwin +DIST_SUBDIRS = linux lustre EXTRA_DIST = \ cl_object.h \ diff --git a/lustre/include/darwin/.gitignore b/lustre/include/darwin/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/lustre/include/darwin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/lustre/include/darwin/Makefile.am b/lustre/include/darwin/Makefile.am deleted file mode 100644 index fb8b591..0000000 --- a/lustre/include/darwin/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -EXTRA_DIST = lprocfs_status.h lustre_debug.h lustre_lib.h \ - lustre_dlm.h lustre_handles.h lustre_net.h obd_class.h obd_support.h \ - lustre_log.h lustre_compat.h lustre_mds.h obd.h \ - lvfs.h lustre_lite.h lustre_quota.h \ - lustre_user.h diff --git a/lustre/include/darwin/lprocfs_status.h b/lustre/include/darwin/lprocfs_status.h deleted file mode 100644 index 9fb37e7..0000000 --- a/lustre/include/darwin/lprocfs_status.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - * - * lustre/include/darwin/lprocfs_status.h - * - * Author: Hariharan Thantry thantry@users.sourceforge.net - */ -#ifndef _DARWIN_LPROCFS_SNMP_H -#define _DARWIN_LPROCFS_SNMP_H - -#ifndef _LPROCFS_SNMP_H -#error Do not #include this file directly. #include instead -#endif - -#ifdef LPROCFS -#undef LPROCFS -#endif - -#include -#define kstatfs statfs - -/* - * XXX nikita: temporary! Stubs for naked procfs calls made by Lustre - * code. Should be replaced with our own procfs-like API. - */ - -static inline cfs_proc_dir_entry_t *proc_symlink(const char *name, - cfs_proc_dir_entry_t *parent, - const char *dest) -{ - return NULL; -} - -static inline cfs_proc_dir_entry_t *create_proc_entry(const char *name, - mode_t mode, - cfs_proc_dir_entry_t *p) -{ - return NULL; -} - -#endif /* XNU_LPROCFS_SNMP_H */ diff --git a/lustre/include/darwin/lustre_compat.h b/lustre/include/darwin/lustre_compat.h deleted file mode 100644 index 05c8961..0000000 --- a/lustre/include/darwin/lustre_compat.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_LUSTRE_COMPAT_H__ -#define __DARWIN_LUSTRE_COMPAT_H__ - -#include - -#ifdef __KERNEL__ - -#ifndef HLIST_HEAD -#define hlist_entry list_entry -#define hlist_head list_head -#define hlist_node list_head -#define hlist_del_init list_del_init -#define hlist_add_head list_add -#define hlist_for_each_safe list_for_each_safe - -/* XXX */ -#define LOOKUP_COBD 4096 - -#endif - -struct module; -static inline int try_module_get(struct module *module) -{ - return 1; -} - -static inline void module_put(struct module *module) -{ -} - -#define THIS_MODULE NULL - -static inline void lustre_daemonize_helper(void) -{ - return; -} - -static inline int32_t ext2_set_bit(int nr, void *a) -{ - int32_t old = test_bit(nr, a); - set_bit(nr, a); - return old; -} - -static inline int32_t ext2_clear_bit(int nr, void *a) -{ - int32_t old = test_bit(nr, a); - clear_bit(nr, a); - return old; -} - -struct nameidata; - -#if !defined(__DARWIN8__) -static inline int ll_path_lookup(const char *path, unsigned int flags, struct nameidata *nd) -{ - int ret = 0; - NDINIT(nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)path, current_proc()); - if (ret = namei(nd)){ - CERROR("ll_path_lookup fail!\n"); - } - return ret; -} -#endif - -#define ext2_test_bit test_bit - -#endif /* __KERNEL__ */ - -#endif diff --git a/lustre/include/darwin/lustre_debug.h b/lustre/include/darwin/lustre_debug.h deleted file mode 100644 index 663b46a..0000000 --- a/lustre/include/darwin/lustre_debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_DEBUG_H -#define _DARWIN_LUSTRE_DEBUG_H - -#ifndef _LUSTRE_DEBUG_H -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ -#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) do {} while (0) -#else -#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) do {} while (0) -#endif - -#endif diff --git a/lustre/include/darwin/lustre_dlm.h b/lustre/include/darwin/lustre_dlm.h deleted file mode 100644 index 0a3db53..0000000 --- a/lustre/include/darwin/lustre_dlm.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_DLM_H__ -#define _DARWIN_LUSTRE_DLM_H__ - -#ifndef _LUSTRE_DLM_H__ -#error Do not #include this file directly. #include instead -#endif -#endif diff --git a/lustre/include/darwin/lustre_handles.h b/lustre/include/darwin/lustre_handles.h deleted file mode 100644 index c416e61..0000000 --- a/lustre/include/darwin/lustre_handles.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_LUSTRE_HANDLES_H_ -#define __DARWIN_LUSTRE_HANDLES_H_ - -#ifndef __LUSTRE_HANDLES_H_ -#error Do not #include this file directly. #include instead -#endif - -#include -#include - -#define call_rcu(rcu, cb) (cb)(rcu) - -#endif diff --git a/lustre/include/darwin/lustre_lib.h b/lustre/include/darwin/lustre_lib.h deleted file mode 100644 index ddbb19f..0000000 --- a/lustre/include/darwin/lustre_lib.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * copy of GPLv2]. - * - * 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. - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/include/darwin/lustre_lib.h - * - * Basic Lustre library routines. - */ - -#ifndef _DARWIN_LUSTRE_LIB_H -#define _DARWIN_LUSTRE_LIB_H - -#ifndef _LUSTRE_LIB_H -#error Do not #include this file directly. #include instead -#endif - -#include -#include - -#ifndef LP_POISON -#define LI_POISON ((int)0x5a5a5a5a) -#define LL_POISON ((long)0x5a5a5a5a) -#define LP_POISON ((void *)(long)0x5a5a5a5a) -#endif - -#ifndef LPU64 -#define LPU64 "%llu" -#define LPD64 "%lld" -#define LPX64 "%llx" -#define LPO64 "%llo" -#endif - -struct obd_ioctl_data; -#define OBD_IOC_DATA_TYPE struct obd_ioctl_data - -#define LUSTRE_FATAL_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | \ - sigmask(SIGTERM) | sigmask(SIGQUIT) | \ - sigmask(SIGALRM) | sigmask(SIGHUP)) - -#endif diff --git a/lustre/include/darwin/lustre_lite.h b/lustre/include/darwin/lustre_lite.h deleted file mode 100644 index e88c8c2..0000000 --- a/lustre/include/darwin/lustre_lite.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - * - * lustre/include/darwin/lustre_lite.h - * - * lustre lite cluster file system - */ - -#ifndef _DARWIN_LL_H -#define _DARWIN_LL_H - -#ifndef _LL_H -#error Do not #include this file directly. #include instead -#endif - -#include - -#ifdef __KERNEL__ - -struct iattr { - unsigned int ia_valid; - umode_t ia_mode; - uid_t ia_uid; - gid_t ia_gid; - loff_t ia_size; - time_t ia_atime; - time_t ia_mtime; - time_t ia_ctime; - unsigned int ia_attr_flags; -}; - -#define INTENT_MAGIC 0x19620323 /* Happy birthday! */ - -struct lustre_intent_data { - int it_disposition; - int it_status; - __u64 it_lock_handle; - void *it_data; - int it_lock_mode; -}; - -/* - * Liang: We keep the old lookup_intent struct in XNU - * to avoid unnecessary allocate/free. - */ -#define LUSTRE_IT(it) ((struct lustre_intent_data *)(&(it)->d.lustre)) - -struct lookup_intent { - int it_magic; - void (*it_op_release)(struct lookup_intent *); - int it_op; - int it_create_mode; - __u64 it_flags; - union { - struct lustre_intent_data lustre; - void *fs_data; - } d; -}; - -struct super_operations{ -}; -#endif - -#endif diff --git a/lustre/include/darwin/lustre_log.h b/lustre/include/darwin/lustre_log.h deleted file mode 100644 index f0cff05..0000000 --- a/lustre/include/darwin/lustre_log.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_LOG_H -#define _DARWIN_LUSTRE_LOG_H - -#ifndef _LUSTRE_LOG_H -#error Do not #include this file directly. #include instead -#endif - -#undef LUSTRE_LOG_SERVER -#include - -#endif diff --git a/lustre/include/darwin/lustre_mds.h b/lustre/include/darwin/lustre_mds.h deleted file mode 100644 index dbbae4a..0000000 --- a/lustre/include/darwin/lustre_mds.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_MDS_H -#define _DARWIN_LUSTRE_MDS_H - -#ifndef _LUSTRE_MDS_H -#error Do not #include this file directly. #include instead -#endif - -#include -#include - -#endif diff --git a/lustre/include/darwin/lustre_net.h b/lustre/include/darwin/lustre_net.h deleted file mode 100644 index bcfeb42..0000000 --- a/lustre/include/darwin/lustre_net.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_NET_H -#define _DARWIN_LUSTRE_NET_H - -#ifndef _LUSTRE_NET_H -#error Do not #include this file directly. #include instead -#endif - -#include - -#undef WITH_GROUP_INFO - -#endif diff --git a/lustre/include/darwin/lustre_quota.h b/lustre/include/darwin/lustre_quota.h deleted file mode 100644 index da7321c..0000000 --- a/lustre/include/darwin/lustre_quota.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_LUSTRE_QUOTA_H -#define _DARWIN_LUSTRE_QUOTA_H - -#ifndef _LUSTRE_QUOTA_H -#error Do not #include this file directly. #include instead -#endif - -#ifdef __KERNEL__ -#include -#endif - - -#endif /* _LUSTRE_QUOTA_H */ diff --git a/lustre/include/darwin/lustre_user.h b/lustre/include/darwin/lustre_user.h deleted file mode 100644 index 5c219bf..0000000 --- a/lustre/include/darwin/lustre_user.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - * - * lustre/include/darwin/lustre_user.h - * - * Lustre public user-space interface definitions. - */ - -#ifndef _DARWIN_LUSTRE_USER_H -#define _DARWIN_LUSTRE_USER_H - -#ifndef __KERNEL__ -/* for llmount */ -# include -# include -# include -# include -# include -# include -# include -# include -# include -#endif - -typedef struct stat lstat_t; -#define HAVE_LOV_USER_MDS_DATA - -#ifndef LPU64 -#if (BITS_PER_LONG == 32 || __WORDSIZE == 32) -# define LPU64 "%llu" -# define LPD64 "%lld" -# define LPX64 "%#llx" -# define LPO64 "%#llo" -#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64) -# define LPU64 "%lu" -# define LPD64 "%ld" -# define LPX64 "%#lx" -# define LPO64 "%#lo" -#endif -#endif /* !LPU64 */ - -#endif /* _LUSTRE_USER_H */ diff --git a/lustre/include/darwin/lvfs.h b/lustre/include/darwin/lvfs.h deleted file mode 100644 index a51a4dc..0000000 --- a/lustre/include/darwin/lvfs.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_LVFS_H__ -#define __DARWIN_LVFS_H__ - -#ifndef __LVFS_H__ -#error Do not #include this file directly. #include instead -#endif - -struct lvfs_run_ctxt { - int pid; -}; - -#endif diff --git a/lustre/include/darwin/obd.h b/lustre/include/darwin/obd.h deleted file mode 100644 index be1000b..0000000 --- a/lustre/include/darwin/obd.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_OBD_H -#define __DARWIN_OBD_H - -#ifndef __OBD_H -#error Do not #include this file directly. #include instead -#endif - -#include - -typedef struct semaphore client_obd_lock_t; - -static inline void client_obd_list_lock_init(client_obd_lock_t *lock) -{ - sema_init(lock, 1); -} - -static inline void client_obd_list_lock_done(client_obd_lock_t *lock) -{} - -static inline void client_obd_list_lock(client_obd_lock_t *lock) -{ - mutex_down(lock); -} - -static inline void client_obd_list_unlock(client_obd_lock_t *lock) -{ - mutex_up(lock); -} - -#endif /* __DARWIN_OBD_H */ diff --git a/lustre/include/darwin/obd_cksum.h b/lustre/include/darwin/obd_cksum.h deleted file mode 100644 index 90e4514..0000000 --- a/lustre/include/darwin/obd_cksum.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * - * This file is part of Lustre, http://www.lustre.org. - * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre 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 for more details. - * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef __DARWIN_OBD_CKSUM -#define __DARWIN_OBD_CKSUM - -#ifndef __OBD_CKSUM -#error Do not #include this file directly. #include instead -#endif - -#include - -#if !defined(__KERNEL__) && defined(HAVE_ADLER) -# include -#endif /* !__KERNEL__ */ - -#endif diff --git a/lustre/include/darwin/obd_class.h b/lustre/include/darwin/obd_class.h deleted file mode 100644 index 6c77a44..0000000 --- a/lustre/include/darwin/obd_class.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef __DARWIN_CLASS_OBD_H -#define __DARWIN_CLASS_OBD_H - -#ifndef __CLASS_OBD_H -#error Do not #include this file directly. #include instead -#endif - -#endif /* __XNU_OBD_CLASS_H */ diff --git a/lustre/include/darwin/obd_support.h b/lustre/include/darwin/obd_support.h deleted file mode 100644 index 5d2c939..0000000 --- a/lustre/include/darwin/obd_support.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#ifndef _DARWIN_OBD_SUPPORT -#define _DARWIN_OBD_SUPPORT - -#ifndef _OBD_SUPPORT -#error Do not #include this file directly. #include instead -#endif - -#include - -#endif diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 3deb990..a72ae4b 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -44,8 +44,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 002b56f..5754070 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -56,8 +56,6 @@ #include #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_acl.h b/lustre/include/lustre_acl.h index b8e996e..fcca1fc 100644 --- a/lustre/include/lustre_acl.h +++ b/lustre/include/lustre_acl.h @@ -39,8 +39,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #endif #endif diff --git a/lustre/include/lustre_debug.h b/lustre/include/lustre_debug.h index 0bd6e57..a1a879c 100644 --- a/lustre/include/lustre_debug.h +++ b/lustre/include/lustre_debug.h @@ -47,8 +47,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 8c6ce8e..2aa2e7de 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -50,8 +50,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_handles.h b/lustre/include/lustre_handles.h index 05b83e6..5b6f30f 100644 --- a/lustre/include/lustre_handles.h +++ b/lustre/include/lustre_handles.h @@ -44,8 +44,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 31d3b0c..f829172 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -52,8 +52,6 @@ #include #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_lite.h b/lustre/include/lustre_lite.h index 68f6493..666855a 100644 --- a/lustre/include/lustre_lite.h +++ b/lustre/include/lustre_lite.h @@ -44,8 +44,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 34958d6..3ea5be1 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -58,8 +58,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 4f2546f..3ed63bf 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -57,8 +57,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index f357dbc..7c6121c 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -34,8 +34,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #endif #include diff --git a/lustre/include/lvfs.h b/lustre/include/lvfs.h index 1fc8847..a1ae6de 100644 --- a/lustre/include/lvfs.h +++ b/lustre/include/lvfs.h @@ -43,8 +43,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 486340d..d7eb8b0 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -42,8 +42,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 37dcecb..12784c9 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -50,8 +50,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index c1e914e..6213ddf 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -42,8 +42,6 @@ #if defined(__linux__) #include -#elif defined(__APPLE__) -#include #else #error Unsupported operating system. #endif diff --git a/lustre/lov/autoMakefile.am b/lustre/lov/autoMakefile.am index 0b698a0..a77a6aa 100644 --- a/lustre/lov/autoMakefile.am +++ b/lustre/lov/autoMakefile.am @@ -40,6 +40,4 @@ if MODULES modulefs_DATA = lov$(KMODEXT) endif # MODULES -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/obdclass/Info.plist b/lustre/obdclass/Info.plist deleted file mode 100644 index 0b7e718..0000000 --- a/lustre/obdclass/Info.plist +++ /dev/null @@ -1,39 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - obdclass - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.obdclass - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - com.clusterfs.lustre.libcfs - 1.0.0 - com.clusterfs.lustre.lvfs - 1.0.0 - - - diff --git a/lustre/obdclass/autoMakefile.am b/lustre/obdclass/autoMakefile.am index 717c89a..66b7c25 100644 --- a/lustre/obdclass/autoMakefile.am +++ b/lustre/obdclass/autoMakefile.am @@ -1,8 +1,5 @@ SUBDIRS = linux -if DARWIN -SUBDIRS += darwin -endif -DIST_SUBDIRS = linux darwin +DIST_SUBDIRS = linux if LIBLUSTRE noinst_LIBRARIES = liblustreclass.a @@ -28,31 +25,7 @@ modulefs_DATA += llog_test$(KMODEXT) endif # TESTS endif # LINUX -if DARWIN -macos_PROGRAMS = obdclass - -obdclass_SOURCES = \ - darwin/darwin-module.c darwin/darwin-sysctl.c \ - class_obd.c genops.c lprocfs_status.c \ - lustre_handles.c lustre_peer.c obd_config.c \ - obdo.c debug.c llog_ioctl.c uuid.c \ - llog_swab.c llog_obd.c llog.c llog_cat.c \ - lu_object.c dt_object.c lu_ref.c \ - lprocfs_counters.c - -obdclass_CFLAGS := $(EXTRA_KCFLAGS) -obdclass_LDFLAGS := $(EXTRA_KLDFLAGS) -obdclass_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif # DARWIN - endif # MODULES -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ -MOSTLYCLEANFILES += linux/*.o darwin/*.o +MOSTLYCLEANFILES += linux/*.o diff --git a/lustre/obdclass/darwin/.gitignore b/lustre/obdclass/darwin/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/lustre/obdclass/darwin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/lustre/obdclass/darwin/Makefile.am b/lustre/obdclass/darwin/Makefile.am deleted file mode 100644 index 77480f6..0000000 --- a/lustre/obdclass/darwin/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -EXTRA_DIST = \ - darwin-module.c \ - darwin-sysctl.c diff --git a/lustre/obdclass/darwin/darwin-module.c b/lustre/obdclass/darwin/darwin-module.c deleted file mode 100644 index faf2815..0000000 --- a/lustre/obdclass/darwin/darwin-module.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifndef OBD_MAX_IOCTL_BUFFER -#ifdef CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER -#define OBD_MAX_IOCTL_BUFFER CONFIG_LUSTRE_OBD_MAX_IOCTL_BUFFER -#else -#define OBD_MAX_IOCTL_BUFFER 8192 -#endif -#endif - -/* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void *arg) -{ - struct obd_ioctl_hdr *hdr; - struct obd_ioctl_data *data; - int err = 0; - int offset = 0; - ENTRY; - - hdr = (struct obd_ioctl_hdr *)arg; - if (hdr->ioc_version != OBD_IOCTL_VERSION) { - CERROR("Version mismatch kernel vs application\n"); - RETURN(-EINVAL); - } - - if (hdr->ioc_len > OBD_MAX_IOCTL_BUFFER) { - CERROR("User buffer len %d exceeds %d max buffer\n", - hdr->ioc_len, OBD_MAX_IOCTL_BUFFER); - RETURN(-EINVAL); - } - - if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) { - CERROR("OBD: user buffer too small for ioctl (%d)\n", hdr->ioc_len); - RETURN(-EINVAL); - } - - OBD_ALLOC_LARGE(*buf, hdr->ioc_len); - if (*buf == NULL) { - CERROR("Cannot allocate control buffer of len %d\n", - hdr->ioc_len); - RETURN(-EINVAL); - } - *len = hdr->ioc_len; - data = (struct obd_ioctl_data *)*buf; - - bzero(data, hdr->ioc_len); - memcpy(data, (void *)arg, sizeof(struct obd_ioctl_data)); - if (data->ioc_inlbuf1) - err = copy_from_user(&data->ioc_bulk[0], (void *)data->ioc_inlbuf1, - hdr->ioc_len - ((void *)&data->ioc_bulk[0] - (void *)data)); - - if (obd_ioctl_is_invalid(data)) { - CERROR("ioctl not correctly formatted\n"); - OBD_FREE_LARGE(*buf, hdr->ioc_len); - return -EINVAL; - } - - if (data->ioc_inllen1) { - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - offset += size_round(data->ioc_inllen1); - } - - if (data->ioc_inllen2) { - data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; - offset += size_round(data->ioc_inllen2); - } - - if (data->ioc_inllen3) { - data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; - offset += size_round(data->ioc_inllen3); - } - - if (data->ioc_inllen4) { - data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; - } - - EXIT; - return 0; -} - -int obd_ioctl_popdata(void *arg, void *data, int len) -{ - /* - * Xnu ioctl copyout(uaddr, arg, sizeof(struct obd_ioctl_data)), - * we have to copyout data exceed sizeof(struct obd_ioctl_data) - * by ourself. - */ - if (len <= sizeof(struct obd_ioctl_data)) { - memcpy(arg, data, len); - return 0; - } else { - int err; - struct obd_ioctl_data *u = (struct obd_ioctl_data *)arg; - struct obd_ioctl_data *k = (struct obd_ioctl_data *)data; - err = copy_to_user((void *)u->ioc_inlbuf1, &k->ioc_bulk[0], - len -((void *)&k->ioc_bulk[0] -(void *)k)); - memcpy(arg, data, sizeof(struct obd_ioctl_data)); - return err; - } -} - -static int -obd_class_open(dev_t dev, int flags, int devtype, struct proc *p) -{ - ENTRY; - - RETURN(0); -} - -/* closing /dev/obd */ -static int -obd_class_release(dev_t dev, int flags, int mode, struct proc *p) -{ - ENTRY; - - RETURN(0); -} - -static int -obd_class_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) -{ - int err = 0; - ENTRY; - - if (!is_suser()) - RETURN (EPERM); - - err = class_handle_ioctl(cmd, (unsigned long)arg); - - RETURN(err); -} - -static struct cdevsw obd_psdevsw = { - obd_class_open, - obd_class_release, - NULL, - NULL, - obd_class_ioctl, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, -}; - -struct miscdevice obd_psdev = { - -1, - NULL, - "obd", - &obd_psdevsw -}; - -int class_procfs_init(void) -{ - return 0; -} - -int class_procfs_clean(void) -{ - return 0; -} diff --git a/lustre/obdclass/darwin/darwin-sysctl.c b/lustre/obdclass/darwin/darwin-sysctl.c deleted file mode 100644 index e636f41..0000000 --- a/lustre/obdclass/darwin/darwin-sysctl.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#ifndef BUILD_VERSION -#define BUILD_VERSION "Unknown" -#endif - -struct ctl_table_header *obd_table_header = NULL; - -int proc_obd_timeout SYSCTL_HANDLER_ARGS; -extern unsigned int obd_dump_on_timeout; -extern unsigned int obd_timeout; -extern unsigned int ldlm_timeout; -extern atomic_t obd_memory; - -int read_build_version SYSCTL_HANDLER_ARGS; - -SYSCTL_NODE (, OID_AUTO, lustre, CTLFLAG_RW, - 0, "lustre sysctl top"); -SYSCTL_PROC(_lustre, OID_AUTO, timeout, - CTLTYPE_INT | CTLFLAG_RW , &obd_timeout, - 0, &proc_obd_timeout, "I", "obd_timeout"); -SYSCTL_PROC(_lustre, OID_AUTO, build_version, - CTLTYPE_STRING | CTLFLAG_RD , NULL, - 0, &read_build_version, "A", "lustre_build_version"); -SYSCTL_INT(_lustre, OID_AUTO, dump_on_timeout, - CTLTYPE_INT | CTLFLAG_RW, &obd_dump_on_timeout, - 0, "lustre_dump_on_timeout"); -SYSCTL_INT(_lustre, OID_AUTO, debug_peer_on_timeout, - CTLTYPE_INT | CTLFLAG_RW, &obd_debug_peer_on_timeout, - 0, "lustre_debug_peer_on_timeout"); -SYSCTL_INT(_lustre, OID_AUTO, memused, - CTLTYPE_INT | CTLFLAG_RW, (int *)&obd_memory.counter, - 0, "lustre_memory_used"); -SYSCTL_INT(_lustre, OID_AUTO, ldlm_timeout, - CTLTYPE_INT | CTLFLAG_RW, &ldlm_timeout, - 0, "ldlm_timeout"); - -static struct ctl_table parent_table[] = { - &sysctl__lustre, - &sysctl__lustre_timeout, - &sysctl__lustre_dump_on_timeout, - &sysctl__lustre_debug_peer_on_timeout, - &sysctl__lustre_upcall, - &sysctl__lustre_memused, - &sysctl__lustre_filter_sync_on_commit, - &sysctl__lustre_ldlm_timeout, -}; - -int proc_obd_timeout SYSCTL_HANDLER_ARGS -{ - int error = 0; - - error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if (!error && req->newptr != USER_ADDR_NULL) { - if (ldlm_timeout >= obd_timeout) - ldlm_timeout = max(obd_timeout / 3, 1U); - } else if (req->newptr != USER_ADDR_NULL) { - printf ("sysctl fail obd_timeout: %d.\n", error); - } else { - /* Read request */ - error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout); - } - return error; -} - -int read_build_version SYSCTL_HANDLER_ARGS -{ - int error = 0; - - error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); - if ( req->newptr != USER_ADDR_NULL) { - printf("sysctl read_build_version is read-only!\n"); - } else { - error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION)); - } - return error; -} - -void obd_sysctl_init (void) -{ -#if 1 - if ( !obd_table_header ) - obd_table_header = register_sysctl_table(parent_table); -#endif -} - -void obd_sysctl_clean (void) -{ -#if 1 - if ( obd_table_header ) - unregister_sysctl_table(obd_table_header); - obd_table_header = NULL; -#endif -} diff --git a/lustre/obdecho/Info.plist b/lustre/obdecho/Info.plist deleted file mode 100644 index 19a6096..0000000 --- a/lustre/obdecho/Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - obdecho - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.obdecho - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - com.clusterfs.lustre.libcfs - 1.0.0 - com.clusterfs.lustre.lvfs - 1.0.0 - com.clusterfs.lustre.obdclass - 1.0.0 - com.clusterfs.lustre.ptlrpc - 1.0.0 - com.clusterfs.lustre.osc - 1.0.0 - - - diff --git a/lustre/obdecho/autoMakefile.am b/lustre/obdecho/autoMakefile.am index 1beff82..b9c1dba 100644 --- a/lustre/obdecho/autoMakefile.am +++ b/lustre/obdecho/autoMakefile.am @@ -47,28 +47,6 @@ if MODULES if LINUX modulefs_DATA = obdecho$(KMODEXT) endif - -if DARWIN -macos_PROGRAMS = obdecho -obdecho_SOURCES = \ - echo_client.c - -if SERVER -obdecho_SOURCES += echo.c -endif - -obdecho_CFLAGS := $(EXTRA_KCFLAGS) -obdecho_LDFLAGS := $(EXTRA_KLDFLAGS) -obdecho_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif # darwin - endif # MODULES -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/osc/Info.plist b/lustre/osc/Info.plist deleted file mode 100644 index 727980d..0000000 --- a/lustre/osc/Info.plist +++ /dev/null @@ -1,43 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - osc - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.osc - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.bsd - 8.0.0b1 - com.apple.kpi.libkern - 8.0.0b1 - com.apple.kpi.mach - 8.0.0b1 - com.apple.kpi.unsupported - 8.0.0b1 - com.clusterfs.lustre.libcfs - 1.0.0 - com.clusterfs.lustre.lvfs - 1.0.0 - com.clusterfs.lustre.obdclass - 1.0.0 - com.clusterfs.lustre.ptlrpc - 1.0.0 - - - diff --git a/lustre/osc/autoMakefile.am b/lustre/osc/autoMakefile.am index 0efef0c..b749c64 100644 --- a/lustre/osc/autoMakefile.am +++ b/lustre/osc/autoMakefile.am @@ -50,31 +50,6 @@ if LINUX modulefs_DATA = osc$(KMODEXT) endif -if DARWIN -macos_PROGRAMS = osc - -osc_SOURCES = \ - osc_dev.c \ - osc_object.c \ - osc_page.c \ - osc_lock.c \ - osc_io.c \ - osc_request.c \ - osc_quota.c \ - osc_cache.c - -osc_CFLAGS := $(EXTRA_KCFLAGS) -osc_LDFLAGS := $(EXTRA_KLDFLAGS) -osc_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif # Darwin - endif -install-data-hook: $(install_data_hook) - MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/ptlrpc/Info.plist b/lustre/ptlrpc/Info.plist deleted file mode 100644 index 2b7d35f..0000000 --- a/lustre/ptlrpc/Info.plist +++ /dev/null @@ -1,33 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ptlrpc - CFBundleIconFile - - CFBundleIdentifier - com.clusterfs.lustre.ptlrpc - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - KEXT - CFBundleSignature - ???? - CFBundleVersion - 1.0.1 - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.clusterfs.lustre.libcfs - 1.0.0 - com.clusterfs.lustre.lnet - 1.0.0 - com.clusterfs.lustre.obdclass - 1.0.0 - - - diff --git a/lustre/ptlrpc/autoMakefile.am b/lustre/ptlrpc/autoMakefile.am index 06975a5..f2a5d7d 100644 --- a/lustre/ptlrpc/autoMakefile.am +++ b/lustre/ptlrpc/autoMakefile.am @@ -72,56 +72,10 @@ if LINUX modulefs_DATA = ptlrpc$(KMODEXT) endif #LINUX -if DARWIN -macos_PROGRAMS = ptlrpc - -ptlrpc_SOURCES = \ - ptlrpc_module.c \ - client.c \ - connection.c \ - events.c \ - import.c \ - llog_client.c \ - llog_net.c \ - llog_server.c \ - lproc_ptlrpc.c \ - niobuf.c \ - pack_generic.c \ - pers.c \ - pinger.c \ - ptlrpcd.c \ - recover.c \ - service.c \ - nrs.c \ - nrs_fifo.c \ - nrs_crr.c \ - nrs_orr.c \ - nrs_tbf.c \ - wiretest.c \ - sec.c \ - sec_bulk.c \ - sec_gc.c \ - sec_config.c \ - sec_lproc.c \ - sec_null.c \ - sec_plain.c \ - $(LDLM_COMM_SOURCES) - -ptlrpc_CFLAGS := $(EXTRA_KCFLAGS) -ptlrpc_LDFLAGS := $(EXTRA_KLDFLAGS) -ptlrpc_LDADD := $(EXTRA_KLIBS) - -plist_DATA = Info.plist - -install_data_hook = fix-kext-ownership - -endif # DARWIN - endif # MODULES if GSS SUBDIRS = gss endif -install-data-hook: $(install_data_hook) MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ ldlm_*.c l_lock.c interval_tree.c